mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 09:23:24 +00:00
Issue #9349: removing 2 duplicate "*-short" actions.
"edit-paste-as-new-image-short" and "vectors-selection-to-vectors-short" were just duplicate of the action named the same, except for the "-short" suffix, and the only point was to have different labels. Not though that this time, it was not enough to conclude that the action in a menu shoud have the short variant. These were both used differently depending on the menu. Instead I added the concept of "label-variant" attribute in .ui menu files. When the "long" variant is set, then we simply use the longer label. There is still one more "-short" action: "tools-by-color-select-short", but I am a still unsure how to handle this one.
This commit is contained in:
parent
89772351c9
commit
ea1205f094
7 changed files with 57 additions and 25 deletions
|
@ -120,13 +120,9 @@ static const GimpActionEntry edit_actions[] =
|
|||
GIMP_HELP_EDIT_COPY_VISIBLE },
|
||||
|
||||
{ "edit-paste-as-new-image", GIMP_ICON_EDIT_PASTE_AS_NEW,
|
||||
NC_("edit-action", "From _Clipboard"), NULL, { "<primary><shift>V", "<shift>Paste", NULL },
|
||||
NC_("edit-action", "Create a new image from the content of the clipboard"),
|
||||
edit_paste_as_new_image_cmd_callback,
|
||||
GIMP_HELP_EDIT_PASTE_AS_NEW_IMAGE },
|
||||
|
||||
{ "edit-paste-as-new-image-short", GIMP_ICON_EDIT_PASTE_AS_NEW,
|
||||
NC_("edit-action", "Paste as _New Image"), NULL, { NULL },
|
||||
NC_("edit-action", "Paste as _New Image"),
|
||||
NC_("edit-action", "From _Clipboard"),
|
||||
{ "<primary><shift>V", "<shift>Paste", NULL },
|
||||
NC_("edit-action", "Create a new image from the content of the clipboard"),
|
||||
edit_paste_as_new_image_cmd_callback,
|
||||
GIMP_HELP_EDIT_PASTE_AS_NEW_IMAGE },
|
||||
|
|
|
@ -274,13 +274,8 @@ static const GimpEnumActionEntry vectors_to_selection_actions[] =
|
|||
static const GimpEnumActionEntry vectors_selection_to_vectors_actions[] =
|
||||
{
|
||||
{ "vectors-selection-to-vectors", GIMP_ICON_SELECTION_TO_PATH,
|
||||
NC_("vectors-action", "Selecti_on to Path"), NULL, { NULL },
|
||||
NC_("vectors-action", "Selection to path"),
|
||||
FALSE, FALSE,
|
||||
GIMP_HELP_SELECTION_TO_PATH },
|
||||
|
||||
{ "vectors-selection-to-vectors-short", GIMP_ICON_SELECTION_TO_PATH,
|
||||
NC_("vectors-action", "To _Path"), NULL, { NULL },
|
||||
NC_("vectors-action", "Selecti_on to Path"),
|
||||
NC_("vectors-action", "To _Path"), { NULL },
|
||||
NC_("vectors-action", "Selection to path"),
|
||||
FALSE, FALSE,
|
||||
GIMP_HELP_SELECTION_TO_PATH },
|
||||
|
@ -439,7 +434,6 @@ vectors_actions_update (GimpActionGroup *group,
|
|||
SET_SENSITIVE ("vectors-import", image);
|
||||
|
||||
SET_SENSITIVE ("vectors-selection-to-vectors", image && !mask_empty);
|
||||
SET_SENSITIVE ("vectors-selection-to-vectors-short", image && !mask_empty);
|
||||
SET_SENSITIVE ("vectors-selection-to-vectors-advanced", image && !mask_empty);
|
||||
SET_SENSITIVE ("vectors-fill", n_selected_vectors > 0 &&
|
||||
dr_writable &&
|
||||
|
|
|
@ -88,6 +88,7 @@ static void gimp_menu_add_placeholder (GimpMenu *menu
|
|||
const gchar *label);
|
||||
static void gimp_menu_add_action (GimpMenu *menu,
|
||||
const gchar *action_name,
|
||||
gboolean long_label,
|
||||
GtkWidget *sibling,
|
||||
gboolean top,
|
||||
GtkRadioMenuItem **group);
|
||||
|
@ -264,7 +265,17 @@ gimp_menu_append (GimpMenuShell *shell,
|
|||
}
|
||||
else
|
||||
{
|
||||
gimp_menu_add_action (menu, action_name, NULL, FALSE, &group);
|
||||
gchar *label_variant = NULL;
|
||||
|
||||
g_menu_model_get_item_attribute (G_MENU_MODEL (model), i, "label-variant", "s", &label_variant);
|
||||
gimp_menu_add_action (menu, action_name,
|
||||
/* By default, we use the short label in menus,
|
||||
* unless "label-variant" attribute is set to
|
||||
* "long".
|
||||
*/
|
||||
g_strcmp0 (label_variant, "long") == 0,
|
||||
NULL, FALSE, &group);
|
||||
g_free (label_variant);
|
||||
}
|
||||
|
||||
g_free (label);
|
||||
|
@ -295,7 +306,7 @@ gimp_menu_add_ui (GimpMenuShell *shell,
|
|||
if (! placeholder)
|
||||
g_warning ("%s: no placeholder item '%s'.", G_STRFUNC, placeholder_key);
|
||||
|
||||
gimp_menu_add_action (menu, action_name, placeholder, top, NULL);
|
||||
gimp_menu_add_action (menu, action_name, FALSE, placeholder, top, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -419,6 +430,7 @@ gimp_menu_add_placeholder (GimpMenu *menu,
|
|||
static void
|
||||
gimp_menu_add_action (GimpMenu *menu,
|
||||
const gchar *action_name,
|
||||
gboolean long_label,
|
||||
GtkWidget *sibling,
|
||||
gboolean top,
|
||||
GtkRadioMenuItem **group)
|
||||
|
@ -436,7 +448,10 @@ gimp_menu_add_action (GimpMenu *menu,
|
|||
|
||||
g_return_if_fail (GIMP_IS_ACTION (action));
|
||||
|
||||
action_label = gimp_action_get_short_label (action);
|
||||
if (long_label)
|
||||
action_label = gimp_action_get_label (action);
|
||||
else
|
||||
action_label = gimp_action_get_short_label (action);
|
||||
g_return_if_fail (action_label != NULL);
|
||||
|
||||
if (GIMP_IS_TOGGLE_ACTION (action))
|
||||
|
@ -657,16 +672,21 @@ gimp_menu_section_items_changed (GMenuModel *model,
|
|||
|
||||
while (added > 0)
|
||||
{
|
||||
gchar *action_name = NULL;
|
||||
gchar *action_name = NULL;
|
||||
gchar *label_variant = NULL;
|
||||
|
||||
g_menu_model_get_item_attribute (G_MENU_MODEL (model), position,
|
||||
G_MENU_ATTRIBUTE_ACTION, "s", &action_name);
|
||||
g_menu_model_get_item_attribute (G_MENU_MODEL (model), position,
|
||||
"label-variant", "s", &label_variant);
|
||||
|
||||
g_return_if_fail (action_name != NULL);
|
||||
gimp_menu_add_action (menu, action_name,
|
||||
g_strcmp0 (label_variant, "long") == 0,
|
||||
iter ? iter->data : NULL,
|
||||
iter ? TRUE : FALSE, NULL);
|
||||
g_free (action_name);
|
||||
g_free (label_variant);
|
||||
|
||||
added--;
|
||||
position++;
|
||||
|
|
|
@ -654,6 +654,7 @@ gimp_menu_model_initialize (GimpMenuModel *model,
|
|||
if (action_name)
|
||||
{
|
||||
GimpAction *action;
|
||||
gchar *label_variant = NULL;
|
||||
|
||||
action = gimp_ui_manager_find_action (model->priv->manager, NULL, action_name);
|
||||
|
||||
|
@ -668,11 +669,21 @@ gimp_menu_model_initialize (GimpMenuModel *model,
|
|||
G_CALLBACK (gimp_menu_model_action_notify_visible),
|
||||
model, 0);
|
||||
|
||||
g_menu_item_set_label (item, gimp_action_get_short_label (action));
|
||||
g_menu_item_get_attribute (item, "label-variant", "s", &label_variant);
|
||||
if (g_strcmp0 (label_variant, "long") == 0)
|
||||
g_menu_item_set_label (item, gimp_action_get_label (action));
|
||||
else
|
||||
g_menu_item_set_label (item, gimp_action_get_short_label (action));
|
||||
|
||||
g_signal_connect_object (action,
|
||||
"notify::short-label",
|
||||
G_CALLBACK (gimp_menu_model_action_notify_label),
|
||||
item, 0);
|
||||
g_signal_connect_object (action,
|
||||
"notify::label",
|
||||
G_CALLBACK (gimp_menu_model_action_notify_label),
|
||||
item, 0);
|
||||
g_free (label_variant);
|
||||
}
|
||||
/* else we instal a placeholder (no-action and always invisible) item. */
|
||||
}
|
||||
|
@ -824,10 +835,17 @@ gimp_menu_model_action_notify_label (GimpAction *action,
|
|||
GParamSpec *pspec,
|
||||
GMenuItem *item)
|
||||
{
|
||||
gchar *label_variant = NULL;
|
||||
|
||||
g_return_if_fail (GIMP_IS_ACTION (action));
|
||||
g_return_if_fail (G_IS_MENU_ITEM (item));
|
||||
|
||||
g_menu_item_set_label (item, gimp_action_get_short_label (action));
|
||||
g_menu_item_get_attribute (item, "label-variant", "s", &label_variant);
|
||||
if (g_strcmp0 (label_variant, "long") == 0)
|
||||
g_menu_item_set_label (item, gimp_action_get_label (action));
|
||||
else
|
||||
g_menu_item_set_label (item, gimp_action_get_short_label (action));
|
||||
g_free (label_variant);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -935,6 +953,10 @@ gimp_menu_model_ui_added (GimpUIManager *manager,
|
|||
"notify::short-label",
|
||||
G_CALLBACK (gimp_menu_model_action_notify_label),
|
||||
item, 0);
|
||||
g_signal_connect_object (action,
|
||||
"notify::label",
|
||||
G_CALLBACK (gimp_menu_model_action_notify_label),
|
||||
item, 0);
|
||||
g_menu_model_items_changed (G_MENU_MODEL (model), position, 0, 1);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
<item><attribute name="action">app.edit-paste-merged-in-place</attribute></item>
|
||||
<item><attribute name="action">app.edit-paste-into</attribute></item>
|
||||
<item><attribute name="action">app.edit-paste-into-in-place</attribute></item>
|
||||
<item><attribute name="action">app.edit-paste-as-new-image-short</attribute></item>
|
||||
<item><attribute name="action">app.edit-paste-as-new-image</attribute><attribute name="label-variant">long</attribute></item>
|
||||
</submenu>
|
||||
<submenu>
|
||||
<attribute name="label" translatable="yes" context="edit-action">_Buffer</attribute>
|
||||
|
@ -138,7 +138,7 @@
|
|||
<section>
|
||||
<item><attribute name="action">app.quick-mask-toggle</attribute></item>
|
||||
<item><attribute name="action">app.select-save</attribute></item>
|
||||
<item><attribute name="action">app.vectors-selection-to-vectors-short</attribute></item>
|
||||
<item><attribute name="action">app.vectors-selection-to-vectors</attribute></item>
|
||||
</section>
|
||||
</submenu>
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
</section>
|
||||
<section>
|
||||
<item><attribute name="action">app.select-save</attribute></item>
|
||||
<item><attribute name="action">app.vectors-selection-to-vectors-short</attribute></item>
|
||||
<item><attribute name="action">app.vectors-selection-to-vectors</attribute></item>
|
||||
</section>
|
||||
<item><attribute name="action">app.select-fill</attribute></item>
|
||||
<item><attribute name="action">app.select-stroke</attribute></item>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<item><attribute name="action">app.vectors-selection-add</attribute></item>
|
||||
<item><attribute name="action">app.vectors-selection-subtract</attribute></item>
|
||||
<item><attribute name="action">app.vectors-selection-intersect</attribute></item>
|
||||
<item><attribute name="action">app.vectors-selection-to-vectors</attribute></item>
|
||||
<item><attribute name="action">app.vectors-selection-to-vectors</attribute><attribute name="label-variant">long</attribute></item>
|
||||
</section>
|
||||
<section>
|
||||
<item><attribute name="action">app.vectors-fill</attribute></item>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue