## Out-of-Process vs In-Process

Applets can either live in their own process ("out-of-process") or in the panel process ("in-process"). The decision to choose one or the other is done at build time, with the macro that you use to define the applet factory: `PANEL_APPLET_OUT_PROCESS_FACTORY()` is used for out-of-process applets while `PANEL_APPLET_IN_PROCESS_FACTORY()` is used for in-process applets. Obviously, only one of those two macros can be used. If both types should be supported, then each macro must be placed between preprocessor conditions and switched on through a configure option. For example:

    1
    2
    3
    4
    5
    #ifdef MY_APPLET_OUT_PROCESS_ENABLED
    PANEL_APPLET_OUT_PROCESS_FACTORY (...)
    #else
    PANEL_APPLET_IN_PROCESS_FACTORY (...)
    #endif

For most practical matters, from the applet perspective, the two options are the same. In-process applets do offer a slightly better performance when the applet is loaded, but this should not have much effect on the user experience. However, an in-process applet can potentially affect the whole behavior of the panel, especially in case of crashes or memory corruptions: a crash in an in-process applet will crash the whole panel. It is therefore recommended to use out-of-process applets.

The communication between the panel and the applet factory is done over D-Bus. When creating an applet, the panel will send a message to the D-Bus service of the applet factory. If the D-Bus service is not running yet, it must be started automatically. We use D-Bus activation for this, which requires install a standard D-Bus service file. This is only needed for, because in-process applets do no need to have their binary autostarted for obvious reasons.

Please refer to the D-Bus documentation for more information about D-Bus service files.

Here is an example for a D-Bus Service file. It should be named `org.gnome.panel.applet.HelloWorldFactory.service.in`

    1
    2
    3
    [D-BUS Service]
    Name=org.gnome.panel.applet.HelloWorldFactory
    Exec=@LOCATION@

Additionally you should adjust the build system to replace `@LOCATION@` by the install location of the applet binary. The file itself must be installed into `$(datadir)/dbus-1/services/`.

The next section contains an explanation how to setup the Makefile in order to install the service file to the correct location on the system.