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

Enabled multiple menu entries per plug-in procedure:

2004-05-06  Michael Natterer  <mitch@gimp.org>

	Enabled multiple menu entries per plug-in procedure:

	* app/plug-in/plug-in-proc.[ch]: changed "gchar *menu_path" to
	"GList *menu_paths".

	* app/plug-in/plug-in-message.c
	* app/plug-in/plug-in-rc.c
	* app/plug-in/plug-in.c
	* app/plug-in/plug-ins.c
	* app/menus/menus.c
	* app/widgets/gimpfiledialog.c
	* app/xcf/xcf.c: changed accordingly.

	* app/actions/file-dialog-actions.c
	* app/actions/plug-in-actions.c: create an action for the first
	element of proc_def->menu_paths.

	* app/gui/gui-vtable.c
	* app/menus/plug-in-menus.[ch]: create proxy widgets for each
	element of proc_def->menu_paths.

	* tools/pdbgen/pdb/plug_in.pdb: added new function
	gimp_plugin_menu_add() which can be called during query() and adds
	a menu path to a procedure registered by the calling plugin.

	* app/pdb/internal_procs.c
	* app/pdb/plug_in_cmds.c
	* libgimp/gimpplugin_pdb.[ch]: regenerated.

	* menus/image-menu.xml.in
	* menus/toolbox-menu.xml.in: added lots of <placeholder>s for
	logical groups (like Image/Resize, Image/Scale, Image/Crop
	etc.). Added empty placeholder File/Send for stuff like print and
	mail. Added an "Acquire" menu under <Image>/File

	* plug-ins/common/mail.c
	* plug-ins/print/print.c
	* plug-ins/common/winprint.c: register under File/Send.

	* plug-ins/common/screenshot.c
	* plug-ins/winsnap/winsnap.c: also register under
	<Image>/File/Acquire.

	* plug-ins/common/autocrop.c
	* plug-ins/common/ccanalyze.c
	* plug-ins/common/colortoalpha.c
	* plug-ins/common/threshold_alpha.c
	* plug-ins/common/zealouscrop.c: register additional menu entries
	under placeholders in the "Image" and "Layer" menus. This is not
	meant to be final but just a hint to keep in mind when
	reorganizing the plug-in menus.
parent 0582f559
2004-05-06 Michael Natterer <mitch@gimp.org>
Enabled multiple menu entries per plug-in procedure:
* app/plug-in/plug-in-proc.[ch]: changed "gchar *menu_path" to
"GList *menu_paths".
* app/plug-in/plug-in-message.c
* app/plug-in/plug-in-rc.c
* app/plug-in/plug-in.c
* app/plug-in/plug-ins.c
* app/menus/menus.c
* app/widgets/gimpfiledialog.c
* app/xcf/xcf.c: changed accordingly.
* app/actions/file-dialog-actions.c
* app/actions/plug-in-actions.c: create an action for the first
element of proc_def->menu_paths.
* app/gui/gui-vtable.c
* app/menus/plug-in-menus.[ch]: create proxy widgets for each
element of proc_def->menu_paths.
* tools/pdbgen/pdb/plug_in.pdb: added new function
gimp_plugin_menu_add() which can be called during query() and adds
a menu path to a procedure registered by the calling plugin.
* app/pdb/internal_procs.c
* app/pdb/plug_in_cmds.c
* libgimp/gimpplugin_pdb.[ch]: regenerated.
* menus/image-menu.xml.in
* menus/toolbox-menu.xml.in: added lots of <placeholder>s for
logical groups (like Image/Resize, Image/Scale, Image/Crop
etc.). Added empty placeholder File/Send for stuff like print and
mail. Added an "Acquire" menu under <Image>/File
* plug-ins/common/mail.c
* plug-ins/print/print.c
* plug-ins/common/winprint.c: register under File/Send.
* plug-ins/common/screenshot.c
* plug-ins/winsnap/winsnap.c: also register under
<Image>/File/Acquire.
* plug-ins/common/autocrop.c
* plug-ins/common/ccanalyze.c
* plug-ins/common/colortoalpha.c
* plug-ins/common/threshold_alpha.c
* plug-ins/common/zealouscrop.c: register additional menu entries
under placeholders in the "Image" and "Layer" menus. This is not
meant to be final but just a hint to keep in mind when
reorganizing the plug-in menus.
2004-05-06 Sven Neumann <sven@gimp.org>
* app/gui/resize-dialog.[ch]: cleaned up variable names and
......
......@@ -53,7 +53,7 @@ file_dialog_actions_setup (GimpActionGroup *group,
GimpPlugInActionEntry entry;
gboolean is_xcf;
if (! file_proc->menu_path)
if (! file_proc->menu_paths)
continue;
is_xcf = (strcmp (file_proc->db_info.name, xcf_proc_name) == 0);
......@@ -79,7 +79,7 @@ file_dialog_actions_setup (GimpActionGroup *group,
entry.name = file_proc->db_info.name;
entry.stock_id = stock_id;
entry.label = strstr (file_proc->menu_path, "/") + 1;
entry.label = strstr (file_proc->menu_paths->data, "/") + 1;
entry.accelerator = file_proc->accelerator;
entry.tooltip = NULL;
entry.proc_def = file_proc;
......
......@@ -117,7 +117,7 @@ plug_in_actions_setup (GimpActionGroup *group)
PlugInProcDef *proc_def = list->data;
if (proc_def->prog &&
proc_def->menu_path &&
proc_def->menu_paths &&
! proc_def->extensions &&
! proc_def->prefixes &&
! proc_def->magics)
......@@ -150,7 +150,7 @@ plug_in_actions_update (GimpActionGroup *group,
{
PlugInProcDef *proc_def = list->data;
if (proc_def->menu_path &&
if (proc_def->menu_paths &&
proc_def->image_types_val &&
! proc_def->extensions &&
! proc_def->prefixes &&
......@@ -202,7 +202,7 @@ plug_in_actions_update (GimpActionGroup *group,
path = dgettext (plug_ins_locale_domain (group->gimp,
progname, NULL),
proc_def->menu_path);
proc_def->menu_paths->data);
stripped = gimp_strip_uline (path);
basename = g_path_get_basename (stripped);
......@@ -269,7 +269,7 @@ plug_in_actions_add_proc (GimpActionGroup *group,
help_id = plug_in_proc_def_get_help_id (proc_def, help_domain);
path_original = g_strdup (proc_def->menu_path);
path_original = g_strdup (proc_def->menu_paths->data);
path_translated = g_strdup (dgettext (locale_domain, path_original));
p1 = strrchr (path_original, '/');
......
......@@ -239,14 +239,22 @@ gui_menus_create_entry (Gimp *gimp,
list;
list = g_list_next (list))
{
if (! strncmp (proc_def->menu_path, "<Toolbox>", 9))
{
plug_in_menus_add_proc (list->data, "/toolbox-menubar", proc_def);
}
else if (! strncmp (proc_def->menu_path, "<Image>", 7))
GList *path;
for (path = proc_def->menu_paths; path; path = g_list_next (path))
{
plug_in_menus_add_proc (list->data, "/image-menubar", proc_def);
plug_in_menus_add_proc (list->data, "/image-popup", proc_def);
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, "/image-popup", proc_def,
path->data);
}
}
}
}
......
......@@ -335,8 +335,7 @@ menus_open_recent_add (GimpUIManager *manager,
gchar *action_path;
action_name = g_strdup_printf ("file-open-recent-%02d", i + 1);
action_path = g_strdup_printf ("%s/File/Open Recent/file-open-recent-placeholder",
ui_path);
action_path = g_strdup_printf ("%s/File/Open Recent/Files", ui_path);
gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id,
action_path, action_name, action_name,
......
......@@ -41,7 +41,7 @@
/* local function prototypes */
static gboolean plug_in_menus_tree_traverse (gpointer foo,
static gboolean plug_in_menus_tree_traverse (const gchar *menu_path,
PlugInProcDef *proc_def,
GimpUIManager *manager);
static void plug_in_menus_build_path (GimpUIManager *manager,
......@@ -123,29 +123,33 @@ plug_in_menus_setup (GimpUIManager *manager,
PlugInProcDef *proc_def = list->data;
if (proc_def->prog &&
proc_def->menu_path &&
proc_def->menu_paths &&
! proc_def->extensions &&
! proc_def->prefixes &&
! proc_def->magics)
{
if ((! strncmp (proc_def->menu_path, "<Toolbox>", 9) &&
! strcmp (ui_path, "/toolbox-menubar")) ||
(! strncmp (proc_def->menu_path, "<Image>", 7) &&
(! strcmp (ui_path, "/image-menubar") ||
! strcmp (ui_path, "/image-popup"))))
{
const gchar *progname;
const gchar *locale_domain;
gchar *key;
progname = plug_in_proc_def_get_progname (proc_def);
GList *path;
locale_domain = plug_ins_locale_domain (manager->gimp,
progname, NULL);
key = gimp_strip_uline (dgettext (locale_domain,
proc_def->menu_path));
g_tree_insert (menu_entries, key, proc_def);
for (path = proc_def->menu_paths; path; path = g_list_next (path))
{
if ((! strncmp (path->data, "<Toolbox>", 9) &&
! strcmp (ui_path, "/toolbox-menubar")) ||
(! strncmp (path->data, "<Image>", 7) &&
(! strcmp (ui_path, "/image-menubar") ||
! strcmp (ui_path, "/image-popup"))))
{
const gchar *progname;
const gchar *locale_domain;
gchar *key;
progname = plug_in_proc_def_get_progname (proc_def);
locale_domain = plug_ins_locale_domain (manager->gimp,
progname, NULL);
key = gimp_strip_uline (dgettext (locale_domain, path->data));
g_tree_insert (menu_entries, key, proc_def);
}
}
}
}
......@@ -164,7 +168,8 @@ plug_in_menus_setup (GimpUIManager *manager,
void
plug_in_menus_add_proc (GimpUIManager *manager,
const gchar *ui_path,
PlugInProcDef *proc_def)
PlugInProcDef *proc_def,
const gchar *menu_path)
{
gchar *path;
gchar *p;
......@@ -173,7 +178,7 @@ plug_in_menus_add_proc (GimpUIManager *manager,
g_return_if_fail (ui_path != NULL);
g_return_if_fail (proc_def != NULL);
path = g_strdup (proc_def->menu_path);
path = g_strdup (menu_path);
p = strrchr (path, '/');
......@@ -185,7 +190,19 @@ plug_in_menus_add_proc (GimpUIManager *manager,
*p = '\0';
merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager));
merge_key = g_strdup_printf ("%s-merge-id", proc_def->db_info.name);
merge_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (manager),
merge_key));
if (! merge_id)
{
merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager));
g_object_set_data (G_OBJECT (manager), merge_key,
GUINT_TO_POINTER (merge_id));
}
g_free (merge_key);
plug_in_menus_build_path (manager, ui_path, merge_id, path);
......@@ -204,11 +221,6 @@ plug_in_menus_add_proc (GimpUIManager *manager,
FALSE);
g_free (action_path);
merge_key = g_strdup_printf ("%s-merge-id", proc_def->db_info.name);
g_object_set_data (G_OBJECT (manager), merge_key,
GUINT_TO_POINTER (merge_id));
g_free (merge_key);
}
g_free (path);
......@@ -237,13 +249,13 @@ plug_in_menus_remove_proc (GimpUIManager *manager,
/* private functions */
static gboolean
plug_in_menus_tree_traverse (gpointer foo,
plug_in_menus_tree_traverse (const gchar *menu_path,
PlugInProcDef *proc_def,
GimpUIManager *manager)
{
const gchar *ui_path = g_object_get_data (G_OBJECT (manager), "ui-path");
plug_in_menus_add_proc (manager, ui_path, proc_def);
plug_in_menus_add_proc (manager, ui_path, proc_def, menu_path);
return FALSE;
}
......
......@@ -28,7 +28,8 @@ void plug_in_menus_setup (GimpUIManager *manager,
const gchar *ui_path);
void plug_in_menus_add_proc (GimpUIManager *manager,
const gchar *ui_path,
PlugInProcDef *proc_def);
PlugInProcDef *proc_def,
const gchar *menu_path);
void plug_in_menus_remove_proc (GimpUIManager *manager,
PlugInProcDef *proc_def);
......
......@@ -73,7 +73,10 @@ plug_in_proc_def_free (PlugInProcDef *proc_def)
g_free (proc_def->db_info.values);
g_free (proc_def->prog);
g_free (proc_def->menu_path);
g_list_foreach (proc_def->menu_paths, (GFunc) g_free, NULL);
g_list_free (proc_def->menu_paths);
g_free (proc_def->accelerator);
g_free (proc_def->extensions);
g_free (proc_def->prefixes);
......@@ -149,7 +152,7 @@ plug_in_proc_def_compare_menu_path (gconstpointer a,
const PlugInProcDef *proc_def_a = a;
const PlugInProcDef *proc_def_b = b;
if (proc_def_a->menu_path && proc_def_b->menu_path)
if (proc_def_a->menu_paths && proc_def_b->menu_paths)
{
const gchar *progname_a;
const gchar *progname_b;
......@@ -166,9 +169,9 @@ plug_in_proc_def_compare_menu_path (gconstpointer a,
domain_b = plug_ins_locale_domain (gimp, progname_b, NULL);
menu_path_a = gimp_strip_uline (dgettext (domain_a,
proc_def_a->menu_path));
proc_def_a->menu_paths->data));
menu_path_b = gimp_strip_uline (dgettext (domain_b,
proc_def_b->menu_path));
proc_def_b->menu_paths->data));
retval = g_utf8_collate (menu_path_a, menu_path_b);
......@@ -177,9 +180,9 @@ plug_in_proc_def_compare_menu_path (gconstpointer a,
return retval;
}
else if (proc_def_a->menu_path)
else if (proc_def_a->menu_paths)
return 1;
else if (proc_def_b->menu_path)
else if (proc_def_b->menu_paths)
return -1;
return 0;
......
......@@ -27,7 +27,7 @@
struct _PlugInProcDef
{
gchar *prog;
gchar *menu_path;
GList *menu_paths;
gchar *accelerator;
gchar *extensions;
gchar *prefixes;
......
......@@ -68,7 +68,7 @@ void register_transform_tools_procs (Gimp *gimp);
void register_undo_procs (Gimp *gimp);
void register_unit_procs (Gimp *gimp);
/* 347 procedures registered total */
/* 348 procedures registered total */
void
internal_procs_init (Gimp *gimp,
......@@ -89,7 +89,7 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Color"), 0.066);
register_color_procs (gimp);
(* status_callback) (NULL, _("Convert"), 0.104);
(* status_callback) (NULL, _("Convert"), 0.103);
register_convert_procs (gimp);
(* status_callback) (NULL, _("Display procedures"), 0.112);
......@@ -104,79 +104,79 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("File Operations"), 0.239);
register_fileops_procs (gimp);
(* status_callback) (NULL, _("Floating selections"), 0.262);
(* status_callback) (NULL, _("Floating selections"), 0.261);
register_floating_sel_procs (gimp);
(* status_callback) (NULL, _("Font UI"), 0.28);
(* status_callback) (NULL, _("Font UI"), 0.279);
register_font_select_procs (gimp);
(* status_callback) (NULL, _("Fonts"), 0.288);
(* status_callback) (NULL, _("Fonts"), 0.287);
register_fonts_procs (gimp);
(* status_callback) (NULL, _("Gimprc procedures"), 0.294);
(* status_callback) (NULL, _("Gimprc procedures"), 0.293);
register_gimprc_procs (gimp);
(* status_callback) (NULL, _("Gradient UI"), 0.311);
(* status_callback) (NULL, _("Gradient UI"), 0.31);
register_gradient_select_procs (gimp);
(* status_callback) (NULL, _("Gradients"), 0.32);
(* status_callback) (NULL, _("Gradients"), 0.319);
register_gradients_procs (gimp);
(* status_callback) (NULL, _("Guide procedures"), 0.34);
(* status_callback) (NULL, _("Guide procedures"), 0.339);
register_guides_procs (gimp);
(* status_callback) (NULL, _("Help procedures"), 0.357);
(* status_callback) (NULL, _("Help procedures"), 0.356);
register_help_procs (gimp);
(* status_callback) (NULL, _("Image"), 0.36);
(* status_callback) (NULL, _("Image"), 0.359);
register_image_procs (gimp);
(* status_callback) (NULL, _("Layer"), 0.536);
(* status_callback) (NULL, _("Layer"), 0.534);
register_layer_procs (gimp);
(* status_callback) (NULL, _("Message procedures"), 0.611);
(* status_callback) (NULL, _("Message procedures"), 0.609);
register_message_procs (gimp);
(* status_callback) (NULL, _("Miscellaneous"), 0.62);
(* status_callback) (NULL, _("Miscellaneous"), 0.618);
register_misc_procs (gimp);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.625);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.624);
register_paint_tools_procs (gimp);
(* status_callback) (NULL, _("Palette"), 0.669);
(* status_callback) (NULL, _("Palette"), 0.667);
register_palette_procs (gimp);
(* status_callback) (NULL, _("Palette UI"), 0.686);
(* status_callback) (NULL, _("Palette UI"), 0.684);
register_palette_select_procs (gimp);
(* status_callback) (NULL, _("Palettes"), 0.695);
(* status_callback) (NULL, _("Palettes"), 0.693);
register_palettes_procs (gimp);
(* status_callback) (NULL, _("Parasite procedures"), 0.709);
(* status_callback) (NULL, _("Parasite procedures"), 0.707);
register_parasite_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.744);
(* status_callback) (NULL, _("Paths"), 0.741);
register_paths_procs (gimp);
(* status_callback) (NULL, _("Pattern UI"), 0.787);
(* status_callback) (NULL, _("Pattern UI"), 0.784);
register_pattern_select_procs (gimp);
(* status_callback) (NULL, _("Patterns"), 0.795);
(* status_callback) (NULL, _("Patterns"), 0.793);
register_patterns_procs (gimp);
(* status_callback) (NULL, _("Plug-in"), 0.81);
(* status_callback) (NULL, _("Plug-in"), 0.807);
register_plug_in_procs (gimp);
(* status_callback) (NULL, _("Procedural database"), 0.824);
(* status_callback) (NULL, _("Procedural database"), 0.825);
register_procedural_db_procs (gimp);
(* status_callback) (NULL, _("Image mask"), 0.85);
(* status_callback) (NULL, _("Image mask"), 0.851);
register_selection_procs (gimp);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.902);
register_selection_tools_procs (gimp);
(* status_callback) (NULL, _("Text procedures"), 0.916);
(* status_callback) (NULL, _("Text procedures"), 0.917);
register_text_tool_procs (gimp);
(* status_callback) (NULL, _("Transform Tool procedures"), 0.928);
......@@ -185,7 +185,7 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Undo"), 0.945);
register_undo_procs (gimp);
(* status_callback) (NULL, _("Units"), 0.965);
(* status_callback) (NULL, _("Units"), 0.966);
register_unit_procs (gimp);
}
......@@ -51,6 +51,7 @@ static ProcRecord progress_update_proc;
static ProcRecord plugins_query_proc;
static ProcRecord plugin_domain_register_proc;
static ProcRecord plugin_help_register_proc;
static ProcRecord plugin_menu_add_proc;
void
register_plug_in_procs (Gimp *gimp)
......@@ -60,6 +61,7 @@ register_plug_in_procs (Gimp *gimp)
procedural_db_register (gimp, &plugins_query_proc);
procedural_db_register (gimp, &plugin_domain_register_proc);
procedural_db_register (gimp, &plugin_help_register_proc);
procedural_db_register (gimp, &plugin_menu_add_proc);
}
static int
......@@ -208,14 +210,14 @@ plugins_query_invoker (Gimp *gimp,
{
proc_def = (PlugInProcDef *) list->data;
if (proc_def->prog && proc_def->menu_path)
if (proc_def->prog && proc_def->menu_paths)
{
gchar *name = strrchr (proc_def->menu_path, '/');
gchar *name = strrchr (proc_def->menu_paths->data, '/');
if (name)
name = name + 1;
else
name = proc_def->menu_path;
name = proc_def->menu_paths->data;
if (search_str && match_strings (&sregex, name))
continue;
......@@ -238,21 +240,21 @@ plugins_query_invoker (Gimp *gimp,
proc_def = (PlugInProcDef *) list->data;
if (proc_def->prog && proc_def->menu_path)
if (proc_def->prog && proc_def->menu_paths)
{
ProcRecord *pr = &proc_def->db_info;
gchar *name = strrchr (proc_def->menu_path, '/');
gchar *name = strrchr (proc_def->menu_paths->data, '/');
if (name)
name = name + 1;
else
name = proc_def->menu_path;
name = proc_def->menu_paths->data;
if (search_str && match_strings (&sregex,name))
continue;
menu_strs[i] = gimp_strip_uline (proc_def->menu_path);
menu_strs[i] = gimp_strip_uline (proc_def->menu_paths->data);
accel_strs[i] = g_strdup (proc_def->accelerator);
prog_strs[i] = g_strdup (proc_def->prog);
types_strs[i] = g_strdup (proc_def->image_types);
......@@ -492,3 +494,79 @@ static ProcRecord plugin_help_register_proc =
NULL,
{ { plugin_help_register_invoker } }
};
static Argument *
plugin_menu_add_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
gchar *procedure_name;
gchar *menu_path;
procedure_name = (gchar *) args[0].value.pdb_pointer;
if (procedure_name == NULL || !g_utf8_validate (procedure_name, -1, NULL))
success = FALSE;
menu_path = (gchar *) args[1].value.pdb_pointer;
if (menu_path == NULL || !g_utf8_validate (menu_path, -1, NULL))
success = FALSE;
if (success)
{
if (gimp->current_plug_in && gimp->current_plug_in->query)
{
GSList *list;
for (list = gimp->current_plug_in->plug_in_def->proc_defs;
list;
list = g_slist_next (list))
{
PlugInProcDef *proc_def = list->data;
if (! strcmp (procedure_name, proc_def->db_info.name))
{
proc_def->menu_paths = g_list_append (proc_def->menu_paths,
g_strdup (menu_path));
break;
}
}
if (! list)
success = FALSE;
}
}
return procedural_db_return_args (&plugin_menu_add_proc, success);
}
static ProcArg plugin_menu_add_inargs[] =
{
{
GIMP_PDB_STRING,
"procedure_name",
"The procedure for which to install the menu path"
},
{
GIMP_PDB_STRING,
"menu_path",
"The procedure's additional menu path"
}
};
static ProcRecord plugin_menu_add_proc =
{
"gimp_plugin_menu_add",
"Register an additional menu path for a plug-in procedure.",
"This procedure installs an additional menu entry for the given procedure.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer <mitch@gimp.org>",
"2004",
GIMP_INTERNAL,
2,
plugin_menu_add_inargs,
0,
NULL,
{ { plugin_menu_add_invoker } }