GnuCash  4.11-243-g1cac132214+
Files | Data Structures
Plugin Management Functions

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

Detailed Description

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

81 {
83  gint index;
84 
85  ENTER (" ");
86  g_return_if_fail (GNC_IS_PLUGIN_MANAGER (manager));
87  g_return_if_fail (GNC_IS_PLUGIN (plugin));
88 
89  priv = GNC_PLUGIN_MANAGER_GET_PRIVATE(manager);
90  index = g_list_index (priv->plugins, plugin);
91 
92  if (index >= 0)
93  return;
94 
95  priv->plugins = g_list_append (priv->plugins, plugin);
96  g_hash_table_insert (priv->plugins_table,
97  g_strdup( GNC_PLUGIN_GET_CLASS(plugin)->plugin_name ),
98  plugin);
99 
100  g_signal_emit (G_OBJECT (manager), signals[PLUGIN_ADDED], 0, plugin);
101  LEAVE ("added %s to GncPluginManager", gnc_plugin_get_name(plugin));
102 }
#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:217
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

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

66 {
67  if (singleton == NULL)
68  {
69  singleton = g_object_new (GNC_TYPE_PLUGIN_MANAGER,
70  NULL);
71  gnc_hook_add_dangler (HOOK_SHUTDOWN,
72  gnc_plugin_manager_shutdown, NULL, NULL);
73  }
74 
75  return singleton;
76 }

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

146 {
148 
149  g_return_val_if_fail (GNC_IS_PLUGIN_MANAGER (manager), NULL);
150  g_return_val_if_fail (name != NULL, NULL);
151 
152  priv = GNC_PLUGIN_MANAGER_GET_PRIVATE(manager);
153  return GNC_PLUGIN (g_hash_table_lookup (priv->plugins_table, name));
154 }

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

134 {
136 
137  g_return_val_if_fail (GNC_IS_PLUGIN_MANAGER (manager), NULL);
138 
139  priv = GNC_PLUGIN_MANAGER_GET_PRIVATE(manager);
140  return g_list_copy (priv->plugins);
141 }

◆ gnc_plugin_manager_get_type()

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.

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

107 {
109  gint index;
110 
111  ENTER (" ");
112  g_return_if_fail (GNC_IS_PLUGIN_MANAGER (manager));
113  g_return_if_fail (GNC_IS_PLUGIN (plugin));
114 
115  priv = GNC_PLUGIN_MANAGER_GET_PRIVATE(manager);
116  index = g_list_index (priv->plugins, plugin);
117 
118  if (index < 0)
119  return;
120 
121  priv->plugins = g_list_remove (priv->plugins, plugin);
122  g_hash_table_remove (priv->plugins_table,
123  GNC_PLUGIN_GET_CLASS(plugin)->plugin_name);
124 
125  g_signal_emit (G_OBJECT (manager), signals[PLUGIN_REMOVED], 0, plugin);
126 
127  LEAVE ("removed %s from GncPluginManager",
128  gnc_plugin_get_name(plugin));
129  g_object_unref (plugin);
130 }
#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:217
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282