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.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17024 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Andreas Köhler 2008-03-09 22:43:40 +00:00
parent b6373ae509
commit 1c6f9acd32

View File

@ -219,10 +219,10 @@ gnc_plugin_menu_additions_action_cb (GtkAction *action,
} }
/** Compare two extension menu item and indicate which should appear /** Compare two extension menu items and indicate which should appear
* first in the menu listings. The strings being compared are * first in the menu listings. If only one of them is a submenu,
* collation keys produced by g_utf8_collate_key(), so this function * choose that one. Otherwise, the sort_keys are collation keys
* doesn't have to be anything more than a wrapper around strcmp, * produced by g_utf8_collate_key(), so compare them with strcmp.
* *
* @param a A menu extension. * @param a A menu extension.
* *
@ -231,9 +231,16 @@ gnc_plugin_menu_additions_action_cb (GtkAction *action,
* @return -1 if extension 'a' should appear first. 1 if extension * @return -1 if extension 'a' should appear first. 1 if extension
* 'b' should appear first. */ * 'b' should appear first. */
static gint 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 @@ gnc_plugin_menu_additions_add_to_window (GncPlugin *plugin,
gtk_ui_manager_insert_action_group(window->ui_merge, per_window.group, 0); gtk_ui_manager_insert_action_group(window->ui_merge, per_window.group, 0);
menu_list = g_slist_sort(gnc_extensions_get_menu_list(), menu_list = g_slist_sort(gnc_extensions_get_menu_list(),
(GCompareFunc)gnc_menu_additions_alpha_sort); (GCompareFunc)gnc_menu_additions_sort);
/* Assign accelerators */ /* Assign accelerators */
table = g_once(&accel_table_init, gnc_menu_additions_init_accel_table, NULL); table = g_once(&accel_table_init, gnc_menu_additions_init_accel_table, NULL);