Panel Applet Factory

## Panel Applet Factory Panel Applet Factory — the factory that will create applets. |

## Stability Level

Unstable, unless otherwise indicated

## Synopsis

    #include <panel-applet.h>

    gboolean            (*PanelAppletFactoryCallback)       (PanelApplet *applet,
                                                             const gchar *iid,
                                                             gpointer user_data);
    #define             PANEL_APPLET_OUT_PROCESS_FACTORY    (id,
                                                             type,
                                                             callback,
                                                             data)
    #define             PANEL_APPLET_IN_PROCESS_FACTORY     (id,
                                                             type,
                                                             callback,
                                                             data)
    int                 panel_applet_factory_main           (const gchar *factory_id,
                                                             GType applet_type,
                                                             PanelAppletFactoryCallback callback,
                                                             gpointer data);

## Description

This API is used to create an applet factory. You need to call one and only one of these functions to get applets working in your binary.

## Details

### PanelAppletFactoryCallback ()

    gboolean            (*PanelAppletFactoryCallback)       (PanelApplet *applet,
                                                             const gchar *iid,
                                                             gpointer user_data);

The type used for callbacks after. The callback will usually check that `iid` is a valid applet type identifier for the applet factory, and will then fill `applet` with widgets, connect to signals, etc.

`applet` : | a newly-created PanelApplet.
`iid` : | identifier of the requested applet type.
`user_data` : | user data.
Returns : | `TRUE` if `iid` is a valid applet type identifier for the applet factory and if the creation of `applet` was successfully completed, `FALSE` otherwise.

### PANEL_APPLET_OUT_PROCESS_FACTORY()

    #define             PANEL_APPLET_OUT_PROCESS_FACTORY(id, type, callback, data)

Convenience macro providing a `main()` function for an out-of-process applet. Internally, it will call `panel_applet_factory_main()` to create the `factory_id` applet factory.

Applet instances created by the applet factory will use `applet_type` as GType. Unless you subclass PanelApplet, you should use `PANEL_TYPE_APPLET` as `applet_type`.

On creation of the applet instances, `callback` is called to setup the applet. If `callback` returns `FALSE`, the creation of the applet instance is cancelled.

It can only be used once, and is incompatible with the use of `PANEL_APPLET_IN_PROCESS_FACTORY` and `panel_applet_factory_main()`.

`id` : | identifier of an applet factory.
`type` : | GType of the applet this factory creates.
`callback` : | callback to be called when a new applet is created. [scope call]
`data` : | callback data. [closure]

### PANEL_APPLET_IN_PROCESS_FACTORY()

    #define             PANEL_APPLET_IN_PROCESS_FACTORY(id, type, callback, data)

Convenience macro providing the symbol needed to automatically register the `factory_id` applet factory for an in-process applet.

Applet instances created by the applet factory will use `applet_type` as GType. Unless you subclass PanelApplet, you should use `PANEL_TYPE_APPLET` as `applet_type`.

On creation of the applet instances, `callback` is called to setup the applet. If `callback` returns `FALSE`, the creation of the applet instance is cancelled.

It can only be used once, and is incompatible with the use of `PANEL_APPLET_OUT_PROCESS_FACTORY` and `panel_applet_factory_main()`.

`id` : | identifier of an applet factory.
`type` : | GType of the applet this factory creates.
`callback` : | callback to be called when a new applet is created. [scope call]
`data` : | callback data. [closure]

### panel_applet_factory_main ()

    int                 panel_applet_factory_main           (const gchar *factory_id,
                                                             GType applet_type,
                                                             PanelAppletFactoryCallback callback,
                                                             gpointer data);

Creates the applet factory for `factory_id`, so that the factory can create instances of the applet types it is associated with.

Applet instances created by the applet factory will use `applet_type` as GType. Unless you subclass PanelApplet, you should use `PANEL_TYPE_APPLET` as `applet_type`.

On creation of the applet instances, `callback` is called to setup the applet. If `callback` returns `FALSE`, the creation of the applet instance is cancelled.

If using C, it is recommended to use PANEL_APPLET_OUT_PROCESS_FACTORY instead as it will create a `main()` function for you.

It can only be used once, and is incompatible with the use of `PANEL_APPLET_IN_PROCESS_FACTORY` and `PANEL_APPLET_OUT_PROCESS_FACTORY`.

`factory_id` : | identifier of an applet factory.
`applet_type` : | GType of the applet this factory creates.
`callback` : | callback to be called when a new applet is created. [scope call]
`data` : | callback data. [closure]
Returns : | 0 on success, 1 if there is an error.