Panel Applet Writer's Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Next Page >>> |
Writing applets is very simple. You take some boiler plate code like below, change a couple of things and write the code that implements your widgetry. The hardest part is writing your widgetry - and its completely up to yourself how hard that should be.
As usual, following the pointless tradition of starting with an example of how get 'Hello World' on the screen in some form, here's just about the simplest applet you could write.
#include <string.h> #include <panel-applet.h> #include <gtk/gtklabel.h> static BonoboObject * hello_applet_new () { PanelApplet *applet; GtkWidget *label; label = gtk_label_new ("Hello World"); applet = panel_applet_new (label); return BONOBO_OBJECT (panel_applet_get_control (applet)); } static BonoboObject * hello_applet_factory (BonoboGenericFactory *this, const gchar *iid, gpointer data) { BonoboObject *applet = NULL; if (!strcmp (iid, "OAFIID:GNOME_HelloApplet")) applet = hello_applet_new (); return applet; } PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_HelloApplet_Factory", "The Hello World Applet", "0", hello_applet_factory, NULL) |
The code here is very similar to writing a normal Bonobo control. You define a factory using PANEL_APPLET_BONOBO_FACTORY(), passing it a factory functions like hello_applet_factory().
To crete a #PanelApplet object, you first should set up the widgets for you applet and then call panel_applet_new(), passing the top-level widget of the applet. For example, if you were writing a cdplayer applet, you would stuff all the buttons for cdplayer into a #GtkHBox, and then call
panel_applet_new (hbox); |
<<< Previous Page | Home | Next Page >>> | |
Panel Applet Writer's Reference Manual | Defining a Popup Context Menu |