Module: GNOME Panel Reference Manual

## Module Module — a module with one or more applets |

## Functions

GpAppletInfo * | (*GpGetAppletInfoFunc) ()
const gchar * | (*GetAppletIdFromIidFunc) ()
GtkWidget * | (*GetStandaloneMenuFunc) ()
void | gp_module_set_abi_version ()
void | gp_module_set_gettext_domain ()
void | gp_module_set_id ()
void | gp_module_set_version ()
void | gp_module_set_applet_ids ()
void | gp_module_set_get_applet_info ()
void | gp_module_set_compatibility ()
void | gp_module_set_standalone_menu ()
void | gp_module_load ()

## Types and Values

#define | GP_MODULE_ABI_VERSION
#define | GP_TYPE_MODULE
| GpModule

## Object Hierarchy

        GObject
        ╰── GpModule

## Includes

    #include <libngome-panel/gp-module.h>

## Description

A module with one or more applets.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    static gboolean
    example1_setup_about (GtkAboutDialog *dialog)
    {
      gtk_about_dialog_set_comments (about, "...");
      gtk_about_dialog_set_copyright (about, "...");
      // ...
    }

    static GpAppletInfo *
    example_get_applet_info (const gchar *id)
    {
      GpAppletInfo *info;

      if (g_strcmp0 (id, "example1") == 0)
        {
          info = gp_applet_info_new (example1_get_type,
                                     _("Example 1 name"),
                                     _("Example 1 description"),
                                     "example1-icon");

          gp_applet_info_set_about_dialog (info, example1_setup_about);
          gp_applet_info_set_help_uri (info, "help:example");
        }
      else if (g_strcmp0 (id, "example2") == 0)
        {
          info = gp_applet_info_new (example2_get_type,
                                     _("Example 2 name"),
                                     _("Example 2 description"),
                                     "example2-icon");

          gp_applet_info_set_backends (info, "x11");
        }
      else
        {
          info = NULL;
        }

      return info;
    }

    static const gchar *
    example_get_applet_id_from_iid (const gchar *iid)
    {
      if (g_strcmp0 (iid, "ExampleAppletFactory::Example1Applet") == 0)
        {
          return "example1";
        }
      else if (g_strcmp0 (iid, "ExampleAppletFactory::Example2Applet") == 0)
        {
          return "example2";
        }

      return NULL;
    }

    void
    gp_module_load (GpModule *module)
    {
      bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
      bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
      gp_module_set_gettext_domain (module, GETTEXT_PACKAGE);

      gp_module_set_abi_version (module, GP_MODULE_ABI_VERSION);

      gp_module_set_id (module, "org.example.example");
      gp_module_set_version (module, PACKAGE_VERSION);

      gp_module_set_applet_ids (module, "example1", "example2", NULL);

      gp_module_set_get_applet_info (module, example_get_applet_info);
      gp_module_set_compatibility (module, example_get_applet_id_from_iid);
    }

## Functions

### GpGetAppletInfoFunc ()

    GpAppletInfo *
    (*GpGetAppletInfoFunc) (const gchar *id);

Returns a GpAppletInfo.

#### Parameters

id | the applet id |

#### Returns

returns a GpAppletInfo.

[transfer full]

### GetAppletIdFromIidFunc ()

    const gchar *
    (*GetAppletIdFromIidFunc) (const gchar *iid);

Specifies the type of the module function called to convert old applet iid to new id. See `gp_module_set_compatibility()`.

#### Parameters

iid | the applet iid |

#### Returns

the applet id, or `NULL`.

[transfer none]

### GetStandaloneMenuFunc ()

    GtkWidget *
    (*GetStandaloneMenuFunc) (gboolean enable_tooltips,
                              gboolean locked_down,
                              guint menu_icon_size);

Specifies the type of the module function called to create a standalone menu.

#### Parameters

enable_tooltips | Whether the applet should show tooltips |
locked_down | Whether the applet is on locked down panel |
menu_icon_size | The size of icons in menus |

#### Returns

returns a GtkMenu.

[transfer full]

### gp_module_set_abi_version ()

    void
    gp_module_set_abi_version (GpModule *module,
                               guint32 abi_version);

This function must be called from `gp_module_load()`.

#### Parameters

module | a GpModule |
abi_version | `GP_MODULE_ABI_VERSION` |

### gp_module_set_gettext_domain ()

    void
    gp_module_set_gettext_domain (GpModule *module,
                                  const gchar *gettext_domain);

Sets the gettext domain for this module.

#### Parameters

module | a GpModule |
gettext_domain | the gettext domain |

### gp_module_set_id ()

    void
    gp_module_set_id (GpModule *module,
                      const gchar *id);

The module `id` must be globally unique. For this reason, it is very strongly recommended to use reverse domain style identifier: https://wiki.gnome.org/HowDoI/ChooseApplicationID

#### Parameters

module | a GpModule |
id | the id of this module |

### gp_module_set_version ()

    void
    gp_module_set_version (GpModule *module,
                           const gchar *version);

Sets the version of this module.

#### Parameters

module | a GpModule |
version | the version of this module |

### gp_module_set_applet_ids ()

    void
    gp_module_set_applet_ids (GpModule *module,
                              ...);

Sets the applets available in this module.

#### Parameters

module | a GpModuleInfo |
... | a `NULL`-terminated list of applet ids in this module |

### gp_module_set_get_applet_info ()

    void
    gp_module_set_get_applet_info (GpModule *module,
                                   GpGetAppletInfoFunc func);

Specifies a function to be used to get GpAppletInfo.

#### Parameters

module | a GpModule |
func | the function to call to get GpAppletInfo |

### gp_module_set_compatibility ()

    void
    gp_module_set_compatibility (GpModule *module,
                                 GetAppletIdFromIidFunc func);

Specifies a function to be used to convert old applet iid to id.

The function must check if iid is known to module and only then return new applet id.

#### Parameters

module | a GpModule |
func | the function to call to convert applet iid to id |

### gp_module_set_standalone_menu ()

    void
    gp_module_set_standalone_menu (GpModule *module,
                                   GetStandaloneMenuFunc func);

Specifies a function to be used to create standalone menu.

#### Parameters

module | a GpModule |
func | the function to call to create a menu |

### gp_module_load ()

    void
    gp_module_load (GpModule *module);

Required API for GNOME Panel modules to implement.

This function will be called after module has been loaded and should be used to setup all required module info. As minimum `gp_module_set_id()` and `gp_module_set_abi_version()` should be called.

#### Parameters

module | a GpModule |

## Types and Values

### GP_MODULE_ABI_VERSION

    #define GP_MODULE_ABI_VERSION 0x0001

The version of the module system's ABI.

### GP_TYPE_MODULE

    #define GP_TYPE_MODULE (gp_module_get_type ())

The type for GpModule.

### GpModule

    typedef struct _GpModule GpModule;

GpModule is an opaque data structure and can only be accessed using the following functions.