Hello World Example

In this section we will write a simple example applet. This simple applet will have no functionality and only displays a label with "Hello World" on the panel. For this simple applet only following three parts are needed:

An example is worth a million words, so here is the code for our Hello World applet.

Example 1. Hello World applet

1

While the previous example is simple, it can be useful to directly subclass the PanelApplet type. This makes it easy to have a per-applet instance private structure, among other benefits. Most of the code below is related to the GObject system and needed to subclass the Panel Applet. The only noteworthy difference is that the PANEL_APPLET_OUT_PROCESS_FACTORY macro now takes our subclassed type (e.g. HELLO_WORLD_TYPE_APPLET) as its second parameter, instead of PANEL_TYPE_APPLET.

Example 2. Hello World applet, with a PanelApplet subclass

1