GnuCash c935c2f+
Loading...
Searching...
No Matches
Files
Plugin Management Functions

Files

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

Management Functions

GncPluginManager * gnc_plugin_manager_get (void)
 Retrieve a pointer to the plugin manager.
 
void gnc_plugin_manager_add_plugin (GncPluginManager *manager, GncPlugin *plugin)
 Add a plugin to the list maintained by the plugin manager.
 
void gnc_plugin_manager_remove_plugin (GncPluginManager *manager, GncPlugin *plugin)
 Remove a plugin from the list maintained by the plugin manager.
 
GList * gnc_plugin_manager_get_plugins (GncPluginManager *manager)
 Get a list of all plugins being held by the plugin manager.
 
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.
 

Basic Object Implementation

#define GNC_TYPE_PLUGIN_MANAGER   (gnc_plugin_manager_get_type ())
 

Detailed Description

Macro Definition Documentation

◆ GNC_TYPE_PLUGIN_MANAGER

#define GNC_TYPE_PLUGIN_MANAGER   (gnc_plugin_manager_get_type ())

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

Function Documentation

◆ gnc_plugin_manager_add_plugin()

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

77{
78 gint index;
79
80 ENTER (" ");
81 g_return_if_fail (GNC_IS_PLUGIN_MANAGER (manager));
82 g_return_if_fail (GNC_IS_PLUGIN (plugin));
83
84 index = g_list_index (manager->plugins, plugin);
85
86 if (index >= 0)
87 return;
88
89 manager->plugins = g_list_append (manager->plugins, plugin);
90 g_hash_table_insert (manager->plugins_table,
91 g_strdup( GNC_PLUGIN_GET_CLASS(plugin)->plugin_name ),
92 plugin);
93
94 g_signal_emit (G_OBJECT (manager), signals[PLUGIN_ADDED], 0, plugin);
95 LEAVE ("added %s to GncPluginManager", gnc_plugin_get_name(plugin));
96}
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition qoflog.h:282
#define ENTER(format, args...)
Print a function entry debugging message.
Definition qoflog.h:272
const gchar * gnc_plugin_get_name(GncPlugin *plugin)
Retrieve the textual name of a plugin.
Definition gnc-plugin.c:212

◆ gnc_plugin_manager_get()

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

62{
63 if (singleton == NULL)
64 {
65 singleton = g_object_new (GNC_TYPE_PLUGIN_MANAGER,
66 NULL);
67 gnc_hook_add_dangler (HOOK_SHUTDOWN,
68 gnc_plugin_manager_shutdown, NULL, NULL);
69 }
70
71 return singleton;
72}

◆ gnc_plugin_manager_get_plugin()

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

135{
136 g_return_val_if_fail (GNC_IS_PLUGIN_MANAGER (manager), NULL);
137 g_return_val_if_fail (name != NULL, NULL);
138
139 return GNC_PLUGIN (g_hash_table_lookup (manager->plugins_table, name));
140}

◆ gnc_plugin_manager_get_plugins()

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

126{
127 g_return_val_if_fail (GNC_IS_PLUGIN_MANAGER (manager), NULL);
128
129 return g_list_copy (manager->plugins);
130}

◆ gnc_plugin_manager_remove_plugin()

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

101{
102 gint index;
103
104 ENTER (" ");
105 g_return_if_fail (GNC_IS_PLUGIN_MANAGER (manager));
106 g_return_if_fail (GNC_IS_PLUGIN (plugin));
107
108 index = g_list_index (manager->plugins, plugin);
109
110 if (index < 0)
111 return;
112
113 manager->plugins = g_list_remove (manager->plugins, plugin);
114 g_hash_table_remove (manager->plugins_table,
115 GNC_PLUGIN_GET_CLASS(plugin)->plugin_name);
116
117 g_signal_emit (G_OBJECT (manager), signals[PLUGIN_REMOVED], 0, plugin);
118
119 LEAVE ("removed %s from GncPluginManager",
120 gnc_plugin_get_name(plugin));
121 g_object_unref (plugin);
122}