| | |
Help with Gnome applet developement
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2004
Posts: 29
Reputation:
Solved Threads: 0
Hi all.
I am attempting my first Gnome applet creation and I found a great
tutorial at http://projects.gnome.org/ORBit2/appletstutorial.html .
Unfortunately, I am stuck where the example goes to load an image. I can
compile the applet and make it run but when I add it to the Gnome bar it
doesn't show anything. I have some printf's in the code and those work on
the console.
Here's the code I am working on:
What am I doing wrong?
Thanks
I am attempting my first Gnome applet creation and I found a great
tutorial at http://projects.gnome.org/ORBit2/appletstutorial.html .
Unfortunately, I am stuck where the example goes to load an image. I can
compile the applet and make it run but when I add it to the Gnome bar it
doesn't show anything. I have some printf's in the code and those work on
the console.
Here's the code I am working on:
C Syntax (Toggle Plain Text)
#include <string.h> #include <stdio.h> #include <panel-applet.h> #include <gtk/gtklabel.h> #include <gtk/gtkimage.h> #include <gtk/gtkbox.h> static gboolean on_button_press (GtkWidget *event_box, GdkEventButton *event, gpointer data) { static int window_shown; static GtkWidget *window, *box, *image, *label; /* Don't react to anything other than the left mouse button; return FALSE so the event is passed to the default handler */ if (event->button != 1) return FALSE; if (!window_shown) { window = gtk_window_new (GTK_WINDOW_TOPLEVEL); box = GTK_BOX (gtk_vbox_new (TRUE, 12)); gtk_container_add (GTK_CONTAINER (window), box); image = GTK_IMAGE (gtk_image_new_from_file ("/usr/share/pixmaps/camorama.png")); gtk_box_pack_start (GTK_BOX (box), image, TRUE, TRUE, 12); label = gtk_label_new ("Hello World"); gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 12); gtk_widget_show_all (window); } else gtk_widget_hide (GTK_WIDGET (window)); window_shown = !window_shown; return TRUE; } static gboolean myexample_applet_fill (PanelApplet *applet, const gchar *iid, gpointer data) { GtkWidget *image, *event_box; printf("I just instantiated the image\n"); if (strcmp (iid, "OAFIID:ExampleApplet") != 0) return FALSE; image = gtk_image_new_from_file ("/usr/share/pixmaps/camorama.png"); printf("I just loaded the image\n"); event_box = gtk_event_box_new (); gtk_container_add (GTK_CONTAINER (event_box), image); printf("I just created the EB container\n"); gtk_widget_show_all (GTK_WIDGET (applet)); printf("I should be showing stuff\n"); g_signal_connect (G_OBJECT (event_box), "button_press_event", G_CALLBACK (on_button_press), image); return TRUE; } PANEL_APPLET_BONOBO_FACTORY ("OAFIID:ExampleApplet_Factory", PANEL_TYPE_APPLET, "The Hello World Applet", "0", myexample_applet_fill, NULL);
What am I doing wrong?
Thanks
![]() |
Other Threads in the C Forum
- Previous Thread: Hi guys i need help with this
- Next Thread: Dos colors
| Thread Tools | Search this Thread |
Tag cloud for C
#include * append array arrays asterisks binarysearch calculate changingto char character cm command copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic execv feet fgets file fork forloop framework function functions givemetehcodez grade graphics gtkwinlinux hacking histogram homework include incrementoperators input intmain() iso kernel keyboard km lazy license linked linkedlist linux list lists locate logical_drives looping loopinsideloop. lowest matrix microsoft motherboard mqqueue number oddnumber odf opensource overwrite owf pdf performance pointer posix problem probleminc process program programming radix recursion recv recvblocked research reversing scanf scripting segmentationfault sequential socket socketprograming spoonfeeding standard string student systemcall testing threads turboc unix user variable wab whythiscodecausesegmentationfault windowsapi





