[gimp] Fix #6026, SF scripts use v3 API for multilayer gimp-edit-copy, -cut, -paste.



commit 1846f9130576e5c9403eb68288d87dd3e4e18e04
Author: lloyd konneker <konnekerl gmail com>
Date:   Fri May 6 16:40:19 2022 -0400

    Fix #6026, SF scripts use v3 API for multilayer gimp-edit-copy, -cut, -paste.
    
    Why: in v3 the signature for gimp-edit-foo PDB procedures changed to support multilayer selection.
    
    This finishes the task for ScriptFu scripts in the GIMP repo.
    This is not a complete list, since some calls were changed incidentally by prior commits.
    You can grep for "edit-copy" etc. in script-fu/scripts to find instances.
    
    This also makes incidental changes, to script calls to plug-in-tile,
    which now also has a changed signature to support multilayer.
    
    The changes are simple code transformations.
    The changes to gimp-edit-paste calls are more complex,
    a mixed bag of a few lines transformed to more lines.
    I did not try to understand the larger logic of the changed plugins.
    I did not test the changed plugins functionally.
    I used a harness to call each changed plugin with improvised parameters,
    only checking that the test plugin did not throw runtime errors,
    not checking that they produced correct images.
    
    As noted in the issue, this might be undone if the original signatures
    for gimp-edit-foo are restored as convenience functions.

 plug-ins/script-fu/scripts/carve-it.scm        | 63 +++++++++++++++++++-------
 plug-ins/script-fu/scripts/chrome-it.scm       | 27 +++++++----
 plug-ins/script-fu/scripts/circuit.scm         | 14 ++++--
 plug-ins/script-fu/scripts/predator.scm        | 10 +++-
 plug-ins/script-fu/scripts/select-to-image.scm |  8 +++-
 plug-ins/script-fu/scripts/tileblur.scm        | 14 ++++--
 plug-ins/script-fu/scripts/unsharp-mask.scm    | 12 +++--
 plug-ins/script-fu/scripts/weave.scm           | 55 +++++++++++++++-------
 8 files changed, 143 insertions(+), 60 deletions(-)
---
diff --git a/plug-ins/script-fu/scripts/carve-it.scm b/plug-ins/script-fu/scripts/carve-it.scm
index 630642d930..8f57d0f1a7 100644
--- a/plug-ins/script-fu/scripts/carve-it.scm
+++ b/plug-ins/script-fu/scripts/carve-it.scm
@@ -25,9 +25,15 @@
   (gimp-drawable-edit-clear dest-drawable)
   (gimp-selection-none dest-image)
   (gimp-selection-all source-image)
-  (gimp-edit-copy source-drawable)
-      (let ((floating-sel (car (gimp-edit-paste dest-drawable FALSE))))
-        (gimp-floating-sel-anchor floating-sel)))
+  (gimp-edit-copy 1 (vector source-drawable))
+  (let* (
+         (pasted (gimp-edit-paste dest-drawable FALSE))
+         (num-pasted (car pasted))
+         (floating-sel (aref (cadr pasted) (- num-pasted 1)))
+        )
+        (gimp-floating-sel-anchor floating-sel)
+  )
+)
 
 
 
@@ -48,7 +54,6 @@
         (feather (carve-scale size 0.3))
         (brush-size (carve-scale size 0.3))
         (brush-name (car (gimp-brush-new "Carve It")))
-        (mask-fs 0)
         (mask (car (gimp-channel-new img width height "Engraving Mask" 50 '(0 0 0))))
         (inset-gamma (calculate-inset-gamma (car (gimp-item-get-image bg-layer)) bg-layer))
         (mask-fat 0)
@@ -80,12 +85,17 @@
     (gimp-selection-none img)
     (copy-layer-carve-it img layer1 bg-image bg-layer)
 
-    (gimp-edit-copy mask-drawable)
+    (gimp-edit-copy 1 (vector mask-drawable))
     (gimp-image-insert-channel img mask -1 0)
 
-    (plug-in-tile RUN-NONINTERACTIVE img layer1 width height FALSE)
-    (set! mask-fs (car (gimp-edit-paste mask FALSE)))
-    (gimp-floating-sel-anchor mask-fs)
+    (plug-in-tile RUN-NONINTERACTIVE img 1 (vector layer1) width height FALSE)
+    (let* (
+           (pasted (gimp-edit-paste mask FALSE))
+           (num-pasted (car pasted))
+           (floating-sel (aref (cadr pasted) (- num-pasted 1)))
+          )
+          (gimp-floating-sel-anchor floating-sel)
+    )
     (if (= carve-white FALSE)
         (gimp-drawable-invert mask FALSE))
 
@@ -133,21 +143,40 @@
                          1.0
                          0.0 1.0 TRUE)
 
-    (gimp-edit-copy mask-shadow)
-    (set! shadow-layer (car (gimp-edit-paste layer1 FALSE)))
-    (gimp-floating-sel-to-layer shadow-layer)
+    (gimp-edit-copy 1 (vector mask-shadow))
+    (let* (
+           (pasted (gimp-edit-paste layer1 FALSE))
+           (num-pasted (car pasted))
+           (floating-sel (aref (cadr pasted) (- num-pasted 1)))
+          )
+          (set! shadow-layer floating-sel)
+          (gimp-floating-sel-to-layer shadow-layer)
+    )
     (gimp-layer-set-mode shadow-layer LAYER-MODE-MULTIPLY)
 
-    (gimp-edit-copy mask-highlight)
-    (set! highlight-layer (car (gimp-edit-paste shadow-layer FALSE)))
-    (gimp-floating-sel-to-layer highlight-layer)
+    (gimp-edit-copy 1 (vector mask-highlight))
+    (let* (
+           (pasted (gimp-edit-paste shadow-layer FALSE))
+           (num-pasted (car pasted))
+           (floating-sel (aref (cadr pasted) (- num-pasted 1)))
+          )
+          (set! highlight-layer floating-sel)
+          (gimp-floating-sel-to-layer highlight-layer)
+    )
     (gimp-layer-set-mode highlight-layer LAYER-MODE-SCREEN)
 
-    (gimp-edit-copy mask)
-    (set! cast-shadow-layer (car (gimp-edit-paste highlight-layer FALSE)))
-    (gimp-floating-sel-to-layer cast-shadow-layer)
+    (gimp-edit-copy 1 (vector mask))
+    (let* (
+           (pasted (gimp-edit-paste highlight-layer FALSE))
+           (num-pasted (car pasted))
+           (floating-sel (aref (cadr pasted) (- num-pasted 1)))
+          )
+          (set! cast-shadow-layer floating-sel)
+          (gimp-floating-sel-to-layer cast-shadow-layer)
+    )
     (gimp-layer-set-mode cast-shadow-layer LAYER-MODE-MULTIPLY)
     (gimp-layer-set-opacity cast-shadow-layer 75)
+
     (plug-in-gauss-rle RUN-NONINTERACTIVE img cast-shadow-layer feather TRUE TRUE)
     (gimp-item-transform-translate cast-shadow-layer offx offy)
 
diff --git a/plug-ins/script-fu/scripts/chrome-it.scm b/plug-ins/script-fu/scripts/chrome-it.scm
index c67fe3aa12..bb27e3d4c7 100644
--- a/plug-ins/script-fu/scripts/chrome-it.scm
+++ b/plug-ins/script-fu/scripts/chrome-it.scm
@@ -64,11 +64,13 @@
     (gimp-drawable-edit-clear dest-drawable)
     (gimp-selection-none dest-image)
     (gimp-selection-all source-image)
-    (gimp-edit-copy source-drawable)
-    (let (
-         (floating-sel (car (gimp-edit-paste dest-drawable FALSE)))
-         )
-         (gimp-floating-sel-anchor floating-sel)
+    (gimp-edit-copy 1 (vector source-drawable))
+    (let* (
+           (pasted (gimp-edit-paste dest-drawable FALSE))
+           (num-pasted (car pasted))
+           (floating-sel (aref (cadr pasted) (- num-pasted 1)))
+          )
+     (gimp-floating-sel-anchor floating-sel)
     )
   )
 
@@ -95,7 +97,6 @@
         (layer2 (car (gimp-layer-new img width height GRAYA-IMAGE _"Layer 2" 100 LAYER-MODE-DIFFERENCE)))
         (layer3 (car (gimp-layer-new img width height GRAYA-IMAGE _"Layer 3" 100 LAYER-MODE-NORMAL)))
         (shadow (car (gimp-layer-new img width height GRAYA-IMAGE _"Drop Shadow" 100 LAYER-MODE-NORMAL)))
-        (mask-fs 0)
         (layer-mask 0)
         )
 
@@ -110,9 +111,17 @@
     (gimp-image-insert-layer img layer3 0 0)
     (gimp-image-insert-layer img layer2 0 0)
 
-    (gimp-edit-copy mask-drawable)
-    (set! mask-fs (car (gimp-edit-paste mask FALSE)))
-    (gimp-floating-sel-anchor mask-fs)
+    (gimp-edit-copy 1 (vector mask-drawable))
+
+    ; Clipboard is copy of mask-drawable.  Paste into mask, a channel, and anchor it.
+    (let* (
+           (pasted (gimp-edit-paste mask FALSE))
+           (num-pasted (car pasted))
+           (floating-sel (aref (cadr pasted) (- num-pasted 1)))
+          )
+     (gimp-floating-sel-anchor floating-sel)
+    )
+
     (if (= carve-white FALSE)
         (gimp-drawable-invert mask FALSE)
     )
diff --git a/plug-ins/script-fu/scripts/circuit.scm b/plug-ins/script-fu/scripts/circuit.scm
index 084e195774..34e3d3bdc6 100644
--- a/plug-ins/script-fu/scripts/circuit.scm
+++ b/plug-ins/script-fu/scripts/circuit.scm
@@ -80,11 +80,15 @@
           (gimp-selection-none image)
           (gimp-drawable-edit-clear effect-layer)
           (gimp-image-select-item image CHANNEL-OP-REPLACE active-selection)
-          (gimp-edit-copy drawable)
-
-          (let ((floating-sel (car (gimp-edit-paste effect-layer FALSE))))
-            (gimp-floating-sel-anchor floating-sel)
-            )
+          (gimp-edit-copy 1 (vector drawable))
+
+          (let* (
+                 (pasted (gimp-edit-paste effect-layer FALSE))
+                 (num-pasted (car pasted))
+                 (floating-sel (aref (cadr pasted) (- num-pasted 1)))
+                )
+           (gimp-floating-sel-anchor floating-sel)
+          )
           (gimp-image-set-active-layer image effect-layer ))
           (set! effect-layer drawable)
     )
diff --git a/plug-ins/script-fu/scripts/predator.scm b/plug-ins/script-fu/scripts/predator.scm
index 119457e3b5..44ede366c6 100644
--- a/plug-ins/script-fu/scripts/predator.scm
+++ b/plug-ins/script-fu/scripts/predator.scm
@@ -85,10 +85,16 @@
           (gimp-drawable-edit-clear effect-layer)
 
           (gimp-image-select-item image CHANNEL-OP-REPLACE active-selection)
-          (gimp-edit-copy drawable)
-          (let ((floating-sel (car (gimp-edit-paste effect-layer FALSE))))
+          (gimp-edit-copy 1 (vector drawable))
+
+          (let* (
+                 (pasted (gimp-edit-paste effect-layer FALSE))
+                 (num-pasted (car pasted))
+                 (floating-sel (aref (cadr pasted) (- num-pasted 1)))
+                 )
             (gimp-floating-sel-anchor floating-sel)
           )
+
           (gimp-image-set-active-layer image effect-layer)
         )
         (set! effect-layer drawable)
diff --git a/plug-ins/script-fu/scripts/select-to-image.scm b/plug-ins/script-fu/scripts/select-to-image.scm
index db8f74f944..8579ef87f9 100644
--- a/plug-ins/script-fu/scripts/select-to-image.scm
+++ b/plug-ins/script-fu/scripts/select-to-image.scm
@@ -54,7 +54,7 @@
         )
     )
 
-    (gimp-edit-copy drawable)
+    (gimp-edit-copy 1 (vector drawable))
 
     (set! new-image (car (gimp-image-new selection-width
                                          selection-height image-type)))
@@ -64,7 +64,11 @@
     (gimp-image-insert-layer new-image new-draw 0 0)
     (gimp-drawable-fill new-draw FILL-BACKGROUND)
 
-    (let ((floating-sel (car (gimp-edit-paste new-draw FALSE))))
+    (let* (
+           (pasted (gimp-edit-paste new-draw FALSE))
+           (num-pasted (car pasted))
+           (floating-sel (aref (cadr pasted) (- num-pasted 1)))
+          )
       (gimp-floating-sel-anchor floating-sel)
     )
 
diff --git a/plug-ins/script-fu/scripts/tileblur.scm b/plug-ins/script-fu/scripts/tileblur.scm
index b937621743..77b1257fa0 100644
--- a/plug-ins/script-fu/scripts/tileblur.scm
+++ b/plug-ins/script-fu/scripts/tileblur.scm
@@ -25,10 +25,14 @@
         )
 
     (define (pasteat xoff yoff)
-      (let ((theFloat (car(gimp-edit-paste theLayer 0))))
-        (gimp-layer-set-offsets theFloat (* xoff theWidth) (* yoff theHeight) )
-        (gimp-floating-sel-anchor theFloat)
-       )
+      (let* (
+             (pasted (gimp-edit-paste theLayer FALSE))
+             (num-pasted (car pasted))
+             (floating-sel (aref (cadr pasted) (- num-pasted 1)))
+            )
+        (gimp-layer-set-offsets floating-sel (* xoff theWidth) (* yoff theHeight) )
+        (gimp-floating-sel-anchor floating-sel)
+      )
     )
 
     (gimp-context-push)
@@ -38,7 +42,7 @@
     (gimp-layer-resize theLayer (* 3 theWidth) (* 3 theHeight) 0 0)
 
     (gimp-image-select-rectangle theImage CHANNEL-OP-REPLACE 0 0 theWidth theHeight)
-    (gimp-edit-cut theLayer)
+    (gimp-edit-cut 1 (vector theLayer))
 
     (gimp-selection-none theImage)
     (gimp-layer-set-offsets theLayer theWidth theHeight)
diff --git a/plug-ins/script-fu/scripts/unsharp-mask.scm b/plug-ins/script-fu/scripts/unsharp-mask.scm
index 421502120d..7af2d50b96 100644
--- a/plug-ins/script-fu/scripts/unsharp-mask.scm
+++ b/plug-ins/script-fu/scripts/unsharp-mask.scm
@@ -21,13 +21,19 @@
         )
 
     (gimp-selection-all img)
-    (gimp-edit-copy drw)
+    (gimp-edit-copy 1 (vector drw))
 
     (gimp-image-undo-disable new-image)
 
     (gimp-image-insert-layer new-image original-layer 0 0)
-    (gimp-floating-sel-anchor
-      (car (gimp-edit-paste original-layer FALSE)))
+
+    (let* (
+           (pasted (gimp-edit-paste original-layer FALSE))
+           (num-pasted (car pasted))
+           (floating-sel (aref (cadr pasted) (- num-pasted 1)))
+          )
+     (gimp-floating-sel-anchor floating-sel)
+    )
 
     (set! original-layer-for-darker (car (gimp-layer-copy original-layer TRUE)))
     (set! original-layer-for-lighter (car (gimp-layer-copy original-layer TRUE)))
diff --git a/plug-ins/script-fu/scripts/weave.scm b/plug-ins/script-fu/scripts/weave.scm
index a6610fb30c..00411f6133 100644
--- a/plug-ins/script-fu/scripts/weave.scm
+++ b/plug-ins/script-fu/scripts/weave.scm
@@ -30,10 +30,15 @@
                         dest-x
                         dest-y)
   (gimp-image-select-rectangle img CHANNEL-OP-REPLACE x1 y1 width height)
-  (gimp-edit-copy drawable)
-  (let ((floating-sel (car (gimp-edit-paste drawable FALSE))))
-    (gimp-layer-set-offsets floating-sel dest-x dest-y)
-    (gimp-floating-sel-anchor floating-sel))
+  (gimp-edit-copy 1 (vector drawable))
+  (let* (
+         (pasted (gimp-edit-paste drawable FALSE))
+         (num-pasted (car pasted))
+         (floating-sel (aref (cadr pasted) (- num-pasted 1)))
+        )
+   (gimp-layer-set-offsets floating-sel dest-x dest-y)
+   (gimp-floating-sel-anchor floating-sel)
+  )
   (gimp-selection-none img))
 
 ; Creates a single weaving tile
@@ -147,7 +152,7 @@
                                   shadow-depth))
          (tile-img (car tile))
          (tile-layer (cadr tile))
-          (weaving (plug-in-tile RUN-NONINTERACTIVE tile-img tile-layer width height TRUE)))
+          (weaving (plug-in-tile RUN-NONINTERACTIVE tile-img 1 (vector tile-layer) width height TRUE)))
     (gimp-image-delete tile-img)
     weaving))
 
@@ -213,7 +218,7 @@
                                  r3-x1 r3-y1 r3-width r3-height))
          (tile-img (car tile))
          (tile-layer (cadr tile))
-         (mask (plug-in-tile RUN-NONINTERACTIVE tile-img tile-layer final-width final-height
+         (mask (plug-in-tile RUN-NONINTERACTIVE tile-img 1 (vector tile-layer) final-width final-height
                              TRUE)))
     (gimp-image-delete tile-img)
     mask))
@@ -320,17 +325,29 @@
 
     (gimp-layer-add-mask h-layer h-mask)
     (gimp-selection-all hm-img)
-    (gimp-edit-copy hm-layer)
+    (gimp-edit-copy 1 (vector hm-layer))
     (gimp-image-delete hm-img)
-    (gimp-floating-sel-anchor (car (gimp-edit-paste h-mask FALSE)))
+    (let* (
+           (pasted (gimp-edit-paste h-mask FALSE))
+           (num-pasted (car pasted))
+           (floating-sel (aref (cadr pasted) (- num-pasted 1)))
+          )
+     (gimp-floating-sel-anchor floating-sel)
+    )
     (gimp-layer-set-opacity h-layer thread-intensity)
     (gimp-layer-set-mode h-layer LAYER-MODE-MULTIPLY)
 
     (gimp-layer-add-mask v-layer v-mask)
     (gimp-selection-all vm-img)
-    (gimp-edit-copy vm-layer)
+    (gimp-edit-copy 1 (vector vm-layer))
     (gimp-image-delete vm-img)
-    (gimp-floating-sel-anchor (car (gimp-edit-paste v-mask FALSE)))
+    (let* (
+           (pasted (gimp-edit-paste v-mask FALSE))
+           (num-pasted (car pasted))
+           (floating-sel (aref (cadr pasted) (- num-pasted 1)))
+          )
+     (gimp-floating-sel-anchor floating-sel)
+    )
     (gimp-layer-set-opacity v-layer thread-intensity)
     (gimp-layer-set-mode v-layer LAYER-MODE-MULTIPLY)
 
@@ -378,14 +395,18 @@
     (gimp-context-set-feather FALSE)
 
     (gimp-selection-all w-img)
-    (gimp-edit-copy w-layer)
+    (gimp-edit-copy 1 (vector w-layer))
     (gimp-image-delete w-img)
-    (let ((floating-sel (car (gimp-edit-paste drawable FALSE))))
-      (gimp-layer-set-offsets floating-sel
-                              (car d-offsets)
-                              (cadr d-offsets))
-      (gimp-layer-set-mode floating-sel LAYER-MODE-MULTIPLY)
-      (gimp-floating-sel-to-layer floating-sel)
+    (let* (
+           (pasted (gimp-edit-paste drawable FALSE))
+           (num-pasted (car pasted))
+           (floating-sel (aref (cadr pasted) (- num-pasted 1)))
+          )
+          (gimp-layer-set-offsets floating-sel
+                                  (car d-offsets)
+                                  (cadr d-offsets))
+          (gimp-layer-set-mode floating-sel LAYER-MODE-MULTIPLY)
+          (gimp-floating-sel-to-layer floating-sel)
     )
   )
   (gimp-context-pop)


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