[gimp] plug-ins: port python-fu-eval to GimpBatchProcedure.



commit 752cbd137776e4941bcd87ee888eba358fb0498f
Author: Jehan <jehan girinstud io>
Date:   Sat Apr 16 17:11:31 2022 +0200

    plug-ins: port python-fu-eval to GimpBatchProcedure.

 plug-ins/python/python-eval.py | 27 ++++-----------------------
 1 file changed, 4 insertions(+), 23 deletions(-)
---
diff --git a/plug-ins/python/python-eval.py b/plug-ins/python/python-eval.py
index 966671e7de..c0b51a0338 100644
--- a/plug-ins/python/python-eval.py
+++ b/plug-ins/python/python-eval.py
@@ -26,15 +26,7 @@ from gi.repository import Gio
 import sys
 
 
-def code_eval(procedure, args, data):
-
-    # Get the parameters
-    if args.length() != 1:
-        error = 'No parameters given'
-        return procedure.new_return_values(Gimp.PDBStatusType.CALLING_ERROR,
-                                           GLib.Error(error))
-
-    code = args.index(0)
+def code_eval(procedure, run_mode, code, args, data):
     if code == '-':
         code = sys.stdin.read()
     exec(code, globals())
@@ -42,15 +34,6 @@ def code_eval(procedure, args, data):
 
 
 class PythonEval (Gimp.PlugIn):
-    ## Parameters ##
-    __gproperties__ = {
-        "code": (str,
-                 "Python code to evaluate, or '-' to read from stdin",
-                 "Python code to evaluate, or '-' to read from stdin",
-                 "",
-                 GObject.ParamFlags.READWRITE)
-    }
-
     ## GimpPlugIn virtual methods ##
     def do_query_procedures(self):
         self.set_translation_domain("gimp30-python",
@@ -59,9 +42,9 @@ class PythonEval (Gimp.PlugIn):
         return ['python-fu-eval']
 
     def do_create_procedure(self, name):
-        procedure = Gimp.Procedure.new(self, name,
-                                       Gimp.PDBProcType.PLUGIN,
-                                       code_eval, None)
+        procedure = Gimp.BatchProcedure.new(self, name,
+                                            Gimp.PDBProcType.PLUGIN,
+                                            code_eval, None)
         procedure.set_documentation ("Evaluate Python code",
                                      "Evaluate python code under the python interpreter (primarily for batch 
mode)",
                                      name)
@@ -70,8 +53,6 @@ class PythonEval (Gimp.PlugIn):
                                   "Manish Singh",
                                   "2006")
 
-        procedure.add_argument_from_property(self, "code")
-
         return procedure
 
 


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