r17024 - gnucash/trunk/src/gnome-utils - In reports menu, first list submenus, then menu items, both sorted lexicographically.

Andreas Köhler andi5 at cvs.gnucash.org
Sun Mar 9 18:43:41 EDT 2008


Author: andi5
Date: 2008-03-09 18:43:40 -0400 (Sun, 09 Mar 2008)
New Revision: 17024
Trac: http://svn.gnucash.org/trac/changeset/17024

Modified:
   gnucash/trunk/src/gnome-utils/gnc-plugin-menu-additions.c
Log:
In reports menu, first list submenus, then menu items, both sorted lexicographically.

Should ease finding specific reports when reports and placeholders are
not mixed together anymore.

Previously all elements were sorted lexicographically, where the
submenus already contained accelerators.  As LANG=C and LANG=en_US.utf8
handle underscores differently, even those results were not the same.


Modified: gnucash/trunk/src/gnome-utils/gnc-plugin-menu-additions.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-plugin-menu-additions.c	2008-03-09 21:46:14 UTC (rev 17023)
+++ gnucash/trunk/src/gnome-utils/gnc-plugin-menu-additions.c	2008-03-09 22:43:40 UTC (rev 17024)
@@ -219,10 +219,10 @@
 }
 
 
-/** Compare two extension menu item and indicate which should appear
- *  first in the menu listings.  The strings being compared are
- *  collation keys produced by g_utf8_collate_key(), so this function
- *  doesn't have to be anything more than a wrapper around strcmp,
+/** Compare two extension menu items and indicate which should appear
+ *  first in the menu listings.  If only one of them is a submenu,
+ *  choose that one.  Otherwise, the sort_keys are collation keys
+ *  produced by g_utf8_collate_key(), so compare them with strcmp.
  *
  *  @param a A menu extension.
  *
@@ -231,9 +231,16 @@
  *  @return -1 if extension 'a' should appear first. 1 if extension
  *  'b' should appear first. */
 static gint
-gnc_menu_additions_alpha_sort (ExtensionInfo *a, ExtensionInfo *b)
+gnc_menu_additions_sort (ExtensionInfo *a, ExtensionInfo *b)
 {
-  return strcmp(a->sort_key, b->sort_key);
+  if (a->type == b->type)
+    return strcmp(a->sort_key, b->sort_key);
+  else if (a->type == GTK_UI_MANAGER_MENU)
+    return -1;
+  else if (b->type == GTK_UI_MANAGER_MENU)
+    return 1;
+  else
+    return 0;
 }
 
 
@@ -437,7 +444,7 @@
   gtk_ui_manager_insert_action_group(window->ui_merge, per_window.group, 0);
 
   menu_list = g_slist_sort(gnc_extensions_get_menu_list(),
-			   (GCompareFunc)gnc_menu_additions_alpha_sort);
+			   (GCompareFunc)gnc_menu_additions_sort);
 
   /* Assign accelerators */
   table = g_once(&accel_table_init, gnc_menu_additions_init_accel_table, NULL);



More information about the gnucash-changes mailing list