[gimp] Bug 625167 - Problem exporting floating selections from within layer groups
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 625167 - Problem exporting floating selections from within layer groups
- Date: Mon, 14 Feb 2011 08:51:03 +0000 (UTC)
commit 02477f556333fcccd5ff3afd18f977ea8155d6a1
Author: Michael Natterer <mitch gimp org>
Date: Mon Feb 14 09:45:59 2011 +0100
Bug 625167 - Problem exporting floating selections from within layer groups
Add "gboolean merge_active_group" to gimp_image_merge_visible_layers()
and pass FALSE from the PDB wrapper so plug-in invoked layer merging
always acts on the toplevel container as it did in 2.6. Do the same
when opening an image as layer.
Also, added a "Merge within active group only" toggle to the merge
layers dialog and pass it down to the core, but default to TRUE here
so.
app/actions/image-commands.c | 18 +++++++++------
app/core/gimpimage-merge.c | 37 ++++++++++++++++++------------
app/core/gimpimage-merge.h | 1 +
app/dialogs/image-merge-layers-dialog.c | 23 ++++++++++++++++--
app/dialogs/image-merge-layers-dialog.h | 2 +
app/file/file-open.c | 3 +-
app/pdb/image-cmds.c | 3 +-
tools/pdbgen/pdb/image.pdb | 3 +-
8 files changed, 62 insertions(+), 28 deletions(-)
---
diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c
index f826b93..2526b1e 100644
--- a/app/actions/image-commands.c
+++ b/app/actions/image-commands.c
@@ -109,11 +109,12 @@ static void image_merge_layers_response (GtkWidget *widget,
/* private variables */
-static GimpMergeType image_merge_layers_type = GIMP_EXPAND_AS_NECESSARY;
-static gboolean image_merge_layers_discard_invisible = FALSE;
-static GimpUnit image_resize_unit = GIMP_UNIT_PIXEL;
-static GimpUnit image_scale_unit = GIMP_UNIT_PIXEL;
-static GimpInterpolationType image_scale_interp = -1;
+static GimpMergeType image_merge_layers_type = GIMP_EXPAND_AS_NECESSARY;
+static gboolean image_merge_layers_merge_active_group = TRUE;
+static gboolean image_merge_layers_discard_invisible = FALSE;
+static GimpUnit image_resize_unit = GIMP_UNIT_PIXEL;
+static GimpUnit image_scale_unit = GIMP_UNIT_PIXEL;
+static GimpInterpolationType image_scale_interp = -1;
/* public functions */
@@ -471,6 +472,7 @@ image_merge_layers_cmd_callback (GtkAction *action,
action_data_get_context (data),
widget,
image_merge_layers_type,
+ image_merge_layers_merge_active_group,
image_merge_layers_discard_invisible);
g_signal_connect (dialog->dialog, "response",
@@ -703,12 +705,14 @@ image_merge_layers_response (GtkWidget *widget,
{
if (response_id == GTK_RESPONSE_OK)
{
- image_merge_layers_type = dialog->merge_type;
- image_merge_layers_discard_invisible = dialog->discard_invisible;
+ image_merge_layers_type = dialog->merge_type;
+ image_merge_layers_merge_active_group = dialog->merge_active_group;
+ image_merge_layers_discard_invisible = dialog->discard_invisible;
gimp_image_merge_visible_layers (dialog->image,
dialog->context,
image_merge_layers_type,
+ image_merge_layers_merge_active_group,
image_merge_layers_discard_invisible);
gimp_image_flush (dialog->image);
diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c
index 1a327ab..edb5d17 100644
--- a/app/core/gimpimage-merge.c
+++ b/app/core/gimpimage-merge.c
@@ -63,9 +63,9 @@ GimpLayer *
gimp_image_merge_visible_layers (GimpImage *image,
GimpContext *context,
GimpMergeType merge_type,
+ gboolean merge_active_group,
gboolean discard_invisible)
{
- GimpLayer *active_layer;
GimpContainer *container;
GList *list;
GSList *merge_list = NULL;
@@ -74,25 +74,32 @@ gimp_image_merge_visible_layers (GimpImage *image,
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
- active_layer = gimp_image_get_active_layer (image);
-
- /* if the active layer is the floating selection, get the underlying
- * drawable, but only if it is a layer
- */
- if (active_layer && gimp_layer_is_floating_sel (active_layer))
+ if (merge_active_group)
{
- GimpDrawable *fs_drawable;
+ GimpLayer *active_layer = gimp_image_get_active_layer (image);
- fs_drawable = gimp_layer_get_floating_sel_drawable (active_layer);
+ /* if the active layer is the floating selection, get the
+ * underlying drawable, but only if it is a layer
+ */
+ if (active_layer && gimp_layer_is_floating_sel (active_layer))
+ {
+ GimpDrawable *fs_drawable;
- if (GIMP_IS_LAYER (fs_drawable))
- active_layer = GIMP_LAYER (fs_drawable);
- }
+ fs_drawable = gimp_layer_get_floating_sel_drawable (active_layer);
+
+ if (GIMP_IS_LAYER (fs_drawable))
+ active_layer = GIMP_LAYER (fs_drawable);
+ }
- if (active_layer)
- container = gimp_item_get_container (GIMP_ITEM (active_layer));
+ if (active_layer)
+ container = gimp_item_get_container (GIMP_ITEM (active_layer));
+ else
+ container = gimp_image_get_layers (image);
+ }
else
- container = gimp_image_get_layers (image);
+ {
+ container = gimp_image_get_layers (image);
+ }
for (list = gimp_item_stack_get_item_iter (GIMP_ITEM_STACK (container));
list;
diff --git a/app/core/gimpimage-merge.h b/app/core/gimpimage-merge.h
index 423a44a..35bdce1 100644
--- a/app/core/gimpimage-merge.h
+++ b/app/core/gimpimage-merge.h
@@ -22,6 +22,7 @@
GimpLayer * gimp_image_merge_visible_layers (GimpImage *image,
GimpContext *context,
GimpMergeType merge_type,
+ gboolean merge_active_group,
gboolean discard_invisible);
GimpLayer * gimp_image_merge_down (GimpImage *image,
GimpLayer *current_layer,
diff --git a/app/dialogs/image-merge-layers-dialog.c b/app/dialogs/image-merge-layers-dialog.c
index 00f3ed9..db98a6f 100644
--- a/app/dialogs/image-merge-layers-dialog.c
+++ b/app/dialogs/image-merge-layers-dialog.c
@@ -26,6 +26,7 @@
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
+#include "core/gimpitemstack.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpviewabledialog.h"
@@ -43,6 +44,7 @@ image_merge_layers_dialog_new (GimpImage *image,
GimpContext *context,
GtkWidget *parent,
GimpMergeType merge_type,
+ gboolean merge_active_group,
gboolean discard_invisible)
{
ImageMergeLayersDialog *dialog;
@@ -55,9 +57,11 @@ image_merge_layers_dialog_new (GimpImage *image,
dialog = g_slice_new0 (ImageMergeLayersDialog);
- dialog->image = image;
- dialog->context = context;
- dialog->merge_type = GIMP_EXPAND_AS_NECESSARY;
+ dialog->image = image;
+ dialog->context = context;
+ dialog->merge_type = GIMP_EXPAND_AS_NECESSARY;
+ dialog->merge_active_group = merge_active_group;
+ dialog->discard_invisible = discard_invisible;
dialog->dialog =
gimp_viewable_dialog_new (GIMP_VIEWABLE (image), context,
@@ -107,6 +111,19 @@ image_merge_layers_dialog_new (GimpImage *image,
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
+ button = gtk_check_button_new_with_mnemonic (_("Merge within active _group only"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
+ dialog->merge_active_group);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_widget_show (button);
+
+ g_signal_connect (button, "toggled",
+ G_CALLBACK (gimp_toggle_button_update),
+ &dialog->merge_active_group);
+
+ if (gimp_item_stack_is_flat (GIMP_ITEM_STACK (gimp_image_get_layers (image))))
+ gtk_widget_set_sensitive (button, FALSE);
+
button = gtk_check_button_new_with_mnemonic (_("_Discard invisible layers"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
dialog->discard_invisible);
diff --git a/app/dialogs/image-merge-layers-dialog.h b/app/dialogs/image-merge-layers-dialog.h
index ef2e7df..1271fd7 100644
--- a/app/dialogs/image-merge-layers-dialog.h
+++ b/app/dialogs/image-merge-layers-dialog.h
@@ -28,6 +28,7 @@ struct _ImageMergeLayersDialog
GimpImage *image;
GimpContext *context;
GimpMergeType merge_type;
+ gboolean merge_active_group;
gboolean discard_invisible;
};
@@ -37,6 +38,7 @@ ImageMergeLayersDialog *
GimpContext *context,
GtkWidget *parent,
GimpMergeType merge_type,
+ gboolean merge_active_group,
gboolean discard_invisible);
diff --git a/app/file/file-open.c b/app/file/file-open.c
index 4d2c1f8..4982f81 100644
--- a/app/file/file-open.c
+++ b/app/file/file-open.c
@@ -500,7 +500,8 @@ file_open_layers (Gimp *gimp,
g_list_free (layers);
layer = gimp_image_merge_visible_layers (new_image, context,
- GIMP_CLIP_TO_IMAGE, FALSE);
+ GIMP_CLIP_TO_IMAGE,
+ FALSE, FALSE);
layers = g_list_prepend (NULL, layer);
}
diff --git a/app/pdb/image-cmds.c b/app/pdb/image-cmds.c
index 120a6f2..4c35c60 100644
--- a/app/pdb/image-cmds.c
+++ b/app/pdb/image-cmds.c
@@ -1440,7 +1440,8 @@ image_merge_visible_layers_invoker (GimpProcedure *procedure,
if (success)
{
- layer = gimp_image_merge_visible_layers (image, context, merge_type, FALSE);
+ layer = gimp_image_merge_visible_layers (image, context, merge_type,
+ FALSE, FALSE);
if (! layer)
success = FALSE;
diff --git a/tools/pdbgen/pdb/image.pdb b/tools/pdbgen/pdb/image.pdb
index 66819be..6c4edf5 100644
--- a/tools/pdbgen/pdb/image.pdb
+++ b/tools/pdbgen/pdb/image.pdb
@@ -942,7 +942,8 @@ HELP
headers => [ qw("core/gimpimage-merge.h") ],
code => <<'CODE'
{
- layer = gimp_image_merge_visible_layers (image, context, merge_type, FALSE);
+ layer = gimp_image_merge_visible_layers (image, context, merge_type,
+ FALSE, FALSE);
if (! layer)
success = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]