Made plug-in menu registration work the same way for ordinary and

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

	Made plug-in menu registration work the same way for ordinary and
	temporary procedures. Addresses bug #158117.

	* app/core/gimp-gui.[ch]: added "const gchar *menu_path" to
	gimp_menus_create_entry().

	* app/gui/gui-vtable.c (gui_menus_create_entry): if menu_path is
	NULL, behave as before and create an action and its menu entries
	for all the procedure's menu_paths. If it is non-NULL, skip action
	creation and create a menu entry just for that path.

	* app/plug-in/plug-ins.c (plug_ins_temp_proc_def_add): call
	gimp_menus_create_entry() with a NULL menu path and call it if
	proc_def->menu_paths *or* proc_def->menu_label is non-NULL, so
	it creates at least the procedure's action, even if it has
	no menu_path (yet).

	* tools/pdbgen/pdb/plug_in.pdb (plugin_menu_register): check both
	the list of procs and temp_procs when trying to register the
	entry.  Allow ordinary procedures and extensions to install stuff
	at query() and init() time and allow temp_procs to install stuff
	at any time.

	* app/pdb/plug_in_cmds.c: regenerated.
This commit is contained in:
Michael Natterer
2004-11-17 14:51:50 +00:00
committed by Michael Natterer
parent 3afed9e1fa
commit d871be74bf
8 changed files with 267 additions and 122 deletions

View File

@ -1,3 +1,30 @@
2004-11-17 Michael Natterer <mitch@gimp.org>
Made plug-in menu registration work the same way for ordinary and
temporary procedures. Addresses bug #158117.
* app/core/gimp-gui.[ch]: added "const gchar *menu_path" to
gimp_menus_create_entry().
* app/gui/gui-vtable.c (gui_menus_create_entry): if menu_path is
NULL, behave as before and create an action and its menu entries
for all the procedure's menu_paths. If it is non-NULL, skip action
creation and create a menu entry just for that path.
* app/plug-in/plug-ins.c (plug_ins_temp_proc_def_add): call
gimp_menus_create_entry() with a NULL menu path and call it if
proc_def->menu_paths *or* proc_def->menu_label is non-NULL, so
it creates at least the procedure's action, even if it has
no menu_path (yet).
* tools/pdbgen/pdb/plug_in.pdb (plugin_menu_register): check both
the list of procs and temp_procs when trying to register the
entry. Allow ordinary procedures and extensions to install stuff
at query() and init() time and allow temp_procs to install stuff
at any time.
* app/pdb/plug_in_cmds.c: regenerated.
2004-11-17 Michael Natterer <mitch@gimp.org>
* plug-ins/dbbrowser/gimpprocbox.c

View File

@ -286,13 +286,14 @@ gimp_menus_init (Gimp *gimp,
void
gimp_menus_create_entry (Gimp *gimp,
PlugInProcDef *proc_def)
PlugInProcDef *proc_def,
const gchar *menu_path)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (proc_def != NULL);
if (gimp->gui.menus_create)
gimp->gui.menus_create (gimp, proc_def);
gimp->gui.menus_create (gimp, proc_def, menu_path);
}
void

View File

@ -58,7 +58,8 @@ struct _GimpGui
GSList *plug_in_defs,
const gchar *std_domain);
void (* menus_create) (Gimp *gimp,
PlugInProcDef *proc_def);
PlugInProcDef *proc_def,
const gchar *menu_path);
void (* menus_delete) (Gimp *gimp,
PlugInProcDef *proc_def);
@ -120,7 +121,8 @@ void gimp_menus_init (Gimp *gimp,
GSList *plug_in_defs,
const gchar *std_plugins_domain);
void gimp_menus_create_entry (Gimp *gimp,
PlugInProcDef *proc_def);
PlugInProcDef *proc_def,
const gchar *menu_path);
void gimp_menus_delete_entry (Gimp *gimp,
PlugInProcDef *proc_def);

View File

@ -104,7 +104,8 @@ static void gui_menus_init (Gimp *gimp,
GSList *plug_in_defs,
const gchar *plugins_domain);
static void gui_menus_create_entry (Gimp *gimp,
PlugInProcDef *proc_def);
PlugInProcDef *proc_def,
const gchar *menu_path);
static void gui_menus_delete_entry (Gimp *gimp,
PlugInProcDef *proc_def);
static GimpProgress * gui_new_progress (Gimp *gimp,
@ -369,36 +370,58 @@ gui_menus_init (Gimp *gimp,
static void
gui_menus_create_entry (Gimp *gimp,
PlugInProcDef *proc_def)
PlugInProcDef *proc_def,
const gchar *menu_path)
{
GList *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);
for (list = gimp_action_groups_from_name ("plug-in");
list;
list = g_list_next (list))
{
plug_in_actions_add_proc (list->data, proc_def);
}
}
for (list = gimp_ui_managers_from_name ("<Image>");
list;
list = g_list_next (list))
{
GList *path;
for (path = proc_def->menu_paths; path; path = g_list_next (path))
if (menu_path == NULL)
{
if (! strncmp (path->data, "<Toolbox>", 9))
GList *path;
for (path = proc_def->menu_paths; path; path = g_list_next (path))
{
if (! strncmp (path->data, "<Toolbox>", 9))
{
plug_in_menus_add_proc (list->data, "/toolbox-menubar",
proc_def, path->data);
}
else if (! strncmp (path->data, "<Image>", 7))
{
plug_in_menus_add_proc (list->data, "/image-menubar",
proc_def, path->data);
plug_in_menus_add_proc (list->data, "/dummy-menubar/image-popup",
proc_def, path->data);
}
}
}
else
{
if (! strncmp (menu_path, "<Toolbox>", 9))
{
plug_in_menus_add_proc (list->data, "/toolbox-menubar",
proc_def, path->data);
proc_def, menu_path);
}
else if (! strncmp (path->data, "<Image>", 7))
else if (! strncmp (menu_path, "<Image>", 7))
{
plug_in_menus_add_proc (list->data, "/image-menubar",
proc_def, path->data);
proc_def, menu_path);
plug_in_menus_add_proc (list->data, "/dummy-menubar/image-popup",
proc_def, path->data);
proc_def, menu_path);
}
}
}

View File

@ -441,64 +441,110 @@ plugin_menu_register_invoker (Gimp *gimp,
if (success)
{
if (gimp->current_plug_in && gimp->current_plug_in->query)
if (gimp->current_plug_in)
{
GSList *list;
PlugInProcDef *proc_def = NULL;
GSList *list;
for (list = gimp->current_plug_in->plug_in_def->proc_defs;
list;
list = g_slist_next (list))
if (gimp->current_plug_in->plug_in_def)
{
PlugInProcDef *proc_def = list->data;
if (! strcmp (procedure_name, proc_def->db_info.name))
for (list = gimp->current_plug_in->plug_in_def->proc_defs;
list;
list = g_slist_next (list))
{
if (proc_def->menu_label)
PlugInProcDef *pd = list->data;
if (! strcmp (procedure_name, pd->db_info.name))
{
GError *error = NULL;
if (! plug_in_proc_args_check (gimp->current_plug_in->name,
gimp->current_plug_in->prog,
procedure_name,
menu_path,
proc_def->db_info.args,
proc_def->db_info.num_args,
proc_def->db_info.values,
proc_def->db_info.num_values,
&error))
{
g_message (error->message);
g_clear_error (&error);
success = FALSE;
}
else
{
proc_def->menu_paths = g_list_append (proc_def->menu_paths,
g_strdup (menu_path));
}
proc_def = pd;
break;
}
else
{
g_message ("Plug-In \"%s\"\n(%s)\n\n"
"attempted to install additional menu_path \"%s\"\n"
"for procedure \"%s\".\n"
"However the menu_path given in "
"gimp_install_procedure() already contained "
"a path. To make this work, pass just the menu's "
"label to gimp_install_procedure().",
gimp_filename_to_utf8 (gimp->current_plug_in->name),
gimp_filename_to_utf8 (gimp->current_plug_in->prog),
menu_path, procedure_name);
success = FALSE;
}
break;
}
}
if (! list)
if (! proc_def)
{
for (list = gimp->current_plug_in->temp_proc_defs;
list;
list = g_slist_next (list))
{
PlugInProcDef *pd = list->data;
if (! strcmp (procedure_name, pd->db_info.name))
{
proc_def = pd;
break;
}
}
}
if (proc_def)
{
if (proc_def->menu_label)
{
GError *error = NULL;
if (! plug_in_proc_args_check (gimp->current_plug_in->name,
gimp->current_plug_in->prog,
procedure_name,
menu_path,
proc_def->db_info.args,
proc_def->db_info.num_args,
proc_def->db_info.values,
proc_def->db_info.num_values,
&error))
{
g_message (error->message);
g_clear_error (&error);
success = FALSE;
}
else
{
switch (proc_def->db_info.proc_type)
{
case GIMP_INTERNAL:
success = FALSE;
break;
case GIMP_PLUGIN:
case GIMP_EXTENSION:
if (! gimp->current_plug_in->query &&
! gimp->current_plug_in->init)
success = FALSE;
break;
case GIMP_TEMPORARY:
break;
}
if (success)
{
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);
}
}
}
else
{
g_message ("Plug-In \"%s\"\n(%s)\n\n"
"attempted to install additional menu_path \"%s\"\n"
"for procedure \"%s\".\n"
"However the menu_path given in "
"gimp_install_procedure() already contained "
"a path. To make this work, pass just the menu's "
"label to gimp_install_procedure().",
gimp_filename_to_utf8 (gimp->current_plug_in->name),
gimp_filename_to_utf8 (gimp->current_plug_in->prog),
menu_path, procedure_name);
success = FALSE;
}
}
else
success = FALSE;
}
else

View File

@ -641,8 +641,8 @@ plug_ins_temp_proc_def_add (Gimp *gimp,
if (! gimp->no_interface)
{
if (proc_def->menu_paths)
gimp_menus_create_entry (gimp, proc_def);
if (proc_def->menu_label || proc_def->menu_paths)
gimp_menus_create_entry (gimp, proc_def, NULL);
}
/* Register the procedural database entry */
@ -661,7 +661,7 @@ plug_ins_temp_proc_def_remove (Gimp *gimp,
if (! gimp->no_interface)
{
if (proc_def->menu_paths)
if (proc_def->menu_label || proc_def->menu_paths)
gimp_menus_delete_entry (gimp, proc_def);
}

View File

@ -641,8 +641,8 @@ plug_ins_temp_proc_def_add (Gimp *gimp,
if (! gimp->no_interface)
{
if (proc_def->menu_paths)
gimp_menus_create_entry (gimp, proc_def);
if (proc_def->menu_label || proc_def->menu_paths)
gimp_menus_create_entry (gimp, proc_def, NULL);
}
/* Register the procedural database entry */
@ -661,7 +661,7 @@ plug_ins_temp_proc_def_remove (Gimp *gimp,
if (! gimp->no_interface)
{
if (proc_def->menu_paths)
if (proc_def->menu_label || proc_def->menu_paths)
gimp_menus_delete_entry (gimp, proc_def);
}

View File

@ -269,64 +269,110 @@ HELP
%invoke = (
code => <<'CODE',
{
if (gimp->current_plug_in && gimp->current_plug_in->query)
if (gimp->current_plug_in)
{
GSList *list;
PlugInProcDef *proc_def = NULL;
GSList *list;
for (list = gimp->current_plug_in->plug_in_def->proc_defs;
list;
list = g_slist_next (list))
if (gimp->current_plug_in->plug_in_def)
{
PlugInProcDef *proc_def = list->data;
if (! strcmp (procedure_name, proc_def->db_info.name))
for (list = gimp->current_plug_in->plug_in_def->proc_defs;
list;
list = g_slist_next (list))
{
if (proc_def->menu_label)
PlugInProcDef *pd = list->data;
if (! strcmp (procedure_name, pd->db_info.name))
{
GError *error = NULL;
if (! plug_in_proc_args_check (gimp->current_plug_in->name,
gimp->current_plug_in->prog,
procedure_name,
menu_path,
proc_def->db_info.args,
proc_def->db_info.num_args,
proc_def->db_info.values,
proc_def->db_info.num_values,
&error))
{
g_message (error->message);
g_clear_error (&error);
success = FALSE;
}
else
{
proc_def->menu_paths = g_list_append (proc_def->menu_paths,
g_strdup (menu_path));
}
proc_def = pd;
break;
}
else
{
g_message ("Plug-In \"%s\"\n(%s)\n\n"
"attempted to install additional menu_path \"%s\"\n"
"for procedure \"%s\".\n"
"However the menu_path given in "
"gimp_install_procedure() already contained "
"a path. To make this work, pass just the menu's "
"label to gimp_install_procedure().",
gimp_filename_to_utf8 (gimp->current_plug_in->name),
gimp_filename_to_utf8 (gimp->current_plug_in->prog),
menu_path, procedure_name);
success = FALSE;
}
break;
}
}
if (! list)
if (! proc_def)
{
for (list = gimp->current_plug_in->temp_proc_defs;
list;
list = g_slist_next (list))
{
PlugInProcDef *pd = list->data;
if (! strcmp (procedure_name, pd->db_info.name))
{
proc_def = pd;
break;
}
}
}
if (proc_def)
{
if (proc_def->menu_label)
{
GError *error = NULL;
if (! plug_in_proc_args_check (gimp->current_plug_in->name,
gimp->current_plug_in->prog,
procedure_name,
menu_path,
proc_def->db_info.args,
proc_def->db_info.num_args,
proc_def->db_info.values,
proc_def->db_info.num_values,
&error))
{
g_message (error->message);
g_clear_error (&error);
success = FALSE;
}
else
{
switch (proc_def->db_info.proc_type)
{
case GIMP_INTERNAL:
success = FALSE;
break;
case GIMP_PLUGIN:
case GIMP_EXTENSION:
if (! gimp->current_plug_in->query &&
! gimp->current_plug_in->init)
success = FALSE;
break;
case GIMP_TEMPORARY:
break;
}
if (success)
{
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);
}
}
}
else
{
g_message ("Plug-In \"%s\"\n(%s)\n\n"
"attempted to install additional menu_path \"%s\"\n"
"for procedure \"%s\".\n"
"However the menu_path given in "
"gimp_install_procedure() already contained "
"a path. To make this work, pass just the menu's "
"label to gimp_install_procedure().",
gimp_filename_to_utf8 (gimp->current_plug_in->name),
gimp_filename_to_utf8 (gimp->current_plug_in->prog),
menu_path, procedure_name);
success = FALSE;
}
}
else
success = FALSE;
}
else