38 #include <glib/gi18n.h>
49 static gpointer parent_class = NULL;
52 static void gnc_plugin_init (
GncPlugin *plugin_page,
54 static void gnc_plugin_finalize (GObject *
object);
64 #define GNC_PLUGIN_GET_PRIVATE(o) \
65 (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN, GncPluginPrivate))
73 static GType gnc_plugin_type = 0;
75 if (gnc_plugin_type == 0)
77 static const GTypeInfo our_info =
82 (GClassInitFunc) gnc_plugin_class_init,
87 (GInstanceInitFunc) gnc_plugin_init,
90 gnc_plugin_type = g_type_register_static (G_TYPE_OBJECT,
95 return gnc_plugin_type;
109 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
111 parent_class = g_type_class_peek_parent (klass);
112 gobject_class->finalize = gnc_plugin_finalize;
130 G_OBJECT_CLASS(klass));
142 gnc_plugin_finalize (GObject *
object)
144 g_return_if_fail (GNC_IS_PLUGIN (
object));
147 G_OBJECT_CLASS (parent_class)->finalize (
object);
162 GtkActionGroup *action_group;
164 g_return_if_fail (GNC_IS_PLUGIN (plugin));
165 klass = GNC_PLUGIN_GET_CLASS (plugin);
174 DEBUG (
"%s: %d actions to merge with gui from %s",
194 if (GNC_PLUGIN_GET_CLASS (plugin)->add_to_window)
196 DEBUG (
"Calling child class function %p", GNC_PLUGIN_GET_CLASS (plugin)->add_to_window);
197 GNC_PLUGIN_GET_CLASS (plugin)->add_to_window (plugin, window, type);
215 g_return_if_fail (GNC_IS_PLUGIN (plugin));
216 klass = GNC_PLUGIN_GET_CLASS (plugin);
223 if (GNC_PLUGIN_GET_CLASS (plugin)->remove_from_window)
225 DEBUG (
"Calling child class function %p",
226 GNC_PLUGIN_GET_CLASS (plugin)->remove_from_window);
227 GNC_PLUGIN_GET_CLASS (plugin)->remove_from_window (plugin, window, type);
235 DEBUG (
"%s: %d actions to unmerge",
248 g_return_val_if_fail (GNC_IS_PLUGIN (plugin), NULL);
249 return (GNC_PLUGIN_GET_CLASS(plugin)->plugin_name);
267 GValue value = { 0, };
270 g_value_init (&value, G_TYPE_STRING);
275 action = gtk_action_group_get_action (action_group,
276 toolbar_labels[i].action_name);
277 g_value_set_static_string (&value, gettext(toolbar_labels[i].label));
278 g_object_set_property (G_OBJECT(action),
"short_label", &value);
295 for (i = 0; name[i]; i++)
297 action = gtk_action_group_get_action (action_group, name[i]);
298 g_object_set (G_OBJECT(action),
"is_important", TRUE, NULL);
314 const gchar **action_names,
315 const gchar *property_name,
319 GValue gvalue = { 0 };
322 g_value_init (&gvalue, G_TYPE_BOOLEAN);
323 g_value_set_boolean (&gvalue, value);
325 for (i = 0; action_names[i]; i++)
327 action = gtk_action_group_get_action (action_group, action_names[i]);
330 g_object_set_property (G_OBJECT(action), property_name, &gvalue);
334 g_warning(
"No such action with name '%s' in action group %s (size %d)",
335 action_names[i], gtk_action_group_get_name(action_group),
336 g_list_length(gtk_action_group_list_actions(action_group)));
347 GtkActionGroup *action_group,
348 const gchar *filename)
350 GError *error = NULL;
354 g_return_val_if_fail (ui_merge, 0);
355 g_return_val_if_fail (action_group, 0);
356 g_return_val_if_fail (filename, 0);
358 ENTER(
"ui_merge %p, action_group %p, filename %s",
359 ui_merge, action_group, filename);
360 gtk_ui_manager_insert_action_group (ui_merge, action_group, 0);
363 if (pathname == NULL)
369 merge_id = gtk_ui_manager_add_ui_from_file (ui_merge, pathname, &error);
370 DEBUG(
"merge_id is %d", merge_id);
372 g_assert(merge_id || error);
375 gtk_ui_manager_ensure_update (ui_merge);
379 g_critical(
"Failed to load ui file.\n Filename %s\n Error %s",
380 filename, error->message);
391 gnc_plugin_base_init (gpointer klass)
393 static gboolean initialized = FALSE;
399 signals[MERGE_ACTIONS] = g_signal_new (
"merge-actions",
400 G_OBJECT_CLASS_TYPE (klass),
404 g_cclosure_marshal_VOID__POINTER,
407 GTK_TYPE_MENU_MERGE);
408 signals[UNMERGE_ACTIONS] = g_signal_new (
"unmerge-actions",
409 G_OBJECT_CLASS_TYPE (klass),
413 g_cclosure_marshal_VOID__POINTER,
416 GTK_TYPE_MENU_MERGE);
void gnc_gobject_tracking_remember(GObject *object, GObjectClass *klass)
void gnc_gobject_tracking_forget(GObject *object)
#define DEBUG(format, args...)
gchar * gnc_filepath_locate_ui_file(const gchar *name)
void gnc_main_window_unmerge_actions(GncMainWindow *window, const gchar *group_name)
#define ENTER(format, args...)
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)
const gchar * ui_filename
const gchar ** important_actions
Gnome specific utility functions.
GtkToggleActionEntry * toggle_actions
All type declarations for the whole Gnucash engine.
const gchar * actions_name
GtkActionGroup * gnc_main_window_get_action_group(GncMainWindow *window, const gchar *group_name)
Functions for adding plugins to a GnuCash window.
#define LEAVE(format, args...)
File path resolution utility functions.
const gchar * QofLogModule