[gimp] app: make gimp_edit_paste() do what its told to do
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: make gimp_edit_paste() do what its told to do
- Date: Fri, 23 Sep 2016 14:49:58 +0000 (UTC)
commit 88b60e99471486ccca5efa963f1342a14625cc5a
Author: Michael Natterer <mitch gimp org>
Date: Fri Sep 23 16:40:11 2016 +0200
app: make gimp_edit_paste() do what its told to do
Don't change the paste_type to NEW_LAYER just because there is a
complex thing in the clipboard. Instead, honor the request to paste
FLOATING or FLOATING_INTO and reduce the pasted thing to a simple flat
layer. Also remove the message and paste_type change from edit_paste()
in edit-commands.c, it had the same purpose, just with a user
notification.
In order to paste the full layer one needs to explicitly invoke
"Paste as new layer" now.
It still changes the paste_type to NEW_LAYER if it's impossible to
attach a floating selection to the target, the menu item was simply
insensitive before.
app/actions/edit-commands.c | 11 --------
app/core/gimp-edit.c | 59 ++++++++++++++++++++++++++++++++----------
2 files changed, 45 insertions(+), 25 deletions(-)
---
diff --git a/app/actions/edit-commands.c b/app/actions/edit-commands.c
index f624bcf..3ab77be 100644
--- a/app/actions/edit-commands.c
+++ b/app/actions/edit-commands.c
@@ -571,17 +571,6 @@ edit_paste (GimpDisplay *display,
gint x, y;
gint width, height;
- if (GIMP_IS_IMAGE (paste) &&
- paste_type != GIMP_PASTE_TYPE_NEW_LAYER)
- {
- gimp_message_literal (display->gimp, G_OBJECT (display),
- GIMP_MESSAGE_INFO,
- _("Pasted as new layer because "
- "there was a layer the clipboard."));
-
- paste_type = GIMP_PASTE_TYPE_NEW_LAYER;
- }
-
if (drawable)
{
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)))
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index 9c08251..ff0e476 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -340,13 +340,56 @@ gimp_edit_paste (GimpImage *image,
gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (paste) || GIMP_IS_BUFFER (paste), NULL);
+ /* change paste type to NEW_LAYER for cases where we can't attach a
+ * floating selection
+ */
+ if (! drawable ||
+ gimp_viewable_get_children (GIMP_VIEWABLE (drawable)) ||
+ gimp_item_is_content_locked (GIMP_ITEM (drawable)))
+ {
+ paste_type = GIMP_PASTE_TYPE_NEW_LAYER;
+ }
+
if (GIMP_IS_IMAGE (paste))
{
+ GType layer_type;
+
layer = gimp_image_get_layer_iter (GIMP_IMAGE (paste))->data;
+ switch (paste_type)
+ {
+ case GIMP_PASTE_TYPE_FLOATING:
+ case GIMP_PASTE_TYPE_FLOATING_INTO:
+ /* when pasting as floating selection, force creation of a
+ * plain layer, so gimp_item_convert() will collapse a
+ * group layer
+ */
+ layer_type = GIMP_TYPE_LAYER;
+ break;
+
+ case GIMP_PASTE_TYPE_NEW_LAYER:
+ layer_type = G_TYPE_FROM_INSTANCE (layer);
+ break;
+
+ default:
+ g_return_val_if_reached (NULL);
+ }
+
layer = GIMP_LAYER (gimp_item_convert (GIMP_ITEM (layer),
- image,
- G_TYPE_FROM_INSTANCE (layer)));
+ image, layer_type));
+
+ switch (paste_type)
+ {
+ case GIMP_PASTE_TYPE_FLOATING:
+ case GIMP_PASTE_TYPE_FLOATING_INTO:
+ /* when pasting as floating selection, get rid of the layer mask */
+ if (gimp_layer_get_mask (layer))
+ gimp_layer_apply_mask (layer, GIMP_MASK_DISCARD, FALSE);
+ break;
+
+ default:
+ break;
+ }
}
else
{
@@ -374,20 +417,8 @@ gimp_edit_paste (GimpImage *image,
viewport_height,
&offset_x,
&offset_y);
-
gimp_item_set_offset (GIMP_ITEM (layer), offset_x, offset_y);
- /* change paste type to NEW_LAYER for cases where we can't attach
- * a floating selection
- */
- if (GIMP_IS_IMAGE (paste) ||
- ! drawable ||
- gimp_viewable_get_children (GIMP_VIEWABLE (drawable)) ||
- gimp_item_is_content_locked (GIMP_ITEM (drawable)))
- {
- paste_type = GIMP_PASTE_TYPE_NEW_LAYER;
- }
-
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_EDIT_PASTE,
C_("undo-type", "Paste"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]