Class Gnome.AppletWidget
- Description
Applets are basically GNOME applications whose window sits inside the panel. Also the panel "takes care" of the applets by providing them with session saving and restarting, window management (inside of the panel), and a context menu.
The simplest applet one can write would be along the lines of:
int main( int argc, array argv ) { Gnome.init( "hello", "1.0", argv, 0 ); Gnome.AppletWidget("hello")->add(GTK1.Label("Hello World!"))->show_all(); GTK1.applet_widget_gtk_main(); }
This creates an applet which just sits on the panel, not really doing anything, in real life the label would be substituted by something which actually does something useful. As you can see the applet doesn't really take care of restarting itself.For the applet to be added to the menus, you need to install two files. Your x.gnorba file goes into $sysconfdir/CORBA/servers/ and the x.desktop file goes into $prefix/share/applets/<category>/.
Example hello.desktop:
[Desktop Entry] Name=Hello Applet Comment=An example Hello World type Applet Type=PanelApplet Exec=hello.pike Icon=gnome-hello.png Terminal=0
Example hello.gnorba:[hello] type=exe repo_id=IDL:GNOME/Applet:1.0 description=Hello Applet location_info=hello.pike
One thing to keep in mind is that the Exec line for the .desktop doesn't actually get executed when the Type is PanelApplet. The Exec line should be the GOAD ID specified in the .gnorba file (the "hello" enclosed by brackets). For a simple applet all you need to do is replace the hello.pike with the name of your applet executable.When the user right clicks on the applet, a menu appears, this is all handeled by the panel, so in order to add items to it you use a special interface to "add callbacks" to the menu. A very simple example would be (making our hello applet even more feature full):
void hello_there() { write( "Hello there, indeed!\n" ); } int main( int argc, array argv ) { Gnome.AppletWidget w; Gnome.init( "hello", "1.0", argv, 0 ); w = Gnome.AppletWidget("hello"); w->add(GTK1.Label("Hello World!"))->show_all(); w->register_callback( "hello", "Hello there", hello_there, 0 ); GTK1.applet_widget_gtk_main(); }
Now the user will see a "Hello There" menu item on the applet menu, and when selected, the applet will print "Hello There". Useful huh?Note that the first argument to the register_callback is just a string identifier of this callback, and can really be whatever you want. But it should NOT be translated as the label (the 2nd argument) should be.
Signals: back_change
change_orient
change_pixel_size
change_position
tooltip_state
- Inherit Plug
inherit GTK1.Plug : Plug
- Method create
Gnome.AppletWidget Gnome.AppletWidget(
string
applet_name
)- Description
Make a new applet and register us with the panel, if you decide to cancel the load before calling add, you should call abort_load.