[gimp] libgimp: add run_data and run_data_destroy parameters to procedure_new()



commit e0a6eb38dac35995297055d816aa580d855192b9
Author: Michael Natterer <mitch gimp org>
Date:   Thu Aug 1 22:45:49 2019 +0200

    libgimp: add run_data and run_data_destroy parameters to procedure_new()
    
    so bindings work properly. Change plug-ins accordingly.

 libgimp/gimpprocedure.c         | 26 +++++++++++++++++++-------
 libgimp/gimpprocedure.h         |  7 +++++--
 plug-ins/common/goat-exercise.c | 10 ++++++----
 plug-ins/help/help.c            | 17 +++++++++++------
 4 files changed, 41 insertions(+), 19 deletions(-)
---
diff --git a/libgimp/gimpprocedure.c b/libgimp/gimpprocedure.c
index 1a76f241fc..dfb1dd588e 100644
--- a/libgimp/gimpprocedure.c
+++ b/libgimp/gimpprocedure.c
@@ -80,6 +80,8 @@ struct _GimpProcedurePrivate
   GParamSpec      **values;         /* Array of return values         */
 
   GimpRunFunc       run_func;
+  gpointer          run_data;
+  GDestroyNotify    run_data_destroy;
 };
 
 
@@ -119,6 +121,9 @@ gimp_procedure_finalize (GObject *object)
   GimpProcedure *procedure = GIMP_PROCEDURE (object);
   gint           i;
 
+  if (procedure->priv->run_data_destroy)
+    procedure->priv->run_data_destroy (procedure->priv->run_data);
+
   g_clear_object  (&procedure->priv->plug_in);
   g_clear_pointer (&procedure->priv->name, g_free);
 
@@ -157,7 +162,9 @@ gimp_procedure_finalize (GObject *object)
  * @plug_in:   a #GimpPlugIn.
  * @name:      the new procedure's name.
  * @proc_type: the new procedure's #GimpPDBProcType.
- * @run_func: (scope async): the run function for the new procedure.
+ * @run_func:  the run function for the new procedure.
+ * @run_data:  user data passed to @run_func.
+ * @run_data_destroy: (nullable) free function for @run_data, or %NULL.
  *
  * Creates a new procedure named @name which will call @run_func when
  * invoked.
@@ -168,7 +175,9 @@ GimpProcedure  *
 gimp_procedure_new (GimpPlugIn      *plug_in,
                     const gchar     *name,
                     GimpPDBProcType  proc_type,
-                    GimpRunFunc      run_func)
+                    GimpRunFunc      run_func,
+                    gpointer         run_data,
+                    GDestroyNotify   run_data_destroy)
 {
   GimpProcedure *procedure;
 
@@ -179,10 +188,12 @@ gimp_procedure_new (GimpPlugIn      *plug_in,
 
   procedure = g_object_new (GIMP_TYPE_PROCEDURE, NULL);
 
-  procedure->priv->plug_in   = g_object_ref (plug_in);
-  procedure->priv->proc_type = proc_type;
-  procedure->priv->name      = g_strdup (name);
-  procedure->priv->run_func  = run_func;
+  procedure->priv->plug_in           = g_object_ref (plug_in);
+  procedure->priv->proc_type         = proc_type;
+  procedure->priv->name              = g_strdup (name);
+  procedure->priv->run_func          = run_func;
+  procedure->priv->run_data          = run_data;
+  procedure->priv->run_data_destroy  = run_data_destroy;
 
   return procedure;
 }
@@ -569,7 +580,8 @@ gimp_procedure_run (GimpProcedure   *procedure,
     }
 
   /*  call the procedure  */
-  return_vals = procedure->priv->run_func (procedure, args);
+  return_vals = procedure->priv->run_func (procedure, args,
+                                           procedure->priv->run_data);
 
   if (! return_vals)
     {
diff --git a/libgimp/gimpprocedure.h b/libgimp/gimpprocedure.h
index 0b123b9f58..44d4af0450 100644
--- a/libgimp/gimpprocedure.h
+++ b/libgimp/gimpprocedure.h
@@ -32,7 +32,8 @@ G_BEGIN_DECLS
 
 
 typedef GimpValueArray * (* GimpRunFunc) (GimpProcedure        *procedure,
-                                          const GimpValueArray *args);
+                                          const GimpValueArray *args,
+                                          gpointer              run_data);
 
 
 #define GIMP_TYPE_PROCEDURE            (gimp_procedure_get_type ())
@@ -64,7 +65,9 @@ GType            gimp_procedure_get_type           (void) G_GNUC_CONST;
 GimpProcedure  * gimp_procedure_new                (GimpPlugIn        *plug_in,
                                                     const gchar       *name,
                                                     GimpPDBProcType    proc_type,
-                                                    GimpRunFunc        run_func);
+                                                    GimpRunFunc        run_func,
+                                                    gpointer           run_data,
+                                                    GDestroyNotify     run_data_destroy);
 
 GimpPlugIn     * gimp_procedure_get_plug_in        (GimpProcedure     *procedure);
 GimpPDBProcType  gimp_procedure_get_proc_type      (GimpProcedure     *procedure);
diff --git a/plug-ins/common/goat-exercise.c b/plug-ins/common/goat-exercise.c
index c376291217..b61b737f33 100644
--- a/plug-ins/common/goat-exercise.c
+++ b/plug-ins/common/goat-exercise.c
@@ -56,7 +56,8 @@ static GimpProcedure  * goat_create_procedure (GimpPlugIn           *plug_in,
                                                const gchar          *name);
 
 static GimpValueArray * goat_run              (GimpProcedure        *procedure,
-                                               const GimpValueArray *args);
+                                               const GimpValueArray *args,
+                                               gpointer              run_data);
 
 
 G_DEFINE_TYPE (Goat, goat, GIMP_TYPE_PLUG_IN)
@@ -99,8 +100,8 @@ goat_create_procedure (GimpPlugIn  *plug_in,
 
   if (! strcmp (name, PLUG_IN_PROC))
     {
-      procedure = gimp_procedure_new (plug_in, name,
-                                      GIMP_PLUGIN, goat_run);
+      procedure = gimp_procedure_new (plug_in, name, GIMP_PLUGIN,
+                                      goat_run, NULL, NULL);
 
       gimp_procedure_set_strings (procedure,
                                   N_("Goat-exercise"),
@@ -142,7 +143,8 @@ goat_create_procedure (GimpPlugIn  *plug_in,
 
 static GimpValueArray *
 goat_run (GimpProcedure        *procedure,
-          const GimpValueArray *args)
+          const GimpValueArray *args,
+          gpointer              run_data)
 {
   GimpPDBStatusType status = GIMP_PDB_SUCCESS;
   gint32            drawable_id;
diff --git a/plug-ins/help/help.c b/plug-ins/help/help.c
index eb097f548f..167a659574 100644
--- a/plug-ins/help/help.c
+++ b/plug-ins/help/help.c
@@ -74,9 +74,11 @@ static GimpProcedure  * help_create_procedure  (GimpPlugIn           *plug_in,
                                                 const gchar          *name);
 
 static GimpValueArray * help_run               (GimpProcedure        *procedure,
-                                                const GimpValueArray *args);
+                                                const GimpValueArray *args,
+                                                gpointer              run_data);
 static GimpValueArray * help_temp_run          (GimpProcedure        *procedure,
-                                                const GimpValueArray *args);
+                                                const GimpValueArray *args,
+                                                gpointer              run_data);
 
 static void             help_temp_proc_install (GimpPlugIn           *plug_in);
 static void             help_load              (const gchar          *procedure,
@@ -130,7 +132,8 @@ help_create_procedure (GimpPlugIn  *plug_in,
 
   if (! strcmp (name, GIMP_HELP_EXT_PROC))
     {
-      procedure = gimp_procedure_new (plug_in, name, GIMP_EXTENSION, help_run);
+      procedure = gimp_procedure_new (plug_in, name, GIMP_EXTENSION,
+                                      help_run, NULL, NULL);
 
       gimp_procedure_set_strings (procedure,
                                   NULL,
@@ -173,7 +176,8 @@ help_create_procedure (GimpPlugIn  *plug_in,
 
 static GimpValueArray *
 help_run (GimpProcedure        *procedure,
-          const GimpValueArray *args)
+          const GimpValueArray *args,
+          gpointer              run_data)
 {
   GimpPDBStatusType status = GIMP_PDB_SUCCESS;
 
@@ -226,7 +230,7 @@ help_temp_proc_install (GimpPlugIn *plug_in)
   GimpProcedure *procedure;
 
   procedure = gimp_procedure_new (plug_in, GIMP_HELP_TEMP_EXT_PROC,
-                                  GIMP_TEMPORARY, help_temp_run);
+                                  GIMP_TEMPORARY, help_temp_run, NULL, NULL);
 
   gimp_procedure_set_strings (procedure,
                               NULL,
@@ -271,7 +275,8 @@ help_temp_proc_install (GimpPlugIn *plug_in)
 
 static GimpValueArray *
 help_temp_run (GimpProcedure        *procedure,
-               const GimpValueArray *args)
+               const GimpValueArray *args,
+               gpointer              run_data)
 {
   GimpPDBStatusType  status       = GIMP_PDB_SUCCESS;
   const gchar       *help_proc    = NULL;


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