943,929 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1090
  • C RSS
Nov 15th, 2008
0

Help with Gnome applet developement

Expand Post »
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
Reputation Points: 11
Solved Threads: 0
Light Poster
trashed is offline Offline
30 posts
since Oct 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Hi guys i need help with this
Next Thread in C Forum Timeline: Dos colors





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC