Plugin Management Functions
[Plugins]


Files

file  gnc-plugin-manager.h
 Plugin management functions for the GnuCash UI.

Data Structures

struct  GncPluginManager
struct  GncPluginManagerClass

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:
manager A pointer to the plugin manager. Retrieve this by calling gnc_plugin_manager_get().
plugin A 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 101 of file gnc-plugin-manager.c.

00103 {
00104         GncPluginManagerPrivate *priv;
00105         gint index;
00106 
00107         ENTER (" ");
00108         g_return_if_fail (GNC_IS_PLUGIN_MANAGER (manager));
00109         g_return_if_fail (GNC_IS_PLUGIN (plugin));
00110 
00111         priv = GNC_PLUGIN_MANAGER_GET_PRIVATE(manager);
00112         index = g_list_index (priv->plugins, plugin);
00113 
00114         if (index >= 0)
00115                 return;
00116 
00117         priv->plugins = g_list_append (priv->plugins, plugin);
00118         g_hash_table_insert (priv->plugins_table,
00119                              g_strdup( GNC_PLUGIN_GET_CLASS(plugin)->plugin_name ),
00120                              plugin);
00121 
00122         g_signal_emit (G_OBJECT (manager), signals[PLUGIN_ADDED], 0, plugin);
00123         LEAVE ("added %s to GncPluginManager", gnc_plugin_get_name(plugin));
00124 }

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 88 of file gnc-plugin-manager.c.

00089 {
00090         if (singleton == NULL) {
00091                 singleton = g_object_new (GNC_TYPE_PLUGIN_MANAGER,
00092                                           NULL);
00093                 gnc_hook_add_dangler (HOOK_UI_SHUTDOWN,
00094                                       gnc_plugin_manager_shutdown, NULL);
00095         }
00096 
00097         return singleton;
00098 }

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:
manager A pointer to the plugin manager. Retrieve this by calling gnc_plugin_manager_get().
name The 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 166 of file gnc-plugin-manager.c.

00168 {
00169         GncPluginManagerPrivate *priv;
00170 
00171         g_return_val_if_fail (GNC_IS_PLUGIN_MANAGER (manager), NULL);
00172         g_return_val_if_fail (name != NULL, NULL);
00173 
00174         priv = GNC_PLUGIN_MANAGER_GET_PRIVATE(manager);
00175         return GNC_PLUGIN (g_hash_table_lookup (priv->plugins_table, name));
00176 }

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:
manager A 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 155 of file gnc-plugin-manager.c.

00156 {
00157         GncPluginManagerPrivate *priv;
00158 
00159         g_return_val_if_fail (GNC_IS_PLUGIN_MANAGER (manager), NULL);
00160         
00161         priv = GNC_PLUGIN_MANAGER_GET_PRIVATE(manager);
00162         return g_list_copy (priv->plugins);
00163 }

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 62 of file gnc-plugin-manager.c.

00063 {
00064         static GType gnc_plugin_manager_type = 0;
00065 
00066         if (gnc_plugin_manager_type == 0) {
00067                 static const GTypeInfo our_info = {
00068                         sizeof (GncPluginManagerClass),
00069                         NULL,
00070                         NULL,
00071                         (GClassInitFunc) gnc_plugin_manager_class_init,
00072                         NULL,
00073                         NULL,
00074                         sizeof (GncPluginManager),
00075                         0,
00076                         (GInstanceInitFunc) gnc_plugin_manager_init
00077                 };
00078                 
00079                 gnc_plugin_manager_type = g_type_register_static (G_TYPE_OBJECT,
00080                                                                   "GncPluginManager",
00081                                                                   &our_info, 0);
00082         }
00083 
00084         return gnc_plugin_manager_type;
00085 }

void gnc_plugin_manager_remove_plugin ( GncPluginManager manager,
GncPlugin plugin 
)

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

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

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

00129 {
00130         GncPluginManagerPrivate *priv;
00131         gint index;
00132         
00133         ENTER (" ");
00134         g_return_if_fail (GNC_IS_PLUGIN_MANAGER (manager));
00135         g_return_if_fail (GNC_IS_PLUGIN (plugin));
00136 
00137         priv = GNC_PLUGIN_MANAGER_GET_PRIVATE(manager);
00138         index = g_list_index (priv->plugins, plugin);
00139 
00140         if (index < 0)
00141                 return;
00142 
00143         priv->plugins = g_list_remove (priv->plugins, plugin);
00144         g_hash_table_remove (priv->plugins_table,
00145                              GNC_PLUGIN_GET_CLASS(plugin)->plugin_name);
00146 
00147         g_signal_emit (G_OBJECT (manager), signals[PLUGIN_REMOVED], 0, plugin);
00148 
00149         LEAVE ("removed %s from GncPluginManager", 
00150                gnc_plugin_get_name(plugin));
00151         g_object_unref (plugin);
00152 }


Generated on Mon Sep 8 05:04:40 2008 for GnuCash by  doxygen 1.5.2