Using a Context Menu

The Panel Applet library uses GAction to define menu items appearing in the context menu of the applet. This chapter provides some guidelines to applet developers and explains how to setup the context menu.

Guidelines for Context Menu

To help guarantee consistency in the interaction with applets, there are some guidelines that are recommended to follow:

  • Do not make the context menu too long: if you have more than five or six menu items, then it might be worth investing efforts on rethinking what is important in the menu.

  • For the menu item that will enable the user to configure the applet, use "Preferences" for the label, and try to avoid "Configure", "Configuration", "Settings", etc.

  • Avoid putting a "Help" menu item. The user will usually explicitly add the applet, so it is expected that he knows what the applet is about. Putting a "Help" menu item in the context menu is therefore too prominent. It might make sense to add a "Help" button in the Preferences dialog, though.

  • If you agree, avoid putting a "About" menu item. To the user, applets are not different applications but elements of one global application, the panel. Of course, this means that credits for working on the applet are not visible to the user.

Menu XML File

The file that is used to setup menu with the panel_applet_setup_menu_from_file() function is a GtkUIManager UI definition file, without the top-level <ui> tag. It must only contain menuitem entries and separators. For example:

1
2
3
<menuitem name="Hello World Prefs" action="HelloWorldPrefs" />
<separator/>
<menuitem name="Hello World Say"   action="HelloWorldSay" />

Alternatively, the panel_applet_setup_menu() function can be used with a string containing directly the XML.