[gimp] script-fu: in weave, improve context and undo management



commit 806d260601ebe707fbd42de665268a3d537c0a6f
Author: Thomas Manni <thomas manni free fr>
Date:   Wed May 16 21:34:33 2018 +0200

    script-fu: in weave, improve context and undo management
    
    Use a gimp-context-push/pop at the beginning/end of the script
    to keep the current context unchanged.
    
    Add undo support for the whole procedure.

 plug-ins/script-fu/scripts/weave.scm |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/plug-ins/script-fu/scripts/weave.scm b/plug-ins/script-fu/scripts/weave.scm
index edf5778..586ada9 100644
--- a/plug-ins/script-fu/scripts/weave.scm
+++ b/plug-ins/script-fu/scripts/weave.scm
@@ -351,6 +351,9 @@
                          thread-length
                          thread-density
                          thread-intensity)
+  (gimp-context-push)
+  (gimp-image-undo-group-start img)
+
   (let* (
         (d-img (car (gimp-item-get-image drawable)))
         (d-width (car (gimp-drawable-width drawable)))
@@ -370,7 +373,6 @@
         (w-layer (cadr weaving))
         )
 
-    (gimp-context-push)
     (gimp-context-set-paint-mode LAYER-MODE-NORMAL)
     (gimp-context-set-opacity 100.0)
     (gimp-context-set-feather FALSE)
@@ -385,11 +387,10 @@
       (gimp-layer-set-mode floating-sel LAYER-MODE-MULTIPLY)
       (gimp-floating-sel-to-layer floating-sel)
     )
-
-    (gimp-displays-flush)
-
-    (gimp-context-pop)
   )
+  (gimp-context-pop)
+  (gimp-image-undo-group-end img)
+  (gimp-displays-flush)
 )
 
 (script-fu-register "script-fu-weave"


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