Commit bf7d5557 authored by Jehan's avatar Jehan

app: edit-clear multi-layers aware.

parent 62eedd41
Pipeline #200397 passed with stages
in 27 minutes and 15 seconds
......@@ -295,11 +295,28 @@ edit_actions_update (GimpActionGroup *group,
gboolean children = FALSE;
gboolean undo_enabled = FALSE;
gboolean have_no_groups = FALSE; /* At least 1 selected layer is not a group. */
gboolean have_writable = FALSE; /* At least 1 selected layer has no contents lock. */
if (image)
{
GList *iter;
drawables = gimp_image_get_selected_drawables (image);
drawable = gimp_image_get_active_drawable (image);
for (iter = drawables; iter; iter = iter->next)
{
if (! gimp_viewable_get_children (GIMP_VIEWABLE (iter->data)))
have_no_groups = TRUE;
if (! gimp_item_is_content_locked (GIMP_ITEM (iter->data)))
have_writable = TRUE;
if (have_no_groups && have_writable)
break;
}
if (drawable)
{
writable = ! gimp_item_is_content_locked (GIMP_ITEM (drawable));
......@@ -372,7 +389,7 @@ edit_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("edit-named-copy-visible", drawable);
/* "edit-named-paste" is always active */
SET_SENSITIVE ("edit-clear", writable && !children);
SET_SENSITIVE ("edit-clear", have_writable && have_no_groups);
SET_SENSITIVE ("edit-fill-fg", writable && !children);
SET_SENSITIVE ("edit-fill-bg", writable && !children);
SET_SENSITIVE ("edit-fill-pattern", writable && !children);
......
......@@ -482,15 +482,28 @@ edit_clear_cmd_callback (GimpAction *action,
GVariant *value,
gpointer data)
{
GimpImage *image;
GimpDrawable *drawable;
return_if_no_drawable (image, drawable, data);
GimpImage *image;
GList *drawables;
GList *iter;
if (! check_drawable_alpha (drawable, data))
return;
return_if_no_drawables (image, drawables, data);
gimp_drawable_edit_clear (drawable, action_data_get_context (data));
for (iter = drawables; iter; iter = iter->next)
/* Return if any has a locked alpha. */
if (! check_drawable_alpha (iter->data, data))
return;
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_PAINT,
_("Clear"));
for (iter = drawables; iter; iter = iter->next)
if (! gimp_viewable_get_children (GIMP_VIEWABLE (iter->data)) &&
! gimp_item_is_content_locked (GIMP_ITEM (iter->data)))
gimp_drawable_edit_clear (iter->data, action_data_get_context (data));
gimp_image_undo_group_end (image);
gimp_image_flush (image);
g_list_free (drawables);
}
void
......
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