[gimp] ScriptFu: scripts use v3 API for multilayer gimp_image_get_selected_drawables etc.



commit 974f694cd22bb54e91b990cf8cf13985f317b796
Author: lloyd konneker <konnekerl gmail com>
Date:   Tue Aug 2 16:40:08 2022 -0400

    ScriptFu: scripts use v3 API for multilayer gimp_image_get_selected_drawables etc.
    
    Commit a6aba929 deleted the old functions.
    
    Misc drive-by fixes for gtk_adjustment step not < pages
    
    Issue #8155 discusses alternative fixes, convenience functions for compatibility in ScriptFu.
    There is one compat function defined already in ScriptFu, temporarily: gimp-image-get-active-drawable
    which was written so that testing clothify-v3.scm could proceed.

 plug-ins/script-fu/scripts/add-bevel.scm          | 4 ++--
 plug-ins/script-fu/scripts/chrome-it.scm          | 4 ++--
 plug-ins/script-fu/scripts/circuit.scm            | 4 ++--
 plug-ins/script-fu/scripts/clothify.scm           | 2 +-
 plug-ins/script-fu/scripts/contactsheet.scm       | 9 +++++----
 plug-ins/script-fu/scripts/font-map.scm           | 2 +-
 plug-ins/script-fu/scripts/line-nova.scm          | 2 --
 plug-ins/script-fu/scripts/paste-as-brush.scm     | 4 ++--
 plug-ins/script-fu/scripts/paste-as-pattern.scm   | 2 +-
 plug-ins/script-fu/scripts/perspective-shadow.scm | 2 +-
 plug-ins/script-fu/scripts/predator.scm           | 4 ++--
 plug-ins/script-fu/scripts/round-corners.scm      | 2 +-
 plug-ins/script-fu/scripts/script-fu-util.scm     | 2 +-
 plug-ins/script-fu/scripts/select-to-image.scm    | 2 +-
 plug-ins/script-fu/scripts/slide.scm              | 2 +-
 plug-ins/script-fu/scripts/spinning-globe.scm     | 2 +-
 plug-ins/script-fu/scripts/waves-anim.scm         | 2 +-
 plug-ins/script-fu/scripts/xach-effect.scm        | 2 +-
 18 files changed, 26 insertions(+), 27 deletions(-)
---
diff --git a/plug-ins/script-fu/scripts/add-bevel.scm b/plug-ins/script-fu/scripts/add-bevel.scm
index e063b9509b..75089c0b7b 100644
--- a/plug-ins/script-fu/scripts/add-bevel.scm
+++ b/plug-ins/script-fu/scripts/add-bevel.scm
@@ -63,7 +63,7 @@
         (thickness (abs thickness))
         (type (car (gimp-drawable-type-with-alpha drawable)))
         (image (if (= work-on-copy TRUE) (car (gimp-image-duplicate img)) img))
-        (pic-layer (car (gimp-image-get-active-drawable image)))
+        (pic-layer (aref (cadr (gimp-image-get-selected-drawables image)) 0))
         (offsets (gimp-drawable-get-offsets pic-layer))
         (width (car (gimp-drawable-get-width pic-layer)))
         (height (car (gimp-drawable-get-height pic-layer)))
@@ -168,7 +168,7 @@
         (gimp-image-remove-layer image bump-layer)
     )
 
-    (gimp-image-set-active-layer image pic-layer)
+    (gimp-image-set-selected-layers image 1 (vector pic-layer))
 
     ; enable undo / end undo group
     (if (= work-on-copy TRUE)
diff --git a/plug-ins/script-fu/scripts/chrome-it.scm b/plug-ins/script-fu/scripts/chrome-it.scm
index bb27e3d4c7..6e0d174701 100644
--- a/plug-ins/script-fu/scripts/chrome-it.scm
+++ b/plug-ins/script-fu/scripts/chrome-it.scm
@@ -76,7 +76,7 @@
 
   (let* (
         (banding-img (car (gimp-file-load RUN-NONINTERACTIVE env-map)))
-        (banding-layer (car (gimp-image-get-active-drawable banding-img)))
+        (banding-layer (aref (cadr (gimp-image-get-selected-drawables banding-img)) 0))
         (banding-height (car (gimp-drawable-get-height banding-layer)))
         (banding-width (car (gimp-drawable-get-width banding-layer)))
         (banding-type (car (gimp-drawable-type banding-layer)))
@@ -248,7 +248,7 @@
   SF-DRAWABLE    "Chrome mask"       0
   SF-ADJUSTMENT _"Chrome saturation" '(-80 -100 100 1 10 0 0)
   SF-ADJUSTMENT _"Chrome lightness"  '(-47 -100 100 1 10 0 0)
-  SF-ADJUSTMENT _"Chrome factor"     '(0.75 0 1 0.1 0.01 2 0)
+  SF-ADJUSTMENT _"Chrome factor"     '(0.75 0 1 0.1 0.2 2 0)
   SF-FILENAME   _"Environment map"
                 (string-append gimp-data-directory
                               "/scripts/images/beavis.jpg")
diff --git a/plug-ins/script-fu/scripts/circuit.scm b/plug-ins/script-fu/scripts/circuit.scm
index 34e3d3bdc6..547f0311ce 100644
--- a/plug-ins/script-fu/scripts/circuit.scm
+++ b/plug-ins/script-fu/scripts/circuit.scm
@@ -89,7 +89,7 @@
                 )
            (gimp-floating-sel-anchor floating-sel)
           )
-          (gimp-image-set-active-layer image effect-layer ))
+          (gimp-image-set-selected-layers image 1 (vector effect-layer)))
           (set! effect-layer drawable)
     )
     (set! active-layer effect-layer)
@@ -117,7 +117,7 @@
         (gimp-selection-none image))
 
     (gimp-image-remove-channel image active-selection)
-    (gimp-image-set-active-layer image drawable)
+    (gimp-image-set-selected-layers image 1 (vector drawable))
 
     (gimp-image-undo-group-end image)
 
diff --git a/plug-ins/script-fu/scripts/clothify.scm b/plug-ins/script-fu/scripts/clothify.scm
index 8be61b4a01..e5f7533302 100644
--- a/plug-ins/script-fu/scripts/clothify.scm
+++ b/plug-ins/script-fu/scripts/clothify.scm
@@ -34,7 +34,7 @@
     (plug-in-gauss-rle RUN-NONINTERACTIVE img layer-one bx TRUE FALSE)
     (plug-in-gauss-rle RUN-NONINTERACTIVE img layer-two by FALSE TRUE)
     (gimp-image-flatten img)
-    (set! bump-layer (car (gimp-image-get-active-layer img)))
+    (set! bump-layer (aref (cadr (gimp-image-get-selected-layers img)) 0))
 
     (plug-in-c-astretch RUN-NONINTERACTIVE img bump-layer)
     (plug-in-noisify RUN-NONINTERACTIVE img bump-layer FALSE 0.2 0.2 0.2 0.2)
diff --git a/plug-ins/script-fu/scripts/contactsheet.scm b/plug-ins/script-fu/scripts/contactsheet.scm
index 04034ff732..0d5961710a 100644
--- a/plug-ins/script-fu/scripts/contactsheet.scm
+++ b/plug-ins/script-fu/scripts/contactsheet.scm
@@ -112,7 +112,7 @@
           (text-height 0)
           )
       (gimp-selection-all img)
-      (gimp-drawable-fill (car (gimp-image-get-active-layer img))
+      (gimp-drawable-fill (aref (cadr (gimp-image-get-selected-layers img)) 0)
                           FILL-BACKGROUND)
       (gimp-selection-none img)
       (set! text-layer (car (gimp-text-fontname img -1 0 0
@@ -227,9 +227,10 @@
               (if (> (car (gimp-image-get-layers new-img)) 1)
                 (gimp-image-flatten new-img)
               )
-              (set! tmp-layer (car (gimp-layer-new-from-drawable
-                            (car (gimp-image-get-active-drawable new-img))
-                                  sheet-img)))
+              (set! tmp-layer
+                (car (gimp-layer-new-from-drawable
+                        (aref (cadr (gimp-image-get-selected-drawables new-img)) 0)
+                        sheet-img)))
 
               (gimp-image-insert-layer sheet-img tmp-layer 0 0)
 
diff --git a/plug-ins/script-fu/scripts/font-map.scm b/plug-ins/script-fu/scripts/font-map.scm
index b3b64fe4b1..7bf3228bb9 100644
--- a/plug-ins/script-fu/scripts/font-map.scm
+++ b/plug-ins/script-fu/scripts/font-map.scm
@@ -148,7 +148,7 @@
       (set! count (+ count 1))
     )
 
-    (gimp-image-set-active-layer img drawable)
+    (gimp-image-set-selected-layers img 1 (vector drawable))
 
     (gimp-image-undo-enable img)
     (gimp-display-new img)
diff --git a/plug-ins/script-fu/scripts/line-nova.scm b/plug-ins/script-fu/scripts/line-nova.scm
index d6931b18e1..1408238922 100644
--- a/plug-ins/script-fu/scripts/line-nova.scm
+++ b/plug-ins/script-fu/scripts/line-nova.scm
@@ -92,8 +92,6 @@
     (if old-selection
       (begin
         (gimp-image-select-item img CHANNEL-OP-REPLACE old-selection)
-        ;; (gimp-image-set-active-layer img drw)
-        ;; delete extra channel by Sven Neumann <neumanns uni-duesseldorf de>
         (gimp-image-remove-channel img old-selection)
       )
     )
diff --git a/plug-ins/script-fu/scripts/paste-as-brush.scm b/plug-ins/script-fu/scripts/paste-as-brush.scm
index 555e731ad1..cef3f7893b 100644
--- a/plug-ins/script-fu/scripts/paste-as-brush.scm
+++ b/plug-ins/script-fu/scripts/paste-as-brush.scm
@@ -27,7 +27,7 @@
 
     (if (= TRUE (car (gimp-image-is-valid brush-image)))
       (begin
-        (set! brush-draw (car (gimp-image-get-active-drawable brush-image)))
+        (set! brush-draw (aref (cadr (gimp-image-get-selected-drawables brush-image)) 0))
         (set! type (car (gimp-drawable-type brush-draw)))
         (set! path (string-append gimp-directory
                                   "/brushes/"
@@ -69,7 +69,7 @@
   ""
   SF-STRING     _"_Brush name" "My Brush"
   SF-STRING     _"_File name"  "mybrush"
-  SF-ADJUSTMENT _"_Spacing"    '(25 0 1000 1 1 1 0)
+  SF-ADJUSTMENT _"_Spacing"    '(25 0 1000 1 2 1 0)
 )
 
 (script-fu-menu-register "script-fu-paste-as-brush"
diff --git a/plug-ins/script-fu/scripts/paste-as-pattern.scm b/plug-ins/script-fu/scripts/paste-as-pattern.scm
index 5f4f2f75a9..e070bbf6aa 100644
--- a/plug-ins/script-fu/scripts/paste-as-pattern.scm
+++ b/plug-ins/script-fu/scripts/paste-as-pattern.scm
@@ -25,7 +25,7 @@
 
     (if (= TRUE (car (gimp-image-is-valid pattern-image)))
       (begin
-        (set! pattern-draw (car (gimp-image-get-active-drawable pattern-image)))
+        (set! pattern-draw (aref (cadr (gimp-image-get-selected-drawables pattern-image)) 0))
         (set! path (string-append gimp-directory
                              "/patterns/"
                              filename
diff --git a/plug-ins/script-fu/scripts/perspective-shadow.scm 
b/plug-ins/script-fu/scripts/perspective-shadow.scm
index 3f5412dfaa..05cafaa5f2 100644
--- a/plug-ins/script-fu/scripts/perspective-shadow.scm
+++ b/plug-ins/script-fu/scripts/perspective-shadow.scm
@@ -185,7 +185,7 @@
           (= from-selection FALSE))
       (gimp-image-raise-item image drawable))
 
-    (gimp-image-set-active-layer image drawable)
+    (gimp-image-set-selected-layers image 1 (vector drawable))
     (gimp-image-undo-group-end image)
     (gimp-displays-flush)
 
diff --git a/plug-ins/script-fu/scripts/predator.scm b/plug-ins/script-fu/scripts/predator.scm
index 44ede366c6..d1fba8dde2 100644
--- a/plug-ins/script-fu/scripts/predator.scm
+++ b/plug-ins/script-fu/scripts/predator.scm
@@ -95,7 +95,7 @@
             (gimp-floating-sel-anchor floating-sel)
           )
 
-          (gimp-image-set-active-layer image effect-layer)
+          (gimp-image-set-selected-layers image 1 (vector effect-layer))
         )
         (set! effect-layer drawable)
     )
@@ -115,7 +115,7 @@
         (gimp-selection-none image)
     )
 
-    (gimp-image-set-active-layer image drawable)
+    (gimp-image-set-selected-layers image 1 (vector drawable))
     (gimp-image-remove-channel image active-selection)
     (gimp-image-undo-group-end image)
     (gimp-displays-flush)
diff --git a/plug-ins/script-fu/scripts/round-corners.scm b/plug-ins/script-fu/scripts/round-corners.scm
index a5224e5c32..5d344185fa 100644
--- a/plug-ins/script-fu/scripts/round-corners.scm
+++ b/plug-ins/script-fu/scripts/round-corners.scm
@@ -56,7 +56,7 @@
                       ((= work-on-copy FALSE)
                        img)))
          ; active drawable is not necessarily the active layer
-         (pic-layer (car (gimp-image-get-active-layer image)))
+         (pic-layer (aref (cadr (gimp-image-get-selected-layers image)) 0))
          (type (car (gimp-drawable-type-with-alpha pic-layer)))
         )
 
diff --git a/plug-ins/script-fu/scripts/script-fu-util.scm b/plug-ins/script-fu/scripts/script-fu-util.scm
index b67fa67d52..bcbe3753dd 100644
--- a/plug-ins/script-fu/scripts/script-fu-util.scm
+++ b/plug-ins/script-fu/scripts/script-fu-util.scm
@@ -79,7 +79,7 @@
            (let* ((filename (car ,filenames))
                   (image (catch #f (car (gimp-file-load RUN-NONINTERACTIVE
                                                         filename))))
-                  (layer (if image (car (gimp-image-get-active-layer image)) #f))
+                  (layer (if image (aref (cadr (gimp-image-get-selected-layers image)) 0) #f))
                   (basename (unbreakupstr (butlast (strbreakup filename ".")) ".")))
              (when image
                ,@body
diff --git a/plug-ins/script-fu/scripts/select-to-image.scm b/plug-ins/script-fu/scripts/select-to-image.scm
index 8579ef87f9..f6340072ed 100644
--- a/plug-ins/script-fu/scripts/select-to-image.scm
+++ b/plug-ins/script-fu/scripts/select-to-image.scm
@@ -73,7 +73,7 @@
     )
 
     (gimp-image-undo-enable image)
-    (gimp-image-set-active-layer image drawable)
+    (gimp-image-set-selected-layers image 1 (vector drawable))
     (gimp-display-new new-image)
     (gimp-displays-flush)
 
diff --git a/plug-ins/script-fu/scripts/slide.scm b/plug-ins/script-fu/scripts/slide.scm
index dae1a6921f..48c47f2671 100644
--- a/plug-ins/script-fu/scripts/slide.scm
+++ b/plug-ins/script-fu/scripts/slide.scm
@@ -91,7 +91,7 @@
                                        "Background"
                                        100
                                        LAYER-MODE-NORMAL)))
-        (pic-layer (car (gimp-image-get-active-drawable image)))
+        (pic-layer (aref (cadr (gimp-image-get-selected-drawables image)) 0))
         (numbera (string-append number "A"))
         )
 
diff --git a/plug-ins/script-fu/scripts/spinning-globe.scm b/plug-ins/script-fu/scripts/spinning-globe.scm
index f3a2ad0339..df683a59f4 100644
--- a/plug-ins/script-fu/scripts/spinning-globe.scm
+++ b/plug-ins/script-fu/scripts/spinning-globe.scm
@@ -31,7 +31,7 @@
         (theImage (if (= inCopy TRUE)
                       (car (gimp-image-duplicate inImage))
                       inImage))
-        (theLayer (car (gimp-image-get-active-layer theImage)))
+        (theLayer (aref (cadr (gimp-image-get-selected-layers theImage)) 0))
         (n 0)
         (ang (* (/ 360 inFrames)
                 (if (= inFromLeft TRUE) 1 -1) ))
diff --git a/plug-ins/script-fu/scripts/waves-anim.scm b/plug-ins/script-fu/scripts/waves-anim.scm
index 4e43d983ff..b12afb7d41 100644
--- a/plug-ins/script-fu/scripts/waves-anim.scm
+++ b/plug-ins/script-fu/scripts/waves-anim.scm
@@ -41,7 +41,7 @@
          (phase 0)
          (phaseshift (/ 360 num-frames))
          (image (car (gimp-image-duplicate img)))
-         (source-layer (car (gimp-image-get-active-layer image))))
+         (source-layer (aref (cadr (gimp-image-get-selected-layers image)) 0)))
 
   (gimp-image-undo-disable image)
 
diff --git a/plug-ins/script-fu/scripts/xach-effect.scm b/plug-ins/script-fu/scripts/xach-effect.scm
index 6e44a3be55..e9b59fd407 100644
--- a/plug-ins/script-fu/scripts/xach-effect.scm
+++ b/plug-ins/script-fu/scripts/xach-effect.scm
@@ -108,7 +108,7 @@
     (if (= keep-selection FALSE)
         (gimp-selection-none image))
 
-    (gimp-image-set-active-layer image drawable)
+    (gimp-image-set-selected-layers image 1 (vector drawable))
     (gimp-image-remove-channel image active-selection)
     (gimp-image-undo-group-end image)
     (gimp-displays-flush)


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