GNOME Bugzilla – Bug 137435
Keyboard shortcut indicators in menus affects sort order
Last modified: 2004-12-22 21:47:04 UTC
I'm not sure if this is actually a GIMP or GTK+ bug. I'm using the latest CVS copies of both GTK+ and GIMP. The _ character in the strings used for a menu entry affect the ordering of the items in the menu when the _ character appears at the start of the string used for the menu item. To see this, look at the order of the items in the Script-Fu/Logos menu. All of the menu items that have their first character underlined are listed after the menu entries which do not have their first character underlined.
This actually is Locale dependant, so strictly speaking it is not a bug (set LC_COLLATE to a non-C non-POSIX locale and the menu items are ordered correctly). However, I am biased, since I explicitely set LC_COLLATE to C, to avoid this very sorting for e.g. ls. Not sure what to do about it. I'd prefer to strip the underscores from the keys for the g_tree in plug_in_menus_create() to guarantee a proper sorting order for POSIX environments.
Created attachment 25707 [details] [review] possible patch to fix the sorting order
The patch fixes the problem. I simplified the patch slightly as you will see below. The patch does a strdup on menupath. Does this need to be g_free'ed after the call to g_tree_insert() or will the key be freed later when the menu is removed?
Created attachment 25714 [details] [review] Slightly simplified version of patch to fix sorting of menu items.
The key must be freed and thats the reason why my patch patched the call to g_tree_new_full() (adding the function to free the key).
Yea, Simon's patch is the correct one because it doesn't leak the key. Please apply and use gimp_strip_uline() from libgimpbase/gimputils.c
Fixed in CVS: 2004-03-17 Simon Budig <simon@gimp.org> * app/gui/plug-in-menus.c: Sort the plugin menu entries with the mnemonics stripped. Avoids weird ordering in the "C" and "POSIX" locales. Fixes bug #137435.