[gimp] plug-ins: port plug-in-script-fu-eval to GimpBatchProcedure.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: port plug-in-script-fu-eval to GimpBatchProcedure.
- Date: Sat, 16 Apr 2022 16:50:37 +0000 (UTC)
commit 0555a6815e277f5b25f788a9d0bfbb443ccb415d
Author: Jehan <jehan girinstud io>
Date: Sat Apr 16 17:55:35 2022 +0200
plug-ins: port plug-in-script-fu-eval to GimpBatchProcedure.
plug-ins/script-fu/script-fu-eval.c | 7 +--
plug-ins/script-fu/script-fu-eval.h | 2 +
plug-ins/script-fu/script-fu.c | 119 ++++++++++++++++++++++--------------
3 files changed, 77 insertions(+), 51 deletions(-)
---
diff --git a/plug-ins/script-fu/script-fu-eval.c b/plug-ins/script-fu/script-fu-eval.c
index 95112c3d57..ec160992dd 100644
--- a/plug-ins/script-fu/script-fu-eval.c
+++ b/plug-ins/script-fu/script-fu-eval.c
@@ -27,15 +27,12 @@
GimpValueArray *
script_fu_eval_run (GimpProcedure *procedure,
+ GimpRunMode run_mode,
+ const gchar *code,
const GimpValueArray *args)
{
GString *output = g_string_new (NULL);
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
- GimpRunMode run_mode;
- const gchar *code;
-
- run_mode = GIMP_VALUES_GET_ENUM (args, 0);
- code = GIMP_VALUES_GET_STRING (args, 1);
ts_set_run_mode (run_mode);
ts_register_output_func (ts_gstring_output_func, output);
diff --git a/plug-ins/script-fu/script-fu-eval.h b/plug-ins/script-fu/script-fu-eval.h
index 0288efe0c0..17cea41232 100644
--- a/plug-ins/script-fu/script-fu-eval.h
+++ b/plug-ins/script-fu/script-fu-eval.h
@@ -20,6 +20,8 @@
GimpValueArray * script_fu_eval_run (GimpProcedure *procedure,
+ GimpRunMode run_mode,
+ const gchar *code,
const GimpValueArray *args);
diff --git a/plug-ins/script-fu/script-fu.c b/plug-ins/script-fu/script-fu.c
index 50abb926a0..5dd8e90aac 100644
--- a/plug-ins/script-fu/script-fu.c
+++ b/plug-ins/script-fu/script-fu.c
@@ -64,6 +64,13 @@ static GimpProcedure * script_fu_create_procedure (GimpPlugIn *plug_i
static GimpValueArray * script_fu_run (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
+static GimpValueArray * script_fu_batch_run (GimpProcedure *procedure,
+ GimpRunMode run_mode,
+ const gchar *code,
+ const GimpValueArray *args,
+ gpointer run_data);
+static void script_fu_run_init (GimpProcedure *procedure,
+ GimpRunMode run_mode);
static GList * script_fu_search_path (void);
static void script_fu_extension_init (GimpPlugIn *plug_in);
static GimpValueArray * script_fu_refresh_proc (GimpProcedure *procedure,
@@ -236,9 +243,9 @@ script_fu_create_procedure (GimpPlugIn *plug_in,
}
else if (! strcmp (name, "plug-in-script-fu-eval"))
{
- procedure = gimp_procedure_new (plug_in, name,
- GIMP_PDB_PROC_TYPE_PLUGIN,
- script_fu_run, NULL, NULL);
+ procedure = gimp_batch_procedure_new (plug_in, name,
+ GIMP_PDB_PROC_TYPE_PLUGIN,
+ script_fu_batch_run, NULL, NULL);
gimp_procedure_set_documentation (procedure,
"Evaluate scheme code",
@@ -249,19 +256,6 @@ script_fu_create_procedure (GimpPlugIn *plug_in,
"Manish Singh",
"Manish Singh",
"1998");
-
- GIMP_PROC_ARG_ENUM (procedure, "run-mode",
- "Run mode",
- "The run mode",
- GIMP_TYPE_RUN_MODE,
- GIMP_RUN_INTERACTIVE,
- G_PARAM_READWRITE);
-
- GIMP_PROC_ARG_STRING (procedure, "code",
- "Code",
- "The code to run",
- NULL,
- G_PARAM_READWRITE);
}
return procedure;
@@ -275,36 +269,11 @@ script_fu_run (GimpProcedure *procedure,
GimpPlugIn *plug_in = gimp_procedure_get_plug_in (procedure);
const gchar *name = gimp_procedure_get_name (procedure);
GimpValueArray *return_vals = NULL;
- GList *path;
-
- INIT_I18N();
-
- path = script_fu_search_path ();
-
- /* Determine before we allow scripts to register themselves
- * whether this is the base, automatically installed script-fu extension
- */
- if (strcmp (name, "extension-script-fu") == 0)
- {
- /* Setup auxiliary temporary procedures for the base extension */
- script_fu_extension_init (plug_in);
-
- /* Init the interpreter and register scripts */
- tinyscheme_init (path, TRUE);
- }
- else
- {
- /* Init the interpreter */
- tinyscheme_init (path, FALSE);
- }
if (gimp_value_array_length (args) > 0)
- ts_set_run_mode (GIMP_VALUES_GET_ENUM (args, 0));
-
- /* Load all of the available scripts */
- script_fu_find_scripts (plug_in, path);
-
- g_list_free_full (path, (GDestroyNotify) g_object_unref);
+ script_fu_run_init (procedure, GIMP_VALUES_GET_ENUM (args, 0));
+ else
+ script_fu_run_init (procedure, GIMP_RUN_NONINTERACTIVE);
if (strcmp (name, "extension-script-fu") == 0)
{
@@ -343,13 +312,34 @@ script_fu_run (GimpProcedure *procedure,
return_vals = script_fu_server_run (procedure, args);
}
- else if (strcmp (name, "plug-in-script-fu-eval") == 0)
+
+ if (! return_vals)
+ return_vals = gimp_procedure_new_return_values (procedure,
+ GIMP_PDB_SUCCESS,
+ NULL);
+
+ return return_vals;
+}
+
+static GimpValueArray *
+script_fu_batch_run (GimpProcedure *procedure,
+ GimpRunMode run_mode,
+ const gchar *code,
+ const GimpValueArray *args,
+ gpointer run_data)
+{
+ const gchar *name = gimp_procedure_get_name (procedure);
+ GimpValueArray *return_vals = NULL;
+
+ script_fu_run_init (procedure, run_mode);
+
+ if (strcmp (name, "plug-in-script-fu-eval") == 0)
{
/*
* A non-interactive "console" (for batch mode)
*/
- return_vals = script_fu_eval_run (procedure, args);
+ return_vals = script_fu_eval_run (procedure, run_mode, code, args);
}
if (! return_vals)
@@ -360,6 +350,43 @@ script_fu_run (GimpProcedure *procedure,
return return_vals;
}
+static void
+script_fu_run_init (GimpProcedure *procedure,
+ GimpRunMode run_mode)
+{
+ GimpPlugIn *plug_in = gimp_procedure_get_plug_in (procedure);
+ const gchar *name = gimp_procedure_get_name (procedure);
+ GList *path;
+
+ INIT_I18N();
+
+ path = script_fu_search_path ();
+
+ /* Determine before we allow scripts to register themselves
+ * whether this is the base, automatically installed script-fu extension
+ */
+ if (strcmp (name, "extension-script-fu") == 0)
+ {
+ /* Setup auxiliary temporary procedures for the base extension */
+ script_fu_extension_init (plug_in);
+
+ /* Init the interpreter and register scripts */
+ tinyscheme_init (path, TRUE);
+ }
+ else
+ {
+ /* Init the interpreter */
+ tinyscheme_init (path, FALSE);
+ }
+
+ ts_set_run_mode (run_mode);
+
+ /* Load all of the available scripts */
+ script_fu_find_scripts (plug_in, path);
+
+ g_list_free_full (path, (GDestroyNotify) g_object_unref);
+}
+
static GList *
script_fu_search_path (void)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]