[Gnucash-changes] Add support for marking actions as "important".

David Hampton hampton at cvs.gnucash.org
Wed Jul 20 14:47:27 EDT 2005


Log Message:
-----------
Add support for marking actions as "important".  This is a setting
used by the toolbar when it is set to GTK_TOOLBAR_BOTH_HORIZ.

Tags:
----
gnucash-gnome2-dev

Modified Files:
--------------
    gnucash/src/gnome-utils:
        gnc-plugin.c
        gnc-plugin.h

Revision Data
-------------
Index: gnc-plugin.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Attic/gnc-plugin.h,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -Lsrc/gnome-utils/gnc-plugin.h -Lsrc/gnome-utils/gnc-plugin.h -u -r1.1.2.1 -r1.1.2.2
--- src/gnome-utils/gnc-plugin.h
+++ src/gnome-utils/gnc-plugin.h
@@ -63,6 +63,7 @@
 	const gchar *actions_name;
 	GtkActionEntry *actions;
 	guint n_actions; 
+	const gchar **important_actions;
 	const gchar *ui_filename;
 
 	const gchar* gconf_section;
@@ -149,6 +150,21 @@
 				  action_short_labels *short_labels);
 
 
+/** Mark certain actions as "important".  This means that their labels
+ *  will appear when the toolbar is set to "Icons and important text"
+ *  (e.g. GTK_TOOLBAR_BOTH_HORIZ) mode.
+ *
+ *  @param action_group The group of all actions associated with a
+ *  plugin or plugin page.  All actions to me modified must be in this
+ *  group.
+ *
+ *  @param name A list of actions names to be marked important.  This
+ *  list must be NULL terminated.
+ */
+void gnc_plugin_set_important_actions (GtkActionGroup *action_group,
+				       const gchar **names);
+
+
 /** Update a property on a set of existing GtkActions.  This function
  *  can be easily used to make a list of actions visible, invisible,
  *  sensitive, or insensitive.
Index: gnc-plugin.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Attic/gnc-plugin.c,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -Lsrc/gnome-utils/gnc-plugin.c -Lsrc/gnome-utils/gnc-plugin.c -u -r1.1.2.2 -r1.1.2.3
--- src/gnome-utils/gnc-plugin.c
+++ src/gnome-utils/gnc-plugin.c
@@ -149,6 +149,7 @@
 			  GQuark type)
 {
 	GncPluginClass *class;
+	GtkActionGroup *action_group;
 
 	g_return_if_fail (GNC_IS_PLUGIN (plugin));
 	class = GNC_PLUGIN_GET_CLASS (plugin);
@@ -164,6 +165,14 @@
 	  gnc_main_window_merge_actions (window, class->actions_name,
 					 class->actions, class->n_actions,
 					 class->ui_filename, plugin);
+
+
+	  if (class->important_actions) {
+	    action_group =
+	      gnc_main_window_get_action_group(window, class->actions_name);
+	    gnc_plugin_set_important_actions(action_group,
+					     class->important_actions);
+	  }
 	}
 
 	/*
@@ -281,6 +290,27 @@
 }
 
 
+/** Mark certain actions as "important".  This means that their labels
+ *  will appear when the toolbar is set to "Icons and important text"
+ *  (e.g. GTK_TOOLBAR_BOTH_HORIZ) mode. */
+void
+gnc_plugin_set_important_actions (GtkActionGroup *action_group,
+				  const gchar **name)
+{
+  GtkAction *action;
+  gint i;
+
+  for (i = 0; name[i]; i++) {
+    action = gtk_action_group_get_action (action_group, name[i]);
+    g_object_set (G_OBJECT(action), "is_important", TRUE, FALSE);
+  }
+
+  /* If this trips, you've got too many "important" actions.  That
+   * can't *all* me that important, can they? */
+  g_assert(i <= 3);
+}
+
+
 /** Update the status of existing UI actions.  This function can
  *  modify actions making them visible, invisible, sensitive, or
  *  insensitive. */


More information about the gnucash-changes mailing list