GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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)
 
#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)
 

Detailed Description

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.

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_append (priv->plugins, plugin);
122  g_hash_table_insert (priv->plugins_table,
123  g_strdup( GNC_PLUGIN_GET_CLASS(plugin)->plugin_name ),
124  plugin);
125 
126  g_signal_emit (G_OBJECT (manager), signals[PLUGIN_ADDED], 0, plugin);
127  LEAVE ("added %s to GncPluginManager", gnc_plugin_get_name(plugin));
128 }
#define ENTER(format, args...)
Definition: qoflog.h:261
const gchar * gnc_plugin_get_name(GncPlugin *plugin)
Definition: gnc-plugin.c:246
#define LEAVE(format, args...)
Definition: qoflog.h:271
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.

92 {
93  if (singleton == NULL)
94  {
95  singleton = g_object_new (GNC_TYPE_PLUGIN_MANAGER,
96  NULL);
97  gnc_hook_add_dangler (HOOK_UI_SHUTDOWN,
98  gnc_plugin_manager_shutdown, NULL);
99  }
100 
101  return singleton;
102 }
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.

172 {
174 
175  g_return_val_if_fail (GNC_IS_PLUGIN_MANAGER (manager), NULL);
176  g_return_val_if_fail (name != NULL, NULL);
177 
178  priv = GNC_PLUGIN_MANAGER_GET_PRIVATE(manager);
179  return GNC_PLUGIN (g_hash_table_lookup (priv->plugins_table, name));
180 }
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.

160 {
162 
163  g_return_val_if_fail (GNC_IS_PLUGIN_MANAGER (manager), NULL);
164 
165  priv = GNC_PLUGIN_MANAGER_GET_PRIVATE(manager);
166  return g_list_copy (priv->plugins);
167 }
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.

64 {
65  static GType gnc_plugin_manager_type = 0;
66 
67  if (gnc_plugin_manager_type == 0)
68  {
69  static const GTypeInfo our_info =
70  {
71  sizeof (GncPluginManagerClass),
72  NULL,
73  NULL,
74  (GClassInitFunc) gnc_plugin_manager_class_init,
75  NULL,
76  NULL,
77  sizeof (GncPluginManager),
78  0,
79  (GInstanceInitFunc) gnc_plugin_manager_init
80  };
81 
82  gnc_plugin_manager_type = g_type_register_static (G_TYPE_OBJECT,
83  "GncPluginManager",
84  &our_info, 0);
85  }
86 
87  return gnc_plugin_manager_type;
88 }
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.

133 {
135  gint index;
136 
137  ENTER (" ");
138  g_return_if_fail (GNC_IS_PLUGIN_MANAGER (manager));
139  g_return_if_fail (GNC_IS_PLUGIN (plugin));
140 
141  priv = GNC_PLUGIN_MANAGER_GET_PRIVATE(manager);
142  index = g_list_index (priv->plugins, plugin);
143 
144  if (index < 0)
145  return;
146 
147  priv->plugins = g_list_remove (priv->plugins, plugin);
148  g_hash_table_remove (priv->plugins_table,
149  GNC_PLUGIN_GET_CLASS(plugin)->plugin_name);
150 
151  g_signal_emit (G_OBJECT (manager), signals[PLUGIN_REMOVED], 0, plugin);
152 
153  LEAVE ("removed %s from GncPluginManager",
154  gnc_plugin_get_name(plugin));
155  g_object_unref (plugin);
156 }
#define ENTER(format, args...)
Definition: qoflog.h:261
const gchar * gnc_plugin_get_name(GncPlugin *plugin)
Definition: gnc-plugin.c:246
#define LEAVE(format, args...)
Definition: qoflog.h:271