[gimp] app: fix position of pasted layers in gimp_edit_paste()



commit 1d76d085c91f1448ea2c90e03099dd9692c145ca
Author: Michael Natterer <mitch gimp org>
Date:   Wed Sep 21 11:15:34 2016 +0200

    app: fix position of pasted layers in gimp_edit_paste()
    
    and make that code more readable.

 app/core/gimp-edit.c |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index bd139a9..9c08251 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -408,14 +408,21 @@ gimp_edit_paste (GimpImage     *image,
       break;
 
     case GIMP_PASTE_TYPE_NEW_LAYER:
-      /* always add on top of the drawable or the active layer, where
-       * we would attach a floating selection
-       */
-      gimp_image_add_layer (image, layer,
-                            GIMP_IS_LAYER (drawable) ?
-                            GIMP_LAYER (gimp_item_get_parent (GIMP_ITEM (drawable))) :
-                            NULL,
-                            -1, TRUE);
+      {
+        GimpLayer *parent   = NULL;
+        gint       position = 0;
+
+        /* always add on top of the passed layer, where we would
+         * attach a floating selection
+         */
+        if (GIMP_IS_LAYER (drawable))
+          {
+            parent   = gimp_layer_get_parent (GIMP_LAYER (drawable));
+            position = gimp_item_get_index (GIMP_ITEM (drawable));
+          }
+
+        gimp_image_add_layer (image, layer, parent, position, TRUE);
+      }
       break;
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]