Commit b8344d51 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

The following fixes have no visible effect because nobody uses

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

	The following fixes have no visible effect because nobody
	uses gimp_plugin_menu_register() on temp_procs yet:

	* app/actions/plug-in-actions.[ch]: added
	plug_in_actions_add_path() which just adds the actions needed for
	a given menu math, but not the procedure action itself.

	* app/gui/gui-vtable.c (gui_menus_create_entry): create the
	menu_path's actions using above function so adding of submenus to
	existing ui managers works.

	* tools/pdbgen/pdb/plug_in.pdb (plugin_menu_register_invoker):
	don't add a menu if "no_interface" is TRUE.

	* app/pdb/plug_in_cmds.c: regenerated.

	* plug-ins/script-fu/script-fu-scripts.c: pass untranslated
	menu_paths to the core, not translated ones. Don't store the
	scripts directly in the "script_list" tree but use a list of
	scripts per key because there can be identical keys for different
	scripts now. Fixed sorting of menu entries and menus.
parent 3e526201
2004-11-18 Michael Natterer <mitch@gimp.org>
The following fixes have no visible effect because nobody
uses gimp_plugin_menu_register() on temp_procs yet:
* app/actions/plug-in-actions.[ch]: added
plug_in_actions_add_path() which just adds the actions needed for
a given menu math, but not the procedure action itself.
* app/gui/gui-vtable.c (gui_menus_create_entry): create the
menu_path's actions using above function so adding of submenus to
existing ui managers works.
* tools/pdbgen/pdb/plug_in.pdb (plugin_menu_register_invoker):
don't add a menu if "no_interface" is TRUE.
* app/pdb/plug_in_cmds.c: regenerated.
* plug-ins/script-fu/script-fu-scripts.c: pass untranslated
menu_paths to the core, not translated ones. Don't store the
scripts directly in the "script_list" tree but use a list of
scripts per key because there can be identical keys for different
scripts now. Fixed sorting of menu entries and menus.
2004-11-18 Simon Budig <simon@gimp.org>
 
* modules/controller_midi.c: implemented support for ALSA-midi,
......
......@@ -274,6 +274,29 @@ plug_in_actions_add_proc (GimpActionGroup *group,
}
}
void
plug_in_actions_add_path (GimpActionGroup *group,
PlugInProcDef *proc_def,
const gchar *menu_path)
{
const gchar *progname;
const gchar *locale_domain;
gchar *path_translated = NULL;
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
g_return_if_fail (proc_def != NULL);
g_return_if_fail (menu_path != NULL);
progname = plug_in_proc_def_get_progname (proc_def);
locale_domain = plug_ins_locale_domain (group->gimp, progname, NULL);
path_translated = dgettext (locale_domain, menu_path);
if (plug_in_actions_check_translation (menu_path, path_translated))
plug_in_actions_build_path (group, menu_path, path_translated);
}
void
plug_in_actions_remove_proc (GimpActionGroup *group,
PlugInProcDef *proc_def)
......
......@@ -26,6 +26,9 @@ void plug_in_actions_update (GimpActionGroup *group,
void plug_in_actions_add_proc (GimpActionGroup *group,
PlugInProcDef *proc_def);
void plug_in_actions_add_path (GimpActionGroup *group,
PlugInProcDef *proc_def,
const gchar *menu_path);
void plug_in_actions_remove_proc (GimpActionGroup *group,
PlugInProcDef *proc_def);
......
......@@ -375,14 +375,18 @@ gui_menus_create_entry (Gimp *gimp,
{
GList *list;
if (menu_path == NULL)
for (list = gimp_action_groups_from_name ("plug-in");
list;
list = g_list_next (list))
{
for (list = gimp_action_groups_from_name ("plug-in");
list;
list = g_list_next (list))
if (menu_path == NULL)
{
plug_in_actions_add_proc (list->data, proc_def);
}
else
{
plug_in_actions_add_path (list->data, proc_def, menu_path);
}
}
for (list = gimp_ui_managers_from_name ("<Image>");
......
......@@ -523,8 +523,11 @@ plugin_menu_register_invoker (Gimp *gimp,
proc_def->menu_paths = g_list_append (proc_def->menu_paths,
g_strdup (menu_path));
if (proc_def->db_info.proc_type == GIMP_TEMPORARY)
gimp_menus_create_entry (gimp, proc_def, menu_path);
if (! gimp->no_interface &&
proc_def->db_info.proc_type == GIMP_TEMPORARY)
{
gimp_menus_create_entry (gimp, proc_def, menu_path);
}
}
}
}
......
......@@ -72,12 +72,12 @@ extern long nlength (LISP obj);
static void script_fu_load_script (const GimpDatafileData *file_data,
gpointer user_data);
static gboolean script_fu_install_script (gpointer foo,
SFScript *script,
GList *scripts,
gpointer bar);
static void script_fu_install_menu (SFMenu *menu,
gpointer foo);
static gboolean script_fu_remove_script (gpointer foo,
SFScript *script,
GList *scripts,
gpointer bar);
static void script_fu_script_proc (const gchar *name,
gint nparams,
......@@ -88,13 +88,16 @@ static void script_fu_script_proc (const gchar *name,
static SFScript * script_fu_find_script (const gchar *script_name);
static void script_fu_free_script (SFScript *script);
static gint script_fu_menu_compare (gconstpointer a,
gconstpointer b);
/*
* Local variables
*/
static GTree *script_list = NULL;
static GSList *script_menu_list = NULL;
static GTree *script_list = NULL;
static GList *script_menu_list = NULL;
/*
......@@ -115,7 +118,7 @@ script_fu_find_scripts (void)
g_tree_destroy (script_list);
}
script_list = g_tree_new ((GCompareFunc) strcoll);
script_list = g_tree_new ((GCompareFunc) g_utf8_collate);
path_str = gimp_gimprc_query ("script-fu-path");
......@@ -128,16 +131,20 @@ script_fu_find_scripts (void)
g_free (path_str);
/* now that all scripts are read in and sorted, tell gimp about them */
/* Now that all scripts are read in and sorted, tell gimp about them */
g_tree_foreach (script_list,
(GTraverseFunc) script_fu_install_script,
NULL);
g_slist_foreach (script_menu_list,
(GFunc) script_fu_install_menu,
NULL);
script_menu_list = g_list_sort (script_menu_list,
(GCompareFunc) script_fu_menu_compare);
g_list_foreach (script_menu_list,
(GFunc) script_fu_install_menu,
NULL);
/* Now we are done with the list of menu entries */
g_slist_free (script_menu_list);
g_list_free (script_menu_list);
script_menu_list = NULL;
}
......@@ -554,7 +561,13 @@ script_fu_add_script (LISP a)
}
script->args = args;
g_tree_insert (script_list, gettext (script->menu_path), script);
{
gchar *key = gettext (script->menu_path);
GList *list = g_tree_lookup (script_list, key);
g_tree_insert (script_list, key, g_list_append (list, script));
}
return NIL;
}
......@@ -584,9 +597,9 @@ script_fu_add_menu (LISP a)
/* Find the script menu path */
val = get_c_string (car (a));
menu->menu_path = g_strdup (gettext (val));
menu->menu_path = g_strdup (val);
script_menu_list = g_slist_append (script_menu_list, menu);
script_menu_list = g_list_prepend (script_menu_list, menu);
return NIL;
}
......@@ -633,30 +646,36 @@ script_fu_load_script (const GimpDatafileData *file_data,
*/
static gboolean
script_fu_install_script (gpointer foo,
SFScript *script,
GList *scripts,
gpointer bar)
{
gchar *menu_path = NULL;
/* Allow scripts with no menus */
if (strncmp (script->menu_path, "<None>", 6) != 0)
menu_path = script->menu_path;
gimp_install_temp_proc (script->pdb_name,
script->help,
"",
script->author,
script->copyright,
script->date,
menu_path,
script->img_types,
GIMP_TEMPORARY,
script->num_args + 1, 0,
script->args, NULL,
script_fu_script_proc);
g_free (script->args);
script->args = NULL;
GList *list;
for (list = scripts; list; list = g_list_next (list))
{
SFScript *script = list->data;
gchar *menu_path = NULL;
/* Allow scripts with no menus */
if (strncmp (script->menu_path, "<None>", 6) != 0)
menu_path = script->menu_path;
gimp_install_temp_proc (script->pdb_name,
script->help,
"",
script->author,
script->copyright,
script->date,
menu_path,
script->img_types,
GIMP_TEMPORARY,
script->num_args + 1, 0,
script->args, NULL,
script_fu_script_proc);
g_free (script->args);
script->args = NULL;
}
return FALSE;
}
......@@ -680,10 +699,19 @@ script_fu_install_menu (SFMenu *menu,
*/
static gboolean
script_fu_remove_script (gpointer foo,
SFScript *script,
GList *scripts,
gpointer bar)
{
script_fu_free_script (script);
GList *list;
for (list = scripts; list; list = g_list_next (list))
{
SFScript *script = list->data;
script_fu_free_script (script);
}
g_list_free (list);
return FALSE;
}
......@@ -852,14 +880,21 @@ script_fu_script_proc (const gchar *name,
/* this is a GTraverseFunction */
static gboolean
script_fu_lookup_script (gpointer *foo,
SFScript *script,
GList *scripts,
gconstpointer *name)
{
if (strcmp (script->pdb_name, *name) == 0)
GList *list;
for (list = scripts; list; list = g_list_next (list))
{
/* store the script in the name pointer and stop the traversal */
*name = script;
return TRUE;
SFScript *script = list->data;
if (strcmp (script->pdb_name, *name) == 0)
{
/* store the script in the name pointer and stop the traversal */
*name = script;
return TRUE;
}
}
return FALSE;
......@@ -970,3 +1005,10 @@ script_fu_free_script (SFScript *script)
g_free (script);
}
}
static gint
script_fu_menu_compare (gconstpointer a,
gconstpointer b)
{
return g_utf8_collate (a, b);
}
......@@ -351,8 +351,11 @@ HELP
proc_def->menu_paths = g_list_append (proc_def->menu_paths,
g_strdup (menu_path));
if (proc_def->db_info.proc_type == GIMP_TEMPORARY)
gimp_menus_create_entry (gimp, proc_def, menu_path);
if (! gimp->no_interface &&
proc_def->db_info.proc_type == GIMP_TEMPORARY)
{
gimp_menus_create_entry (gimp, proc_def, menu_path);
}
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment