GnuCash 2.3.0
Data Structures | Files
Plugin Management Functions
Plugins

Data Structures

struct  GncPluginManager
struct  GncPluginManagerClass

Files

file  gnc-plugin-manager.h
 

Plugin management functions for the GnuCash UI.


Basic Object Implementation

GType gnc_plugin_manager_get_type (void)
#define GNC_TYPE_PLUGIN_MANAGER   (gnc_plugin_manager_get_type ())
#define GNC_PLUGIN_MANAGER(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_MANAGER, GncPluginManager))
#define GNC_PLUGIN_MANAGER_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_MANAGER, GncPluginManagerClass))
#define GNC_IS_PLUGIN_MANAGER(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_MANAGER))
#define GNC_IS_PLUGIN_MANAGER_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_MANAGER))
#define GNC_PLUGIN_MANAGER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_MANAGER, GncPluginManagerClass))

Management Functions

GncPluginManagergnc_plugin_manager_get (void)
void gnc_plugin_manager_add_plugin (GncPluginManager *manager, GncPlugin *plugin)
void gnc_plugin_manager_remove_plugin (GncPluginManager *manager, GncPlugin *plugin)
GList * gnc_plugin_manager_get_plugins (GncPluginManager *manager)
GncPlugingnc_plugin_manager_get_plugin (GncPluginManager *manager, const gchar *name)

Define Documentation

#define GNC_TYPE_PLUGIN_MANAGER   (gnc_plugin_manager_get_type ())

Definition at line 61 of file gnc-plugin-manager.h.


Function Documentation

void gnc_plugin_manager_add_plugin ( GncPluginManager manager,
GncPlugin plugin 
)

Add a plugin to the list maintained by the plugin manager.

Parameters:
managerA pointer to the plugin manager. Retrieve this by calling gnc_plugin_manager_get().
pluginA pointer to the plugin to add.
Note:
This function assumes ownership of this plugin. Do not unref the plugin after passing it off to the plugin manager.

Definition at line 105 of file gnc-plugin-manager.c.

{
    GncPluginManagerPrivate *priv;
    gint index;

    ENTER (" ");
    g_return_if_fail (GNC_IS_PLUGIN_MANAGER (manager));
    g_return_if_fail (GNC_IS_PLUGIN (plugin));

    priv = GNC_PLUGIN_MANAGER_GET_PRIVATE(manager);
    index = g_list_index (priv->plugins, plugin);

    if (index >= 0)
        return;

    priv->plugins = g_list_append (priv->plugins, plugin);
    g_hash_table_insert (priv->plugins_table,
                         g_strdup( GNC_PLUGIN_GET_CLASS(plugin)->plugin_name ),
                         plugin);

    g_signal_emit (G_OBJECT (manager), signals[PLUGIN_ADDED], 0, plugin);
    LEAVE ("added %s to GncPluginManager", gnc_plugin_get_name(plugin));
}
GncPluginManager* gnc_plugin_manager_get ( void  )

Retrieve a pointer to the plugin manager. This object is a singleton, that can only be retrieved via this function. Once you have a pointer to the manager, you can call it to add/remove plugins, etc.

Returns:
A pointer to the plugin manager object.

Definition at line 91 of file gnc-plugin-manager.c.

{
    if (singleton == NULL)
    {
        singleton = g_object_new (GNC_TYPE_PLUGIN_MANAGER,
                                  NULL);
        gnc_hook_add_dangler (HOOK_UI_SHUTDOWN,
                              gnc_plugin_manager_shutdown, NULL);
    }

    return singleton;
}
GncPlugin* gnc_plugin_manager_get_plugin ( GncPluginManager manager,
const gchar *  name 
)

Find a plugin by name from the list of plugins being held by the plugin manager.

Parameters:
managerA pointer to the plugin manager. Retrieve this by calling gnc_plugin_manager_get().
nameThe name of the plugin to find.
Returns:
A pointer to the requested plugin, or NULL if the plugin couldn't be found.

Definition at line 170 of file gnc-plugin-manager.c.

{
    GncPluginManagerPrivate *priv;

    g_return_val_if_fail (GNC_IS_PLUGIN_MANAGER (manager), NULL);
    g_return_val_if_fail (name != NULL, NULL);

    priv = GNC_PLUGIN_MANAGER_GET_PRIVATE(manager);
    return GNC_PLUGIN (g_hash_table_lookup (priv->plugins_table, name));
}
GList* gnc_plugin_manager_get_plugins ( GncPluginManager manager)

Get a list of all plugins being held by the plugin manager. This function is used by the main gnucash window code to get the list of plugins that need to be added to a new top level window.

Parameters:
managerA pointer to the plugin manager. Retrieve this by calling gnc_plugin_manager_get().
Returns:
A list of plugins. This list is owned by the caller, and the must be frees when the caller is finished with it.

Definition at line 159 of file gnc-plugin-manager.c.

{
    GncPluginManagerPrivate *priv;

    g_return_val_if_fail (GNC_IS_PLUGIN_MANAGER (manager), NULL);

    priv = GNC_PLUGIN_MANAGER_GET_PRIVATE(manager);
    return g_list_copy (priv->plugins);
}
GType gnc_plugin_manager_get_type ( void  )

Retrieve the GType value for the gnucash plugin manager.

Returns:
The GType that corresponds to an object of this type.

Definition at line 63 of file gnc-plugin-manager.c.

{
    static GType gnc_plugin_manager_type = 0;

    if (gnc_plugin_manager_type == 0)
    {
        static const GTypeInfo our_info =
        {
            sizeof (GncPluginManagerClass),
            NULL,
            NULL,
            (GClassInitFunc) gnc_plugin_manager_class_init,
            NULL,
            NULL,
            sizeof (GncPluginManager),
            0,
            (GInstanceInitFunc) gnc_plugin_manager_init
        };

        gnc_plugin_manager_type = g_type_register_static (G_TYPE_OBJECT,
                                  "GncPluginManager",
                                  &our_info, 0);
    }

    return gnc_plugin_manager_type;
}
void gnc_plugin_manager_remove_plugin ( GncPluginManager manager,
GncPlugin plugin 
)

Remove a plugin from the list maintained by the plugin manager.

Parameters:
managerA pointer to the plugin manager. Retrieve this by calling gnc_plugin_manager_get().
pluginA pointer to the plugin to add.

Definition at line 131 of file gnc-plugin-manager.c.

{
    GncPluginManagerPrivate *priv;
    gint index;

    ENTER (" ");
    g_return_if_fail (GNC_IS_PLUGIN_MANAGER (manager));
    g_return_if_fail (GNC_IS_PLUGIN (plugin));

    priv = GNC_PLUGIN_MANAGER_GET_PRIVATE(manager);
    index = g_list_index (priv->plugins, plugin);

    if (index < 0)
        return;

    priv->plugins = g_list_remove (priv->plugins, plugin);
    g_hash_table_remove (priv->plugins_table,
                         GNC_PLUGIN_GET_CLASS(plugin)->plugin_name);

    g_signal_emit (G_OBJECT (manager), signals[PLUGIN_REMOVED], 0, plugin);

    LEAVE ("removed %s from GncPluginManager",
           gnc_plugin_get_name(plugin));
    g_object_unref (plugin);
}
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines