[gimp] app: rename procedure_commands_run_procedure()



commit 9d502791d03815da61e72be6d540a2fcf2f580e9
Author: Michael Natterer <mitch gimp org>
Date:   Tue May 30 00:12:22 2017 +0200

    app: rename procedure_commands_run_procedure()
    
    to procedure_commands_run_procedure_async(). Add a new
    procedure_commands_run_procedure() that calls the procedure
    synchronously, needed later.

 app/actions/filters-commands.c   |   16 +++++++-------
 app/actions/plug-in-commands.c   |    8 +++---
 app/actions/procedure-commands.c |   41 +++++++++++++++++++++++++++++++++++--
 app/actions/procedure-commands.h |    6 ++++-
 4 files changed, 55 insertions(+), 16 deletions(-)
---
diff --git a/app/actions/filters-commands.c b/app/actions/filters-commands.c
index 87d2a10..168d598 100644
--- a/app/actions/filters-commands.c
+++ b/app/actions/filters-commands.c
@@ -85,10 +85,10 @@ filters_repeat_cmd_callback (GtkAction *action,
 
       if (args)
         {
-          if (procedure_commands_run_procedure (procedure, gimp,
-                                                GIMP_PROGRESS (display),
-                                                run_mode, args,
-                                                display))
+          if (procedure_commands_run_procedure_async (procedure, gimp,
+                                                      GIMP_PROGRESS (display),
+                                                      run_mode, args,
+                                                      display))
             {
               gimp_filter_history_add (gimp, procedure);
             }
@@ -113,10 +113,10 @@ filters_history_cmd_callback (GtkAction     *action,
 
   if (args)
     {
-      if (procedure_commands_run_procedure (procedure, gimp,
-                                            GIMP_PROGRESS (display),
-                                            GIMP_RUN_INTERACTIVE, args,
-                                            display))
+      if (procedure_commands_run_procedure_async (procedure, gimp,
+                                                  GIMP_PROGRESS (display),
+                                                  GIMP_RUN_INTERACTIVE, args,
+                                                  display))
         {
           gimp_filter_history_add (gimp, procedure);
         }
diff --git a/app/actions/plug-in-commands.c b/app/actions/plug-in-commands.c
index ddb4511..dd47e23 100644
--- a/app/actions/plug-in-commands.c
+++ b/app/actions/plug-in-commands.c
@@ -141,10 +141,10 @@ plug_in_run_cmd_callback (GtkAction     *action,
 
   if (args)
     {
-      if (procedure_commands_run_procedure (procedure, gimp,
-                                            GIMP_PROGRESS (display),
-                                            GIMP_RUN_INTERACTIVE, args,
-                                            display))
+      if (procedure_commands_run_procedure_async (procedure, gimp,
+                                                  GIMP_PROGRESS (display),
+                                                  GIMP_RUN_INTERACTIVE, args,
+                                                  display))
         {
           /* remember only image plug-ins */
           if (procedure->num_args >= 2 &&
diff --git a/app/actions/procedure-commands.c b/app/actions/procedure-commands.c
index 40300a2..114aac7 100644
--- a/app/actions/procedure-commands.c
+++ b/app/actions/procedure-commands.c
@@ -258,9 +258,44 @@ gboolean
 procedure_commands_run_procedure (GimpProcedure  *procedure,
                                   Gimp           *gimp,
                                   GimpProgress   *progress,
-                                  GimpRunMode     run_mode,
-                                  GimpValueArray *args,
-                                  GimpDisplay    *display)
+                                  GimpValueArray *args)
+{
+  GimpValueArray *return_vals;
+  GError         *error = NULL;
+
+  g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), FALSE);
+  g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
+  g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE);
+  g_return_val_if_fail (args != NULL, FALSE);
+
+  g_value_set_int (gimp_value_array_index (args, 0), GIMP_RUN_NONINTERACTIVE);
+
+  return_vals = gimp_procedure_execute (procedure, gimp,
+                                        gimp_get_user_context (gimp),
+                                        progress, args,
+                                        &error);
+  gimp_value_array_unref (return_vals);
+
+  if (error)
+    {
+      gimp_message_literal (gimp,
+                            G_OBJECT (progress), GIMP_MESSAGE_ERROR,
+                            error->message);
+      g_clear_error (&error);
+
+      return FALSE;
+    }
+
+  return TRUE;
+}
+
+gboolean
+procedure_commands_run_procedure_async (GimpProcedure  *procedure,
+                                        Gimp           *gimp,
+                                        GimpProgress   *progress,
+                                        GimpRunMode     run_mode,
+                                        GimpValueArray *args,
+                                        GimpDisplay    *display)
 {
   GError *error = NULL;
 
diff --git a/app/actions/procedure-commands.h b/app/actions/procedure-commands.h
index 59747c9..04df990 100644
--- a/app/actions/procedure-commands.h
+++ b/app/actions/procedure-commands.h
@@ -31,7 +31,11 @@ GimpValueArray * procedure_commands_get_display_args (GimpProcedure  *procedure,
                                                       GimpDisplay    *display,
                                                       GimpObject     *settings);
 
-gboolean         procedure_commands_run_procedure    (GimpProcedure  *procedure,
+gboolean      procedure_commands_run_procedure       (GimpProcedure  *procedure,
+                                                      Gimp           *gimp,
+                                                      GimpProgress   *progress,
+                                                      GimpValueArray *args);
+gboolean      procedure_commands_run_procedure_async (GimpProcedure  *procedure,
                                                       Gimp           *gimp,
                                                       GimpProgress   *progress,
                                                       GimpRunMode     run_mode,


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