Help with Gnome applet developement

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2004
Posts: 29
Reputation: trashed is an unknown quantity at this point 
Solved Threads: 0
trashed trashed is offline Offline
Light Poster

Help with Gnome applet developement

 
0
  #1
Nov 15th, 2008
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:

  1. #include <string.h>
  2. #include <stdio.h>
  3.  
  4. #include <panel-applet.h>
  5. #include <gtk/gtklabel.h>
  6. #include <gtk/gtkimage.h>
  7. #include <gtk/gtkbox.h>
  8.  
  9. static gboolean
  10. on_button_press (GtkWidget *event_box,
  11. GdkEventButton *event,
  12. gpointer data)
  13. {
  14. static int window_shown;
  15. static GtkWidget *window, *box, *image, *label;
  16. /* Don't react to anything other than the left mouse button;
  17.   return FALSE so the event is passed to the default handler */
  18. if (event->button != 1)
  19. return FALSE;
  20.  
  21. if (!window_shown) {
  22. window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  23. box = GTK_BOX (gtk_vbox_new (TRUE, 12));
  24. gtk_container_add (GTK_CONTAINER (window), box);
  25.  
  26. image = GTK_IMAGE (gtk_image_new_from_file
  27. ("/usr/share/pixmaps/camorama.png"));
  28. gtk_box_pack_start (GTK_BOX (box), image, TRUE, TRUE, 12);
  29.  
  30. label = gtk_label_new ("Hello World");
  31. gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 12);
  32.  
  33. gtk_widget_show_all (window);
  34. }
  35. else
  36. gtk_widget_hide (GTK_WIDGET (window));
  37.  
  38. window_shown = !window_shown;
  39. return TRUE;
  40. }
  41.  
  42. static gboolean
  43. myexample_applet_fill (PanelApplet *applet,
  44. const gchar *iid,
  45. gpointer data)
  46.  
  47. {
  48. GtkWidget *image, *event_box;
  49. printf("I just instantiated the image\n");
  50. if (strcmp (iid, "OAFIID:ExampleApplet") != 0)
  51. return FALSE;
  52.  
  53. image = gtk_image_new_from_file ("/usr/share/pixmaps/camorama.png");
  54. printf("I just loaded the image\n");
  55. event_box = gtk_event_box_new ();
  56. gtk_container_add (GTK_CONTAINER (event_box), image);
  57. printf("I just created the EB container\n");
  58. gtk_widget_show_all (GTK_WIDGET (applet));
  59. printf("I should be showing stuff\n");
  60.  
  61. g_signal_connect (G_OBJECT (event_box),
  62. "button_press_event",
  63. G_CALLBACK (on_button_press),
  64. image);
  65.  
  66. return TRUE;
  67. }
  68.  
  69.  
  70. PANEL_APPLET_BONOBO_FACTORY ("OAFIID:ExampleApplet_Factory",
  71. PANEL_TYPE_APPLET,
  72. "The Hello World Applet",
  73. "0",
  74. myexample_applet_fill,
  75. NULL);

What am I doing wrong?
Thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C Forum


Views: 603 | Replies: 0
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC