sort the SFMenu structs by their menu_paths *and* the procedure's

2004-11-22  Michael Natterer  <mitch@gimp.org>

	* plug-ins/script-fu/script-fu-scripts.c: sort the SFMenu structs
	by their menu_paths *and* the procedure's menu_labels. Fixes menu
	item sorting after "Refresh".
This commit is contained in:
Michael Natterer
2004-11-22 21:01:28 +00:00
committed by Michael Natterer
parent 512b1120c4
commit b0bd80136f
2 changed files with 39 additions and 16 deletions

View File

@ -1,3 +1,9 @@
2004-11-22 Michael Natterer <mitch@gimp.org>
* plug-ins/script-fu/script-fu-scripts.c: sort the SFMenu structs
by their menu_paths *and* the procedure's menu_labels. Fixes menu
item sorting after "Refresh".
2004-11-22 Michael Natterer <mitch@gimp.org> 2004-11-22 Michael Natterer <mitch@gimp.org>
* app/tools/gimptextoptions.[ch] (gimp_text_options_editor_new): * app/tools/gimptextoptions.[ch] (gimp_text_options_editor_new):

View File

@ -47,8 +47,8 @@
typedef struct typedef struct
{ {
gchar *pdb_name; SFScript *script;
gchar *menu_path; gchar *menu_path;
} SFMenu; } SFMenu;
@ -566,26 +566,36 @@ script_fu_add_script (LISP a)
LISP LISP
script_fu_add_menu (LISP a) script_fu_add_menu (LISP a)
{ {
SFMenu *menu; SFScript *script;
gchar *val; SFMenu *menu;
gchar *s; gchar *val;
gchar *s;
/* Check the length of a */ /* Check the length of a */
if (nlength (a) != 2) if (nlength (a) != 2)
return my_err ("Incorrect number of arguments for script-fu-menu-register", return my_err ("Incorrect number of arguments for script-fu-menu-register",
NIL); NIL);
/* Create a new list of menus */
menu = g_new0 (SFMenu, 1);
/* Find the script PDB entry name */ /* Find the script PDB entry name */
val = get_c_string (car (a)); val = g_strdup (get_c_string (car (a)));
menu->pdb_name = g_strdup (val); for (s = val; *s; s++)
for (s = menu->pdb_name; *s; s++)
if (*s == '-') if (*s == '-')
*s = '_'; *s = '_';
a = cdr (a); a = cdr (a);
script = script_fu_find_script (val);
g_free (val);
if (! script)
return my_err ("Nonexisting procedure name in script-fu-menu-register",
NIL);
/* Create a new list of menus */
menu = g_new0 (SFMenu, 1);
menu->script = script;
/* Find the script menu path */ /* Find the script menu path */
val = get_c_string (car (a)); val = get_c_string (car (a));
menu->menu_path = g_strdup (val); menu->menu_path = g_strdup (val);
@ -678,9 +688,8 @@ static void
script_fu_install_menu (SFMenu *menu, script_fu_install_menu (SFMenu *menu,
gpointer foo) gpointer foo)
{ {
gimp_plugin_menu_register (menu->pdb_name, menu->menu_path); gimp_plugin_menu_register (menu->script->pdb_name, menu->menu_path);
g_free (menu->pdb_name);
g_free (menu->menu_path); g_free (menu->menu_path);
g_free (menu); g_free (menu);
} }
@ -1003,10 +1012,18 @@ script_fu_menu_compare (gconstpointer a,
{ {
const SFMenu *menu_a = a; const SFMenu *menu_a = a;
const SFMenu *menu_b = b; const SFMenu *menu_b = b;
gint retval = 0;
if (menu_a->menu_path && menu_b->menu_path) if (menu_a->menu_path && menu_b->menu_path)
return g_utf8_collate (gettext (menu_a->menu_path), {
gettext (menu_b->menu_path)); retval = g_utf8_collate (gettext (menu_a->menu_path),
gettext (menu_b->menu_path));
return 0; if (retval == 0 &&
menu_a->script->menu_path && menu_b->script->menu_path)
retval = g_utf8_collate (gettext (menu_a->script->menu_path),
gettext (menu_b->script->menu_path));
}
return retval;
} }