[gimp] app: layers-merge-group multi-layer aware.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: layers-merge-group multi-layer aware.
- Date: Thu, 21 May 2020 13:10:36 +0000 (UTC)
commit ae4abbabfdcebe90ddef65e2892d37fad502a593
Author: Jehan <jehan girinstud io>
Date: Thu May 21 15:06:48 2020 +0200
app: layers-merge-group multi-layer aware.
Also layers-flatten-image does not care about the layer selection and
layers-anchor works anyway only when there is a floating selection,
which means only one layer selected.
app/actions/layers-actions.c | 12 +++++-----
app/actions/layers-commands.c | 54 +++++++++++++++++++++++++++++++++++++------
2 files changed, 53 insertions(+), 13 deletions(-)
---
diff --git a/app/actions/layers-actions.c b/app/actions/layers-actions.c
index f6681719dd..275803ea9e 100644
--- a/app/actions/layers-actions.c
+++ b/app/actions/layers-actions.c
@@ -187,8 +187,8 @@ static const GimpActionEntry layers_actions[] =
GIMP_HELP_LAYER_MERGE_DOWN },
{ "layers-merge-group", NULL,
- NC_("layers-action", "Merge Layer Group"), NULL,
- NC_("layers-action", "Merge the layer group's layers into one normal layer"),
+ NC_("layers-action", "Merge Layer Groups"), NULL,
+ NC_("layers-action", "Merge the layer groups' layers into one normal layer"),
layers_merge_group_cmd_callback,
GIMP_HELP_LAYER_MERGE_GROUP },
@@ -1035,15 +1035,15 @@ layers_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("layers-lower", n_layers > 0 && !fs && !ac && have_next);
SET_SENSITIVE ("layers-lower-to-bottom", n_layers > 0 && !fs && !ac && have_next);
- SET_VISIBLE ("layers-anchor", layer && fs && !ac);
+ SET_VISIBLE ("layers-anchor", fs && !ac);
SET_VISIBLE ("layers-merge-down", !fs);
SET_SENSITIVE ("layers-merge-down", layer && !fs && !ac && visible && next_visible);
SET_VISIBLE ("layers-merge-down-button", !fs);
SET_SENSITIVE ("layers-merge-down-button", layer && !fs && !ac);
- SET_VISIBLE ("layers-merge-group", children);
- SET_SENSITIVE ("layers-merge-group", layer && !fs && !ac && children);
+ SET_VISIBLE ("layers-merge-group", have_groups);
+ SET_SENSITIVE ("layers-merge-group", n_layers && !fs && !ac && have_groups);
SET_SENSITIVE ("layers-merge-layers", n_layers > 0 && !fs && !ac);
- SET_SENSITIVE ("layers-flatten-image", layer && !fs && !ac);
+ SET_SENSITIVE ("layers-flatten-image", !fs && !ac);
SET_VISIBLE ("layers-text-discard", text_layer && !ac);
SET_VISIBLE ("layers-text-to-vectors", text_layer && !ac);
diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c
index aa886278b5..4b5b69af95 100644
--- a/app/actions/layers-commands.c
+++ b/app/actions/layers-commands.c
@@ -805,12 +805,13 @@ layers_anchor_cmd_callback (GimpAction *action,
gpointer data)
{
GimpImage *image;
- GimpLayer *layer;
- return_if_no_layer (image, layer, data);
+ GList *layers;
+ return_if_no_layers (image, layers, data);
- if (gimp_layer_is_floating_sel (layer))
+ if (g_list_length (layers) == 1 &&
+ gimp_layer_is_floating_sel (layers->data))
{
- floating_sel_anchor (layer);
+ floating_sel_anchor (layers->data);
gimp_image_flush (image);
}
}
@@ -838,10 +839,49 @@ layers_merge_group_cmd_callback (GimpAction *action,
gpointer data)
{
GimpImage *image;
- GimpLayer *layer;
- return_if_no_layer (image, layer, data);
+ GList *layers;
+ GList *merge_layers = NULL;
+ GList *iter;
+ return_if_no_layers (image, layers, data);
+
+ for (iter = layers; iter; iter = iter->next)
+ {
+ if (gimp_viewable_get_children (GIMP_VIEWABLE (iter->data)))
+ {
+ GList *iter2;
+
+ for (iter2 = layers; iter2; iter2 = iter2->next)
+ {
+ /* Do not merge a layer when we already merge one of its
+ * ancestors.
+ */
+ if (gimp_item_is_ancestor (iter->data, iter2->data))
+ break;
+ }
+
+ if (iter2 == NULL)
+ merge_layers = g_list_prepend (merge_layers, iter->data);
+ }
+ }
+
+ if (g_list_length (merge_layers) > 1)
+ {
+ gchar *undo_name;
+
+ undo_name = g_strdup_printf (C_("undo-type", "Merge %d Layer Groups"),
+ g_list_length (merge_layers));
+ gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_LAYERS_MERGE,
+ undo_name);
+ g_free (undo_name);
+ }
+
+ for (iter = merge_layers; iter; iter = iter->next)
+ gimp_image_merge_group_layer (image, GIMP_GROUP_LAYER (iter->data));
+
+ if (g_list_length (merge_layers) > 1)
+ gimp_image_undo_group_end (image);
- gimp_image_merge_group_layer (image, GIMP_GROUP_LAYER (layer));
+ g_list_free (merge_layers);
gimp_image_flush (image);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]