Made modifying actions insensitive when the active item is locked
Use the term "writable" in the code as a shortcut for "there is an active item and it is not locked".
This commit is contained in:
@ -154,6 +154,7 @@ drawable_actions_update (GimpActionGroup *group,
|
|||||||
gboolean is_indexed = FALSE;
|
gboolean is_indexed = FALSE;
|
||||||
gboolean visible = FALSE;
|
gboolean visible = FALSE;
|
||||||
gboolean linked = FALSE;
|
gboolean linked = FALSE;
|
||||||
|
gboolean writable = FALSE;
|
||||||
|
|
||||||
image = action_data_get_image (data);
|
image = action_data_get_image (data);
|
||||||
|
|
||||||
@ -175,8 +176,9 @@ drawable_actions_update (GimpActionGroup *group,
|
|||||||
else
|
else
|
||||||
item = GIMP_ITEM (drawable);
|
item = GIMP_ITEM (drawable);
|
||||||
|
|
||||||
visible = gimp_item_get_visible (item);
|
visible = gimp_item_get_visible (item);
|
||||||
linked = gimp_item_get_linked (item);
|
linked = gimp_item_get_linked (item);
|
||||||
|
writable = ! gimp_item_get_lock_content (item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,10 +187,10 @@ drawable_actions_update (GimpActionGroup *group,
|
|||||||
#define SET_ACTIVE(action,condition) \
|
#define SET_ACTIVE(action,condition) \
|
||||||
gimp_action_group_set_action_active (group, action, (condition) != 0)
|
gimp_action_group_set_action_active (group, action, (condition) != 0)
|
||||||
|
|
||||||
SET_SENSITIVE ("drawable-equalize", drawable && ! is_indexed);
|
SET_SENSITIVE ("drawable-equalize", writable && ! is_indexed);
|
||||||
SET_SENSITIVE ("drawable-invert", drawable && ! is_indexed);
|
SET_SENSITIVE ("drawable-invert", writable && ! is_indexed);
|
||||||
SET_SENSITIVE ("drawable-levels-stretch", drawable && is_rgb);
|
SET_SENSITIVE ("drawable-levels-stretch", writable && is_rgb);
|
||||||
SET_SENSITIVE ("drawable-offset", drawable);
|
SET_SENSITIVE ("drawable-offset", writable);
|
||||||
|
|
||||||
SET_SENSITIVE ("drawable-visible", drawable);
|
SET_SENSITIVE ("drawable-visible", drawable);
|
||||||
SET_SENSITIVE ("drawable-linked", drawable);
|
SET_SENSITIVE ("drawable-linked", drawable);
|
||||||
@ -196,12 +198,12 @@ drawable_actions_update (GimpActionGroup *group,
|
|||||||
SET_ACTIVE ("drawable-visible", visible);
|
SET_ACTIVE ("drawable-visible", visible);
|
||||||
SET_ACTIVE ("drawable-linked", linked);
|
SET_ACTIVE ("drawable-linked", linked);
|
||||||
|
|
||||||
SET_SENSITIVE ("drawable-flip-horizontal", drawable);
|
SET_SENSITIVE ("drawable-flip-horizontal", writable);
|
||||||
SET_SENSITIVE ("drawable-flip-vertical", drawable);
|
SET_SENSITIVE ("drawable-flip-vertical", writable);
|
||||||
|
|
||||||
SET_SENSITIVE ("drawable-rotate-90", drawable);
|
SET_SENSITIVE ("drawable-rotate-90", writable);
|
||||||
SET_SENSITIVE ("drawable-rotate-180", drawable);
|
SET_SENSITIVE ("drawable-rotate-180", writable);
|
||||||
SET_SENSITIVE ("drawable-rotate-270", drawable);
|
SET_SENSITIVE ("drawable-rotate-270", writable);
|
||||||
|
|
||||||
#undef SET_SENSITIVE
|
#undef SET_SENSITIVE
|
||||||
#undef SET_ACTIVE
|
#undef SET_ACTIVE
|
||||||
|
@ -263,6 +263,7 @@ edit_actions_update (GimpActionGroup *group,
|
|||||||
gchar *undo_name = NULL;
|
gchar *undo_name = NULL;
|
||||||
gchar *redo_name = NULL;
|
gchar *redo_name = NULL;
|
||||||
gchar *fade_name = NULL;
|
gchar *fade_name = NULL;
|
||||||
|
gboolean writable = FALSE;
|
||||||
gboolean undo_enabled = FALSE;
|
gboolean undo_enabled = FALSE;
|
||||||
gboolean fade_enabled = FALSE;
|
gboolean fade_enabled = FALSE;
|
||||||
|
|
||||||
@ -270,6 +271,11 @@ edit_actions_update (GimpActionGroup *group,
|
|||||||
{
|
{
|
||||||
drawable = gimp_image_get_active_drawable (image);
|
drawable = gimp_image_get_active_drawable (image);
|
||||||
|
|
||||||
|
if (drawable)
|
||||||
|
{
|
||||||
|
writable = ! gimp_item_get_lock_content (GIMP_ITEM (drawable));
|
||||||
|
}
|
||||||
|
|
||||||
undo_enabled = gimp_image_undo_is_enabled (image);
|
undo_enabled = gimp_image_undo_is_enabled (image);
|
||||||
|
|
||||||
if (undo_enabled)
|
if (undo_enabled)
|
||||||
@ -329,22 +335,22 @@ edit_actions_update (GimpActionGroup *group,
|
|||||||
g_free (redo_name);
|
g_free (redo_name);
|
||||||
g_free (fade_name);
|
g_free (fade_name);
|
||||||
|
|
||||||
SET_SENSITIVE ("edit-cut", drawable);
|
SET_SENSITIVE ("edit-cut", writable);
|
||||||
SET_SENSITIVE ("edit-copy", drawable);
|
SET_SENSITIVE ("edit-copy", drawable);
|
||||||
SET_SENSITIVE ("edit-copy-visible", image);
|
SET_SENSITIVE ("edit-copy-visible", image);
|
||||||
/* "edit-paste" is always enabled */
|
SET_SENSITIVE ("edit-paste", ! image || (! drawable || writable));
|
||||||
SET_SENSITIVE ("edit-paste-as-new-layer", image);
|
SET_SENSITIVE ("edit-paste-as-new-layer", image);
|
||||||
SET_SENSITIVE ("edit-paste-into", image);
|
SET_SENSITIVE ("edit-paste-into", image && (! drawable || writable));
|
||||||
|
|
||||||
SET_SENSITIVE ("edit-named-cut", drawable);
|
SET_SENSITIVE ("edit-named-cut", writable);
|
||||||
SET_SENSITIVE ("edit-named-copy", drawable);
|
SET_SENSITIVE ("edit-named-copy", drawable);
|
||||||
SET_SENSITIVE ("edit-named-copy-visible", drawable);
|
SET_SENSITIVE ("edit-named-copy-visible", drawable);
|
||||||
SET_SENSITIVE ("edit-named-paste", image);
|
SET_SENSITIVE ("edit-named-paste", image && (! drawable || writable));
|
||||||
|
|
||||||
SET_SENSITIVE ("edit-clear", drawable);
|
SET_SENSITIVE ("edit-clear", writable);
|
||||||
SET_SENSITIVE ("edit-fill-fg", drawable);
|
SET_SENSITIVE ("edit-fill-fg", writable);
|
||||||
SET_SENSITIVE ("edit-fill-bg", drawable);
|
SET_SENSITIVE ("edit-fill-bg", writable);
|
||||||
SET_SENSITIVE ("edit-fill-pattern", drawable);
|
SET_SENSITIVE ("edit-fill-pattern", writable);
|
||||||
|
|
||||||
#undef SET_LABEL
|
#undef SET_LABEL
|
||||||
#undef SET_SENSITIVE
|
#undef SET_SENSITIVE
|
||||||
|
@ -501,6 +501,7 @@ layers_actions_update (GimpActionGroup *group,
|
|||||||
gboolean indexed = FALSE; /* is indexed */
|
gboolean indexed = FALSE; /* is indexed */
|
||||||
gboolean lock_alpha = FALSE;
|
gboolean lock_alpha = FALSE;
|
||||||
gboolean text_layer = FALSE;
|
gboolean text_layer = FALSE;
|
||||||
|
gboolean writable = FALSE;
|
||||||
GList *next = NULL;
|
GList *next = NULL;
|
||||||
GList *prev = NULL;
|
GList *prev = NULL;
|
||||||
|
|
||||||
@ -521,6 +522,7 @@ layers_actions_update (GimpActionGroup *group,
|
|||||||
mask = gimp_layer_get_mask (layer);
|
mask = gimp_layer_get_mask (layer);
|
||||||
lock_alpha = gimp_layer_get_lock_alpha (layer);
|
lock_alpha = gimp_layer_get_lock_alpha (layer);
|
||||||
alpha = gimp_drawable_has_alpha (GIMP_DRAWABLE (layer));
|
alpha = gimp_drawable_has_alpha (GIMP_DRAWABLE (layer));
|
||||||
|
writable = ! gimp_item_get_lock_content (GIMP_ITEM (layer));
|
||||||
|
|
||||||
layer_list = gimp_item_get_container_iter (GIMP_ITEM (layer));
|
layer_list = gimp_item_get_container_iter (GIMP_ITEM (layer));
|
||||||
|
|
||||||
@ -532,8 +534,7 @@ layers_actions_update (GimpActionGroup *group,
|
|||||||
next = g_list_next (list);
|
next = g_list_next (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (layer)
|
text_layer = gimp_drawable_is_text_layer (GIMP_DRAWABLE (layer));
|
||||||
text_layer = gimp_drawable_is_text_layer (GIMP_DRAWABLE (layer));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -577,21 +578,21 @@ layers_actions_update (GimpActionGroup *group,
|
|||||||
SET_VISIBLE ("layers-text-selection-subtract", text_layer && !ac);
|
SET_VISIBLE ("layers-text-selection-subtract", text_layer && !ac);
|
||||||
SET_VISIBLE ("layers-text-selection-intersect", text_layer && !ac);
|
SET_VISIBLE ("layers-text-selection-intersect", text_layer && !ac);
|
||||||
|
|
||||||
SET_SENSITIVE ("layers-resize", layer && !ac);
|
SET_SENSITIVE ("layers-resize", writable && !ac);
|
||||||
SET_SENSITIVE ("layers-resize-to-image", layer && !ac);
|
SET_SENSITIVE ("layers-resize-to-image", writable && !ac);
|
||||||
SET_SENSITIVE ("layers-scale", layer && !ac);
|
SET_SENSITIVE ("layers-scale", writable && !ac);
|
||||||
|
|
||||||
SET_SENSITIVE ("layers-crop", layer && sel);
|
SET_SENSITIVE ("layers-crop", writable && sel);
|
||||||
|
|
||||||
SET_SENSITIVE ("layers-alpha-add", layer && !fs && !alpha);
|
SET_SENSITIVE ("layers-alpha-add", writable && !fs && !alpha);
|
||||||
SET_SENSITIVE ("layers-alpha-remove", layer && !fs && alpha);
|
SET_SENSITIVE ("layers-alpha-remove", writable && !fs && alpha);
|
||||||
|
|
||||||
SET_SENSITIVE ("layers-lock-alpha", layer);
|
SET_SENSITIVE ("layers-lock-alpha", layer);
|
||||||
SET_ACTIVE ("layers-lock-alpha", lock_alpha);
|
SET_ACTIVE ("layers-lock-alpha", lock_alpha);
|
||||||
|
|
||||||
SET_SENSITIVE ("layers-mask-add", layer && !fs && !ac && !mask);
|
SET_SENSITIVE ("layers-mask-add", layer && !fs && !ac && !mask);
|
||||||
SET_SENSITIVE ("layers-mask-apply", layer && !fs && !ac && mask);
|
SET_SENSITIVE ("layers-mask-apply", writable && !fs && !ac && mask);
|
||||||
SET_SENSITIVE ("layers-mask-delete", layer && !fs && !ac && mask);
|
SET_SENSITIVE ("layers-mask-delete", layer && !fs && !ac && mask);
|
||||||
|
|
||||||
SET_SENSITIVE ("layers-mask-edit", layer && !fs && !ac && mask);
|
SET_SENSITIVE ("layers-mask-edit", layer && !fs && !ac && mask);
|
||||||
SET_SENSITIVE ("layers-mask-show", layer && !fs && !ac && mask);
|
SET_SENSITIVE ("layers-mask-show", layer && !fs && !ac && mask);
|
||||||
|
@ -137,11 +137,17 @@ select_actions_update (GimpActionGroup *group,
|
|||||||
GimpDrawable *drawable = NULL;
|
GimpDrawable *drawable = NULL;
|
||||||
gboolean fs = FALSE;
|
gboolean fs = FALSE;
|
||||||
gboolean sel = FALSE;
|
gboolean sel = FALSE;
|
||||||
|
gboolean writable = FALSE;
|
||||||
|
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
drawable = gimp_image_get_active_drawable (image);
|
drawable = gimp_image_get_active_drawable (image);
|
||||||
|
|
||||||
|
if (drawable)
|
||||||
|
{
|
||||||
|
writable = ! gimp_item_get_lock_content (GIMP_ITEM (drawable));
|
||||||
|
}
|
||||||
|
|
||||||
fs = (gimp_image_get_floating_selection (image) != NULL);
|
fs = (gimp_image_get_floating_selection (image) != NULL);
|
||||||
sel = ! gimp_channel_is_empty (gimp_image_get_mask (image));
|
sel = ! gimp_channel_is_empty (gimp_image_get_mask (image));
|
||||||
}
|
}
|
||||||
@ -152,7 +158,7 @@ select_actions_update (GimpActionGroup *group,
|
|||||||
SET_SENSITIVE ("select-all", drawable);
|
SET_SENSITIVE ("select-all", drawable);
|
||||||
SET_SENSITIVE ("select-none", drawable && sel);
|
SET_SENSITIVE ("select-none", drawable && sel);
|
||||||
SET_SENSITIVE ("select-invert", drawable);
|
SET_SENSITIVE ("select-invert", drawable);
|
||||||
SET_SENSITIVE ("select-float", drawable && sel);
|
SET_SENSITIVE ("select-float", writable && sel);
|
||||||
|
|
||||||
SET_SENSITIVE ("select-feather", drawable && sel);
|
SET_SENSITIVE ("select-feather", drawable && sel);
|
||||||
SET_SENSITIVE ("select-sharpen", drawable && sel);
|
SET_SENSITIVE ("select-sharpen", drawable && sel);
|
||||||
@ -161,8 +167,8 @@ select_actions_update (GimpActionGroup *group,
|
|||||||
SET_SENSITIVE ("select-border", drawable && sel);
|
SET_SENSITIVE ("select-border", drawable && sel);
|
||||||
|
|
||||||
SET_SENSITIVE ("select-save", drawable && !fs);
|
SET_SENSITIVE ("select-save", drawable && !fs);
|
||||||
SET_SENSITIVE ("select-stroke", drawable && sel);
|
SET_SENSITIVE ("select-stroke", writable && sel);
|
||||||
SET_SENSITIVE ("select-stroke-last-values", drawable && sel);
|
SET_SENSITIVE ("select-stroke-last-values", writable && sel);
|
||||||
|
|
||||||
#undef SET_SENSITIVE
|
#undef SET_SENSITIVE
|
||||||
}
|
}
|
||||||
|
@ -244,6 +244,7 @@ vectors_actions_update (GimpActionGroup *group,
|
|||||||
gboolean global_buf = FALSE;
|
gboolean global_buf = FALSE;
|
||||||
gboolean visible = FALSE;
|
gboolean visible = FALSE;
|
||||||
gboolean linked = FALSE;
|
gboolean linked = FALSE;
|
||||||
|
gboolean writable = FALSE;
|
||||||
GList *next = NULL;
|
GList *next = NULL;
|
||||||
GList *prev = NULL;
|
GList *prev = NULL;
|
||||||
|
|
||||||
@ -261,8 +262,9 @@ vectors_actions_update (GimpActionGroup *group,
|
|||||||
GList *vectors_list;
|
GList *vectors_list;
|
||||||
GList *list;
|
GList *list;
|
||||||
|
|
||||||
visible = gimp_item_get_visible (item);
|
visible = gimp_item_get_visible (item);
|
||||||
linked = gimp_item_get_linked (item);
|
linked = gimp_item_get_linked (item);
|
||||||
|
writable = ! gimp_item_get_lock_content (item);
|
||||||
|
|
||||||
vectors_list = gimp_item_get_container_iter (item);
|
vectors_list = gimp_item_get_container_iter (item);
|
||||||
|
|
||||||
@ -281,7 +283,7 @@ vectors_actions_update (GimpActionGroup *group,
|
|||||||
#define SET_ACTIVE(action,condition) \
|
#define SET_ACTIVE(action,condition) \
|
||||||
gimp_action_group_set_action_active (group, action, (condition) != 0)
|
gimp_action_group_set_action_active (group, action, (condition) != 0)
|
||||||
|
|
||||||
SET_SENSITIVE ("vectors-path-tool", vectors);
|
SET_SENSITIVE ("vectors-path-tool", writable);
|
||||||
SET_SENSITIVE ("vectors-edit-attributes", vectors);
|
SET_SENSITIVE ("vectors-edit-attributes", vectors);
|
||||||
|
|
||||||
SET_SENSITIVE ("vectors-new", image);
|
SET_SENSITIVE ("vectors-new", image);
|
||||||
|
Reference in New Issue
Block a user