38 #include <glib/gi18n.h> 47 static QofLogModule log_module = GNC_MOD_GUI;
49 static gpointer parent_class = NULL;
52 static void gnc_plugin_init (
GncPlugin *plugin_page,
54 static void gnc_plugin_finalize (GObject *
object);
67 #define GNC_PLUGIN_GET_PRIVATE(o) \ 68 ((GncPluginPrivate*)gnc_plugin_get_instance_private((GncPlugin*)o)) 80 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
82 parent_class = g_type_class_peek_parent (klass);
83 gobject_class->finalize = gnc_plugin_finalize;
96 gnc_plugin_init (
GncPlugin *plugin_page,
void *data)
101 G_OBJECT_CLASS(klass));
113 gnc_plugin_finalize (GObject *
object)
115 g_return_if_fail (GNC_IS_PLUGIN (
object));
118 G_OBJECT_CLASS (parent_class)->finalize (
object);
133 GtkActionGroup *action_group;
135 g_return_if_fail (GNC_IS_PLUGIN (plugin));
136 klass = GNC_PLUGIN_GET_CLASS (plugin);
145 DEBUG (
"%s: %d actions to merge with gui from %s",
165 if (GNC_PLUGIN_GET_CLASS (plugin)->add_to_window)
167 DEBUG (
"Calling child class function %p", GNC_PLUGIN_GET_CLASS (plugin)->add_to_window);
168 GNC_PLUGIN_GET_CLASS (plugin)->add_to_window (plugin, window, type);
186 g_return_if_fail (GNC_IS_PLUGIN (plugin));
187 klass = GNC_PLUGIN_GET_CLASS (plugin);
194 if (GNC_PLUGIN_GET_CLASS (plugin)->remove_from_window)
196 DEBUG (
"Calling child class function %p",
197 GNC_PLUGIN_GET_CLASS (plugin)->remove_from_window);
198 GNC_PLUGIN_GET_CLASS (plugin)->remove_from_window (plugin, window, type);
206 DEBUG (
"%s: %d actions to unmerge",
219 g_return_val_if_fail (GNC_IS_PLUGIN (plugin), NULL);
220 return (GNC_PLUGIN_GET_CLASS(plugin)->plugin_name);
243 action = gtk_action_group_get_action (action_group,
244 toolbar_labels[i].action_name);
245 gtk_action_set_short_label (action, _(toolbar_labels[i].label));
262 for (i = 0; name[i]; i++)
264 action = gtk_action_group_get_action (action_group, name[i]);
265 g_object_set (G_OBJECT(action),
"is_important", TRUE, NULL);
281 const gchar **action_names,
282 const gchar *property_name,
288 for (i = 0; action_names[i]; i++)
290 action = gtk_action_group_get_action (action_group, action_names[i]);
293 g_object_set (G_OBJECT(action), property_name, value, NULL);
297 g_warning(
"No such action with name '%s' in action group %s (size %d)",
298 action_names[i], gtk_action_group_get_name(action_group),
299 g_list_length(gtk_action_group_list_actions(action_group)));
310 GtkActionGroup *action_group,
311 const gchar *filename)
313 GError *error = NULL;
317 g_return_val_if_fail (ui_merge, 0);
318 g_return_val_if_fail (action_group, 0);
319 g_return_val_if_fail (filename, 0);
321 ENTER(
"ui_merge %p, action_group %p, filename %s",
322 ui_merge, action_group, filename);
323 gtk_ui_manager_insert_action_group (ui_merge, action_group, 0);
326 if (pathname == NULL)
332 merge_id = gtk_ui_manager_add_ui_from_file (ui_merge, pathname, &error);
333 DEBUG(
"merge_id is %d", merge_id);
335 g_assert(merge_id || error);
338 gtk_ui_manager_ensure_update (ui_merge);
342 g_critical(
"Failed to load ui file.\n Filename %s\n Error %s",
343 filename, error->message);
354 gnc_plugin_base_init (gpointer klass)
356 static gboolean initialized = FALSE;
362 signals[MERGE_ACTIONS] = g_signal_new (
"merge-actions",
363 G_OBJECT_CLASS_TYPE (klass),
367 g_cclosure_marshal_VOID__POINTER,
370 GTK_TYPE_MENU_MERGE);
371 signals[UNMERGE_ACTIONS] = g_signal_new (
"unmerge-actions",
372 G_OBJECT_CLASS_TYPE (klass),
376 g_cclosure_marshal_VOID__POINTER,
379 GTK_TYPE_MENU_MERGE);
guint n_actions
The number of actions in the actions array.
void gnc_gobject_tracking_remember(GObject *object, GObjectClass *klass)
Tell gnucash to remember this object in the database.
void gnc_main_window_merge_actions(GncMainWindow *window, const gchar *group_name, GtkActionEntry *actions, guint n_actions, GtkToggleActionEntry *toggle_actions, guint n_toggle_actions, const gchar *filename, gpointer user_data)
Add a set of actions to the specified window.
void gnc_gobject_tracking_forget(GObject *object)
Tell gnucash to remember this object in the database.
#define DEBUG(format, args...)
Print a debugging message.
gchar * gnc_filepath_locate_ui_file(const gchar *name)
Given a ui file name, find the file in the ui directory associated with this application.
The class data structure for a menu-only plugin.
void gnc_main_window_unmerge_actions(GncMainWindow *window, const gchar *group_name)
Remove a set of actions from the specified window.
#define ENTER(format, args...)
Print a function entry debugging message.
guint n_toggle_actions
The number of toggle actions in the toggle actions array.
const gchar * ui_filename
The relative name of the XML file describing the menu/toolbar action items.
GtkActionEntry * actions
An array of actions that should automatically be added to any GnuCash "main" content window that is o...
const gchar ** important_actions
A NULL terminated list of actions that should be considered important.
Gnome specific utility functions.
GtkToggleActionEntry * toggle_actions
An array of toggle actions that should automatically be added to any GnuCash "main" content window th...
All type declarations for the whole Gnucash engine.
const gchar * actions_name
A name for the set of actions that will be added by this plugin.
GtkActionGroup * gnc_main_window_get_action_group(GncMainWindow *window, const gchar *group_name)
Retrieve a specific set of user interface actions from a window.
The instance data structure for a menu-only plugin.
Functions for adding plugins to a GnuCash window.
#define LEAVE(format, args...)
Print a function exit debugging message.
The instance data structure for a main window object.
File path resolution utility functions.
The instance private data for a menu-only plugin.