Setting Up the Menu

The only part of dealing with a context menu that is specific to applets is how to setup the context menu. Once it is setup, this is really just a matter of using GtkAction.

To setup the context menu of the applet, the panel_applet_setup_menu_from_file() function should be used, with a path to a menu XML file and a GtkActionGroup object containing all actions that are used in the menu XML file. The example below shows how to achieve this:

Example 3. Hello World applet, with a context menu

1

Here are the changes compared to the simple example with no context menu: