From 7262e45df9cdc2fd743f75b23b6b1420730e9f53 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Thu, 20 Aug 2009 17:11:31 +0200 Subject: [PATCH] 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". --- app/actions/drawable-actions.c | 24 +++++++++++++----------- app/actions/edit-actions.c | 24 +++++++++++++++--------- app/actions/layers-actions.c | 23 ++++++++++++----------- app/actions/select-actions.c | 12 +++++++++--- app/actions/vectors-actions.c | 8 +++++--- 5 files changed, 54 insertions(+), 37 deletions(-) diff --git a/app/actions/drawable-actions.c b/app/actions/drawable-actions.c index 06d1089689..88a636bd85 100644 --- a/app/actions/drawable-actions.c +++ b/app/actions/drawable-actions.c @@ -154,6 +154,7 @@ drawable_actions_update (GimpActionGroup *group, gboolean is_indexed = FALSE; gboolean visible = FALSE; gboolean linked = FALSE; + gboolean writable = FALSE; image = action_data_get_image (data); @@ -175,8 +176,9 @@ drawable_actions_update (GimpActionGroup *group, else item = GIMP_ITEM (drawable); - visible = gimp_item_get_visible (item); - linked = gimp_item_get_linked (item); + visible = gimp_item_get_visible (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) \ gimp_action_group_set_action_active (group, action, (condition) != 0) - SET_SENSITIVE ("drawable-equalize", drawable && ! is_indexed); - SET_SENSITIVE ("drawable-invert", drawable && ! is_indexed); - SET_SENSITIVE ("drawable-levels-stretch", drawable && is_rgb); - SET_SENSITIVE ("drawable-offset", drawable); + SET_SENSITIVE ("drawable-equalize", writable && ! is_indexed); + SET_SENSITIVE ("drawable-invert", writable && ! is_indexed); + SET_SENSITIVE ("drawable-levels-stretch", writable && is_rgb); + SET_SENSITIVE ("drawable-offset", writable); SET_SENSITIVE ("drawable-visible", drawable); SET_SENSITIVE ("drawable-linked", drawable); @@ -196,12 +198,12 @@ drawable_actions_update (GimpActionGroup *group, SET_ACTIVE ("drawable-visible", visible); SET_ACTIVE ("drawable-linked", linked); - SET_SENSITIVE ("drawable-flip-horizontal", drawable); - SET_SENSITIVE ("drawable-flip-vertical", drawable); + SET_SENSITIVE ("drawable-flip-horizontal", writable); + SET_SENSITIVE ("drawable-flip-vertical", writable); - SET_SENSITIVE ("drawable-rotate-90", drawable); - SET_SENSITIVE ("drawable-rotate-180", drawable); - SET_SENSITIVE ("drawable-rotate-270", drawable); + SET_SENSITIVE ("drawable-rotate-90", writable); + SET_SENSITIVE ("drawable-rotate-180", writable); + SET_SENSITIVE ("drawable-rotate-270", writable); #undef SET_SENSITIVE #undef SET_ACTIVE diff --git a/app/actions/edit-actions.c b/app/actions/edit-actions.c index db6b725640..3de8aad9b4 100644 --- a/app/actions/edit-actions.c +++ b/app/actions/edit-actions.c @@ -263,6 +263,7 @@ edit_actions_update (GimpActionGroup *group, gchar *undo_name = NULL; gchar *redo_name = NULL; gchar *fade_name = NULL; + gboolean writable = FALSE; gboolean undo_enabled = FALSE; gboolean fade_enabled = FALSE; @@ -270,6 +271,11 @@ edit_actions_update (GimpActionGroup *group, { 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); if (undo_enabled) @@ -329,22 +335,22 @@ edit_actions_update (GimpActionGroup *group, g_free (redo_name); g_free (fade_name); - SET_SENSITIVE ("edit-cut", drawable); + SET_SENSITIVE ("edit-cut", writable); SET_SENSITIVE ("edit-copy", drawable); 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-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-visible", drawable); - SET_SENSITIVE ("edit-named-paste", image); + SET_SENSITIVE ("edit-named-paste", image && (! drawable || writable)); - SET_SENSITIVE ("edit-clear", drawable); - SET_SENSITIVE ("edit-fill-fg", drawable); - SET_SENSITIVE ("edit-fill-bg", drawable); - SET_SENSITIVE ("edit-fill-pattern", drawable); + SET_SENSITIVE ("edit-clear", writable); + SET_SENSITIVE ("edit-fill-fg", writable); + SET_SENSITIVE ("edit-fill-bg", writable); + SET_SENSITIVE ("edit-fill-pattern", writable); #undef SET_LABEL #undef SET_SENSITIVE diff --git a/app/actions/layers-actions.c b/app/actions/layers-actions.c index 3064e813d1..5e1a9ccb7a 100644 --- a/app/actions/layers-actions.c +++ b/app/actions/layers-actions.c @@ -501,6 +501,7 @@ layers_actions_update (GimpActionGroup *group, gboolean indexed = FALSE; /* is indexed */ gboolean lock_alpha = FALSE; gboolean text_layer = FALSE; + gboolean writable = FALSE; GList *next = NULL; GList *prev = NULL; @@ -521,6 +522,7 @@ layers_actions_update (GimpActionGroup *group, mask = gimp_layer_get_mask (layer); lock_alpha = gimp_layer_get_lock_alpha (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)); @@ -532,8 +534,7 @@ layers_actions_update (GimpActionGroup *group, 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-intersect", text_layer && !ac); - SET_SENSITIVE ("layers-resize", layer && !ac); - SET_SENSITIVE ("layers-resize-to-image", layer && !ac); - SET_SENSITIVE ("layers-scale", layer && !ac); + SET_SENSITIVE ("layers-resize", writable && !ac); + SET_SENSITIVE ("layers-resize-to-image", writable && !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-remove", layer && !fs && alpha); + SET_SENSITIVE ("layers-alpha-add", writable && !fs && !alpha); + SET_SENSITIVE ("layers-alpha-remove", writable && !fs && alpha); SET_SENSITIVE ("layers-lock-alpha", layer); SET_ACTIVE ("layers-lock-alpha", lock_alpha); - SET_SENSITIVE ("layers-mask-add", layer && !fs && !ac && !mask); - SET_SENSITIVE ("layers-mask-apply", layer && !fs && !ac && mask); - SET_SENSITIVE ("layers-mask-delete", layer && !fs && !ac && mask); + SET_SENSITIVE ("layers-mask-add", 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-edit", layer && !fs && !ac && mask); SET_SENSITIVE ("layers-mask-show", layer && !fs && !ac && mask); diff --git a/app/actions/select-actions.c b/app/actions/select-actions.c index e267217eef..89dab5be77 100644 --- a/app/actions/select-actions.c +++ b/app/actions/select-actions.c @@ -137,11 +137,17 @@ select_actions_update (GimpActionGroup *group, GimpDrawable *drawable = NULL; gboolean fs = FALSE; gboolean sel = FALSE; + gboolean writable = FALSE; if (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); 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-none", drawable && sel); 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-sharpen", drawable && sel); @@ -161,8 +167,8 @@ select_actions_update (GimpActionGroup *group, SET_SENSITIVE ("select-border", drawable && sel); SET_SENSITIVE ("select-save", drawable && !fs); - SET_SENSITIVE ("select-stroke", drawable && sel); - SET_SENSITIVE ("select-stroke-last-values", drawable && sel); + SET_SENSITIVE ("select-stroke", writable && sel); + SET_SENSITIVE ("select-stroke-last-values", writable && sel); #undef SET_SENSITIVE } diff --git a/app/actions/vectors-actions.c b/app/actions/vectors-actions.c index 4011758508..d67e2ed9f8 100644 --- a/app/actions/vectors-actions.c +++ b/app/actions/vectors-actions.c @@ -244,6 +244,7 @@ vectors_actions_update (GimpActionGroup *group, gboolean global_buf = FALSE; gboolean visible = FALSE; gboolean linked = FALSE; + gboolean writable = FALSE; GList *next = NULL; GList *prev = NULL; @@ -261,8 +262,9 @@ vectors_actions_update (GimpActionGroup *group, GList *vectors_list; GList *list; - visible = gimp_item_get_visible (item); - linked = gimp_item_get_linked (item); + visible = gimp_item_get_visible (item); + linked = gimp_item_get_linked (item); + writable = ! gimp_item_get_lock_content (item); vectors_list = gimp_item_get_container_iter (item); @@ -281,7 +283,7 @@ vectors_actions_update (GimpActionGroup *group, #define SET_ACTIVE(action,condition) \ 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-new", image);