| | |
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
Views: 603 | Replies: 0
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays bash binarysearch centimeter char convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory drawing dynamic executable fflush file floatingpointvalidation fork frequency getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling hardware highest homework i/o ide inches infiniteloop initialization interest kilometer lazy linked linkedlist linux linuxsegmentationfault list logical_drives match matrix meter microsoft motherboard multi mysql open opendocumentformat openwebfoundation pattern pause pdf pointer pointers posix power problem program programming pyramidusingturboccodes read recursion recv repetition scanf scheduling segmentationfault send shape single socketprograming socketprogramming spoonfeeding stack standard strchr string strings structures student suggestions system test testautomation unix urboc user voidmain() win32 win32api windows.h





