| Panel Applet Writer's Reference Manual | |||
|---|---|---|---|
| <<< Previous Page | Home | Up | Next Page >>> |
Most applets also place extra menu items into it context menu. It might be a good idea to port this next. In GNOME 1.x this was done using the applet_widget_register_stock_callback API call. In GNOME 2.x 3 things must be done
An xml desription of the popup menu must be written.
A description of the verbs must be prepared. This is basically a list of callbacks to be call when a certain menu item is clicked in the popup.
The menu is registered using a call to panel_applet_setup_menu.
The xml description should look something like this :
static const char fish_menu_xml [] =
"<popup name=\"button3\">\n"
" <menuitem name=\"Properties Item\" verb=\"BlahProperties\" _label=\"Properties ...\"\n"
" pixtype=\"stock\" pixname=\"gtk-properties\"/>\n"
" <menuitem name=\"Help Item\" verb=\"BlahHelp\" _label=\"Help\"\n"
" pixtype=\"stock\" pixname=\"gtk-help\"/>\n"
" <menuitem name=\"About Item\" verb=\"BlahAbout\" _label=\"About ...\"\n"
" pixtype=\"stock\" pixname=\"gnome-stock-about\"/>\n"
"</popup>\n";
|
This could also be in a seperate .xml file and loaded with panel_applet_setup_menu_from_file. The description of the verbs should look something like :
static const BonoboUIVerb fish_menu_verbs [] = {
BONOBO_UI_VERB ("BlahProperties", display_properties_dialog),
BONOBO_UI_VERB ("BlahHelp", display_help_dialog),
BONOBO_UI_VERB ("BlahAbout", display_about_dialog),
BONOBO_UI_VERB_END
};
|
This is just a list of callbacks invoked when the menu items are clicked. There are other macros you may use other than BONOBO_UI_VERB - see bonobo-ui-component.h.
To actually register the menu you just do something like :
panel_applet_setup_menu (PANEL_APPLET (blah->applet),
blah_menu_xml,
blah_menu_verbs,
blah);
|
The last argument is the user_data argument based back to the callbacks.
| <<< Previous Page | Home | Up | Next Page >>> |
| Porting Applets from the GNOME 1.x interfaces | The Panel Applet Library | ||