Separate checks for "writable" from "is group" when setting sensitivity

This commit is contained in:
Michael Natterer 2009-08-29 12:51:58 +02:00
parent 957cf2cfa9
commit 85c6af5d42
4 changed files with 42 additions and 28 deletions

View File

@ -203,10 +203,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", 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-equalize", writable && !children && !is_indexed);
SET_SENSITIVE ("drawable-invert", writable && !children && !is_indexed);
SET_SENSITIVE ("drawable-levels-stretch", writable && !children && is_rgb);
SET_SENSITIVE ("drawable-offset", writable && !children);
SET_SENSITIVE ("drawable-visible", drawable);
SET_SENSITIVE ("drawable-linked", drawable);
@ -216,12 +216,12 @@ drawable_actions_update (GimpActionGroup *group,
SET_ACTIVE ("drawable-linked", linked);
SET_ACTIVE ("drawable-lock-content", locked);
SET_SENSITIVE ("drawable-flip-horizontal", writable || children);
SET_SENSITIVE ("drawable-flip-vertical", writable || children);
SET_SENSITIVE ("drawable-flip-horizontal", writable);
SET_SENSITIVE ("drawable-flip-vertical", writable);
SET_SENSITIVE ("drawable-rotate-90", writable || children);
SET_SENSITIVE ("drawable-rotate-180", writable || children);
SET_SENSITIVE ("drawable-rotate-270", writable || children);
SET_SENSITIVE ("drawable-rotate-90", writable);
SET_SENSITIVE ("drawable-rotate-180", writable);
SET_SENSITIVE ("drawable-rotate-270", writable);
#undef SET_SENSITIVE
#undef SET_ACTIVE

View File

@ -264,6 +264,7 @@ edit_actions_update (GimpActionGroup *group,
gchar *redo_name = NULL;
gchar *fade_name = NULL;
gboolean writable = FALSE;
gboolean children = FALSE;
gboolean undo_enabled = FALSE;
gboolean fade_enabled = FALSE;
@ -274,6 +275,9 @@ edit_actions_update (GimpActionGroup *group,
if (drawable)
{
writable = ! gimp_item_get_lock_content (GIMP_ITEM (drawable));
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)))
children = TRUE;
}
undo_enabled = gimp_image_undo_is_enabled (image);
@ -335,22 +339,25 @@ edit_actions_update (GimpActionGroup *group,
g_free (redo_name);
g_free (fade_name);
SET_SENSITIVE ("edit-cut", writable);
SET_SENSITIVE ("edit-cut", writable && !children);
SET_SENSITIVE ("edit-copy", drawable);
SET_SENSITIVE ("edit-copy-visible", image);
SET_SENSITIVE ("edit-paste", ! image || (! drawable || writable));
SET_SENSITIVE ("edit-paste", !image || (!drawable ||
(writable && !children)));
SET_SENSITIVE ("edit-paste-as-new-layer", image);
SET_SENSITIVE ("edit-paste-into", image && (! drawable || writable));
SET_SENSITIVE ("edit-paste-into", image && (!drawable ||
(writable && !children)));
SET_SENSITIVE ("edit-named-cut", writable);
SET_SENSITIVE ("edit-named-cut", writable && !children);
SET_SENSITIVE ("edit-named-copy", drawable);
SET_SENSITIVE ("edit-named-copy-visible", drawable);
SET_SENSITIVE ("edit-named-paste", image && (! drawable || writable));
SET_SENSITIVE ("edit-named-paste", image && (!drawable ||
(writable && !children)));
SET_SENSITIVE ("edit-clear", writable);
SET_SENSITIVE ("edit-fill-fg", writable);
SET_SENSITIVE ("edit-fill-bg", writable);
SET_SENSITIVE ("edit-fill-pattern", writable);
SET_SENSITIVE ("edit-clear", writable && !children);
SET_SENSITIVE ("edit-fill-fg", writable && !children);
SET_SENSITIVE ("edit-fill-bg", writable && !children);
SET_SENSITIVE ("edit-fill-pattern", writable && !children);
#undef SET_LABEL
#undef SET_SENSITIVE

View File

@ -546,8 +546,11 @@ layers_actions_update (GimpActionGroup *group,
{
if (gimp_item_get_visible (next_visible->data))
{
/* next_visible is actually next_visible_and_writable */
if (gimp_item_get_lock_content (next_visible->data))
/* next_visible is actually next_visible and
* writable not group
*/
if (gimp_item_get_lock_content (next_visible->data) ||
gimp_viewable_get_children (next_visible->data))
next_visible = NULL;
break;
@ -600,20 +603,20 @@ 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", (writable || children) && !ac);
SET_SENSITIVE ("layers-resize", writable && !ac);
SET_SENSITIVE ("layers-resize-to-image", writable && !ac);
SET_SENSITIVE ("layers-scale", (writable || children) && !ac);
SET_SENSITIVE ("layers-scale", writable && !ac);
SET_SENSITIVE ("layers-crop", (writable || children) && sel);
SET_SENSITIVE ("layers-crop", writable && sel);
SET_SENSITIVE ("layers-alpha-add", writable && !fs && !alpha);
SET_SENSITIVE ("layers-alpha-remove", writable && !fs && alpha);
SET_SENSITIVE ("layers-alpha-add", writable && !children && !fs && !alpha);
SET_SENSITIVE ("layers-alpha-remove", writable && !children && !fs && alpha);
SET_SENSITIVE ("layers-lock-alpha", can_lock_alpha);
SET_ACTIVE ("layers-lock-alpha", lock_alpha);
SET_SENSITIVE ("layers-mask-add", layer && !fs && !ac && !mask);
SET_SENSITIVE ("layers-mask-apply", writable && !fs && !ac && mask);
SET_SENSITIVE ("layers-mask-apply", writable && !fs && !ac && mask && !children);
SET_SENSITIVE ("layers-mask-delete", layer && !fs && !ac && mask);
SET_SENSITIVE ("layers-mask-edit", layer && !fs && !ac && mask);

View File

@ -133,11 +133,12 @@ void
select_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpImage *image = action_data_get_image (data);
GimpImage *image = action_data_get_image (data);
GimpDrawable *drawable = NULL;
gboolean fs = FALSE;
gboolean sel = FALSE;
gboolean writable = FALSE;
gboolean children = FALSE;
if (image)
{
@ -146,6 +147,9 @@ select_actions_update (GimpActionGroup *group,
if (drawable)
{
writable = ! gimp_item_get_lock_content (GIMP_ITEM (drawable));
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)))
children = TRUE;
}
fs = (gimp_image_get_floating_selection (image) != NULL);
@ -158,7 +162,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", writable && sel);
SET_SENSITIVE ("select-float", writable && !children && sel);
SET_SENSITIVE ("select-feather", drawable && sel);
SET_SENSITIVE ("select-sharpen", drawable && sel);