Commit 03feba0f authored by Michael Natterer's avatar Michael Natterer 😴

libgimpbase, app: remove the plug-in menu_path compat code

Registering a full menu path as a procedure's menu label is now
forbidden and causes the procedure to be rejected.

Bump the plug-in protocol version so a pluginrc containing such cruft
is not used.
parent 9ef39b50
......@@ -152,8 +152,8 @@ plug_in_actions_update (GimpActionGroup *group,
{
GimpPlugInProcedure *proc = list->data;
if ((proc->menu_label || proc->menu_paths) &&
! proc->file_proc &&
if (proc->menu_label &&
! proc->file_proc &&
proc->image_types_val)
{
GimpProcedure *procedure = GIMP_PROCEDURE (proc);
......@@ -224,7 +224,7 @@ plug_in_actions_register_procedure (GimpPDB *pdb,
G_CALLBACK (plug_in_actions_menu_path_added),
group, 0);
if ((plug_in_proc->menu_label || plug_in_proc->menu_paths) &&
if (plug_in_proc->menu_label &&
! plug_in_proc->file_proc)
{
#if 0
......@@ -250,7 +250,7 @@ plug_in_actions_unregister_procedure (GimpPDB *pdb,
plug_in_actions_menu_path_added,
group);
if ((plug_in_proc->menu_label || plug_in_proc->menu_paths) &&
if (plug_in_proc->menu_label &&
! plug_in_proc->file_proc)
{
GtkAction *action;
......@@ -298,45 +298,10 @@ plug_in_actions_add_proc (GimpActionGroup *group,
{
GimpProcedureActionEntry entry;
const gchar *locale_domain;
gchar *path_original = NULL;
gchar *path_translated = NULL;
GList *list;
locale_domain = gimp_plug_in_procedure_get_locale_domain (proc);
if (! proc->menu_label)
{
gchar *p1, *p2;
path_original = proc->menu_paths->data;
path_translated = dgettext (locale_domain, path_original);
path_original = g_strdup (path_original);
if (plug_in_actions_check_translation (path_original, path_translated))
path_translated = g_strdup (path_translated);
else
path_translated = g_strdup (path_original);
p1 = strrchr (path_original, '/');
p2 = strrchr (path_translated, '/');
if (p1 && p2)
{
*p1 = '\0';
*p2 = '\0';
}
else
{
g_warning ("bad menu path for procedure \"%s\": \"%s\"",
gimp_object_get_name (proc), path_original);
g_free (path_original);
g_free (path_translated);
return;
}
}
entry.name = gimp_object_get_name (proc);
entry.icon_name = gimp_viewable_get_icon_name (GIMP_VIEWABLE (proc));
entry.label = gimp_procedure_get_menu_label (GIMP_PROCEDURE (proc));
......@@ -348,32 +313,18 @@ plug_in_actions_add_proc (GimpActionGroup *group,
gimp_action_group_add_procedure_actions (group, &entry, 1,
G_CALLBACK (plug_in_run_cmd_callback));
if (proc->menu_label)
{
GList *list;
for (list = proc->menu_paths; list; list = g_list_next (list))
{
const gchar *original = list->data;
const gchar *translated = dgettext (locale_domain, original);
if (plug_in_actions_check_translation (original, translated))
plug_in_actions_build_path (group, original, translated);
else
plug_in_actions_build_path (group, original, original);
}
}
else
for (list = proc->menu_paths; list; list = g_list_next (list))
{
plug_in_actions_build_path (group, path_original, path_translated);
const gchar *original = list->data;
const gchar *translated = dgettext (locale_domain, original);
g_free (path_original);
g_free (path_translated);
if (plug_in_actions_check_translation (original, translated))
plug_in_actions_build_path (group, original, translated);
else
plug_in_actions_build_path (group, original, original);
}
if ((proc->menu_label || proc->menu_paths) &&
! proc->file_proc &&
proc->image_types_val)
if (proc->image_types_val)
{
GimpContext *context = gimp_get_user_context (group->gimp);
GimpImage *image = gimp_context_get_image (context);
......
......@@ -134,49 +134,36 @@ plug_in_menus_setup (GimpUIManager *manager,
G_CALLBACK (plug_in_menus_menu_path_added),
manager, 0);
if (plug_in_proc->menu_paths &&
if (plug_in_proc->menu_label &&
! plug_in_proc->file_proc)
{
GList *path;
GFile *file = gimp_plug_in_procedure_get_file (plug_in_proc);
const gchar *locale_domain;
GList *path;
locale_domain =
gimp_plug_in_manager_get_locale_domain (plug_in_manager,
file, NULL);
for (path = plug_in_proc->menu_paths; path; path = g_list_next (path))
{
if (g_str_has_prefix (path->data, manager->name))
{
PlugInMenuEntry *entry = g_slice_new0 (PlugInMenuEntry);
GFile *file;
const gchar *locale_domain;
gchar *menu;
entry->proc = plug_in_proc;
entry->menu_path = path->data;
file = gimp_plug_in_procedure_get_file (plug_in_proc);
locale_domain =
gimp_plug_in_manager_get_locale_domain (plug_in_manager,
file, NULL);
if (plug_in_proc->menu_label)
{
gchar *menu;
menu = g_strconcat (dgettext (locale_domain,
path->data),
"/",
dgettext (locale_domain,
plug_in_proc->menu_label),
NULL);
plug_in_menus_tree_insert (menu_entries, menu, entry);
g_free (menu);
}
else
{
plug_in_menus_tree_insert (menu_entries,
dgettext (locale_domain,
path->data),
entry);
}
menu = g_strconcat (dgettext (locale_domain,
path->data),
"/",
dgettext (locale_domain,
plug_in_proc->menu_label),
NULL);
plug_in_menus_tree_insert (menu_entries, menu, entry);
g_free (menu);
}
}
}
......@@ -216,7 +203,7 @@ plug_in_menus_register_procedure (GimpPDB *pdb,
G_CALLBACK (plug_in_menus_menu_path_added),
manager, 0);
if ((plug_in_proc->menu_label || plug_in_proc->menu_paths) &&
if (plug_in_proc->menu_label &&
! plug_in_proc->file_proc)
{
GList *list;
......@@ -244,7 +231,7 @@ plug_in_menus_unregister_procedure (GimpPDB *pdb,
plug_in_menus_menu_path_added,
manager);
if ((plug_in_proc->menu_label || plug_in_proc->menu_paths) &&
if (plug_in_proc->menu_label &&
! plug_in_proc->file_proc)
{
GList *list;
......@@ -367,7 +354,6 @@ plug_in_menus_add_proc (GimpUIManager *manager,
GimpPlugInProcedure *proc,
const gchar *menu_path)
{
gchar *path;
gchar *merge_key;
gchar *stripped_path;
gchar *action_path;
......@@ -378,24 +364,8 @@ plug_in_menus_add_proc (GimpUIManager *manager,
g_return_if_fail (ui_path != NULL);
g_return_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc));
path = g_strdup (menu_path);
if (! proc->menu_label)
{
gchar *p;
if (! path)
return;
p = strrchr (path, '/');
if (! p)
{
g_free (path);
return;
}
*p = '\0';
}
return;
merge_key = g_strdup_printf ("%s-merge-id", gimp_object_get_name (proc));
......@@ -421,16 +391,13 @@ plug_in_menus_add_proc (GimpUIManager *manager,
GUINT_TO_POINTER (menu_merge_id));
}
stripped_path = gimp_strip_uline (path);
stripped_path = gimp_strip_uline (menu_path);
action_path = plug_in_menus_build_path (manager, ui_path, menu_merge_id,
stripped_path, FALSE);
g_free (stripped_path);
if (! action_path)
{
g_free (path);
return;
}
return;
GIMP_LOG (MENUS, "adding menu item for '%s' (@ %s)",
gimp_object_get_name (proc), action_path);
......@@ -443,7 +410,6 @@ plug_in_menus_add_proc (GimpUIManager *manager,
FALSE);
g_free (action_path);
g_free (path);
}
static void
......
......@@ -747,18 +747,18 @@ gimp_plug_in_handle_proc_install (GimpPlugIn *plug_in,
#define VALIDATE(str) (g_utf8_validate ((str), -1, NULL))
#define VALIDATE_OR_NULL(str) ((str) == NULL || g_utf8_validate ((str), -1, NULL))
if (VALIDATE_OR_NULL (proc_install->menu_path) &&
VALIDATE (canonical) &&
VALIDATE_OR_NULL (proc_install->blurb) &&
VALIDATE_OR_NULL (proc_install->help) &&
VALIDATE_OR_NULL (proc_install->author) &&
VALIDATE_OR_NULL (proc_install->copyright) &&
if (VALIDATE_OR_NULL (proc_install->menu_label) &&
VALIDATE (canonical) &&
VALIDATE_OR_NULL (proc_install->blurb) &&
VALIDATE_OR_NULL (proc_install->help) &&
VALIDATE_OR_NULL (proc_install->author) &&
VALIDATE_OR_NULL (proc_install->copyright) &&
VALIDATE_OR_NULL (proc_install->date))
{
null_name = FALSE;
valid_utf8 = TRUE;
for (i = 0; i < proc_install->nparams && valid_utf8 && !null_name; i++)
for (i = 0; i < proc_install->nparams && valid_utf8 && ! null_name; i++)
{
if (! proc_install->params[i].name)
{
......@@ -810,6 +810,19 @@ gimp_plug_in_handle_proc_install (GimpPlugIn *plug_in,
return;
}
if (proc_install->menu_label && strlen (proc_install->menu_label) &&
proc_install->menu_label[0] == '<')
{
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
"Plug-in \"%s\"\n(%s)\n\n"
"attempted to install a procedure with a full menu path "
"as menu label, this is not supported any longer.",
gimp_object_get_name (plug_in),
gimp_file_get_utf8_name (plug_in->file));
g_free (canonical);
return;
}
/* Create the procedure object */
switch (proc_install->type)
......@@ -840,6 +853,9 @@ gimp_plug_in_handle_proc_install (GimpPlugIn *plug_in,
proc_install->date,
NULL);
if (proc_install->menu_label && strlen (proc_install->menu_label))
proc->menu_label = g_strdup (proc_install->menu_label);
gimp_plug_in_procedure_set_image_types (proc, proc_install->image_types);
for (i = 0; i < proc_install->nparams; i++)
......@@ -864,30 +880,6 @@ gimp_plug_in_handle_proc_install (GimpPlugIn *plug_in,
gimp_procedure_add_return_value (procedure, pspec);
}
/* Sanity check menu path */
if (proc_install->menu_path && strlen (proc_install->menu_path))
{
if (proc_install->menu_path[0] == '<')
{
GError *error = NULL;
if (! gimp_plug_in_procedure_add_menu_path (proc,
proc_install->menu_path,
&error))
{
gimp_message_literal (plug_in->manager->gimp,
NULL, GIMP_MESSAGE_WARNING,
error->message);
g_clear_error (&error);
}
}
else
{
proc->menu_label = g_strdup (proc_install->menu_path);
}
}
/* Install the procedure */
switch (proc_install->type)
......
......@@ -242,31 +242,20 @@ static const gchar *
gimp_plug_in_procedure_get_label (GimpProcedure *procedure)
{
GimpPlugInProcedure *proc = GIMP_PLUG_IN_PROCEDURE (procedure);
const gchar *path;
gchar *stripped;
const gchar *translated;
gchar *ellipsis;
gchar *label;
if (proc->label)
return proc->label;
if (proc->menu_label)
path = dgettext (gimp_plug_in_procedure_get_locale_domain (proc),
proc->menu_label);
else if (proc->menu_paths)
path = dgettext (gimp_plug_in_procedure_get_locale_domain (proc),
proc->menu_paths->data);
else
if (! proc->menu_label)
return NULL;
stripped = gimp_strip_uline (path);
if (proc->menu_label)
label = g_strdup (stripped);
else
label = g_path_get_basename (stripped);
translated = dgettext (gimp_plug_in_procedure_get_locale_domain (proc),
proc->menu_label);
g_free (stripped);
label = gimp_strip_uline (translated);
ellipsis = strstr (label, "...");
......@@ -287,22 +276,8 @@ gimp_plug_in_procedure_get_menu_label (GimpProcedure *procedure)
GimpPlugInProcedure *proc = GIMP_PLUG_IN_PROCEDURE (procedure);
if (proc->menu_label)
{
return dgettext (gimp_plug_in_procedure_get_locale_domain (proc),
proc->menu_label);
}
else if (proc->menu_paths)
{
const gchar *translated;
translated = dgettext (gimp_plug_in_procedure_get_locale_domain (proc),
proc->menu_paths->data);
translated = strrchr (translated, '/');
if (translated)
return translated + 1;
}
return dgettext (gimp_plug_in_procedure_get_locale_domain (proc),
proc->menu_label);
return GIMP_PROCEDURE_CLASS (parent_class)->get_menu_label (procedure);
}
......
......@@ -746,11 +746,7 @@ gimp_quit (void)
*
* @menu_label defines the label that should be used for the
* procedure's menu entry. The position where to register in the menu
* hierarchy is chosen using gimp_plugin_menu_register(). This
* function also still accepts the old (pre-2.2) way of registering a
* menu entry and takes a string in the form
* "&lt;Domain&gt;/Path/To/My/Menu"
* (e.g. "&lt;Image&gt;/Filters/Render/Useless").
* hierarchy is chosen using gimp_plugin_menu_register().
*
* It is possible to register a procedure only for keyboard-shortcut
* activation by passing a @menu_label to gimp_install_procedure() but
......@@ -813,7 +809,7 @@ gimp_install_procedure (const gchar *name,
proc_install.author = (gchar *) author;
proc_install.copyright = (gchar *) copyright;
proc_install.date = (gchar *) date;
proc_install.menu_path = (gchar *) menu_label;
proc_install.menu_label = (gchar *) menu_label;
proc_install.image_types = (gchar *) image_types;
proc_install.type = type;
proc_install.nparams = n_params;
......
......@@ -1012,7 +1012,7 @@ _gp_proc_install_read (GIOChannel *channel,
&proc_install->date, 1, user_data))
goto cleanup;
if (! _gimp_wire_read_string (channel,
&proc_install->menu_path, 1, user_data))
&proc_install->menu_label, 1, user_data))
goto cleanup;
if (! _gimp_wire_read_string (channel,
&proc_install->image_types, 1, user_data))
......@@ -1074,7 +1074,7 @@ _gp_proc_install_read (GIOChannel *channel,
g_free (proc_install->author);
g_free (proc_install->copyright);
g_free (proc_install->date);
g_free (proc_install->menu_path);
g_free (proc_install->menu_label);
g_free (proc_install->image_types);
if (proc_install->params)
......@@ -1136,7 +1136,7 @@ _gp_proc_install_write (GIOChannel *channel,
&proc_install->date, 1, user_data))
return;
if (! _gimp_wire_write_string (channel,
&proc_install->menu_path, 1, user_data))
&proc_install->menu_label, 1, user_data))
return;
if (! _gimp_wire_write_string (channel,
&proc_install->image_types, 1, user_data))
......@@ -1200,7 +1200,7 @@ _gp_proc_install_destroy (GimpWireMessage *msg)
g_free (proc_install->author);
g_free (proc_install->copyright);
g_free (proc_install->date);
g_free (proc_install->menu_path);
g_free (proc_install->menu_label);
g_free (proc_install->image_types);
for (i = 0; i < proc_install->nparams; i++)
......
......@@ -26,7 +26,7 @@ G_BEGIN_DECLS
/* Increment every time the protocol changes
*/
#define GIMP_PROTOCOL_VERSION 0x0101
#define GIMP_PROTOCOL_VERSION 0x0102
enum
......@@ -162,7 +162,7 @@ struct _GPProcInstall
gchar *author;
gchar *copyright;
gchar *date;
gchar *menu_path;
gchar *menu_label;
gchar *image_types;
guint32 type;
guint32 nparams;
......
Markdown is supported
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