[gimp] libgimp: add gimp_procedure_add_(argument|return_value)_from_property().



commit 07875108104ba9ec80a6f05180e11ae7c92d4590
Author: Jehan <jehan girinstud io>
Date:   Fri Aug 2 14:57:42 2019 +0200

    libgimp: add gimp_procedure_add_(argument|return_value)_from_property().
    
    This will be used at least for the Python plug-ins. There is currently a
    bug preventing to set a GParamSpec in a binded API.
    See pygobject#227.
    
    Please don't revert this. At least it allows to use the new GimpPlugIn
    API for Python plug-ins. Anyway even with the old API, I had to add ugly
    temporary API for the introspection (which I will now remove as they
    never made it to release). So we are trading an ugly situation for a
    less ugly one.
    We can always remove these 2 new functions before release if we find or
    implement better solutions before.

 libgimp/gimpprocedure.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++---
 libgimp/gimpprocedure.h |  8 ++++++
 2 files changed, 75 insertions(+), 3 deletions(-)
---
diff --git a/libgimp/gimpprocedure.c b/libgimp/gimpprocedure.c
index 64023271a9..968d834e2a 100644
--- a/libgimp/gimpprocedure.c
+++ b/libgimp/gimpprocedure.c
@@ -649,7 +649,8 @@ gimp_procedure_get_menu_paths (GimpProcedure *procedure)
  *
  * Add a new argument to @procedure according to @pspec specifications.
  * The arguments will be ordered according to the call order to
- * gimp_procedure_add_argument().
+ * gimp_procedure_add_argument() and
+ * gimp_procedure_add_argument_from_property().
  **/
 void
 gimp_procedure_add_argument (GimpProcedure *procedure,
@@ -668,14 +669,47 @@ gimp_procedure_add_argument (GimpProcedure *procedure,
   procedure->priv->n_args++;
 }
 
+/**
+ * gimp_procedure_add_argument_from_property:
+ * @procedure: the #GimpProcedure.
+ * @config:    a #GObject.
+ * @prop_name: property name in @config.
+ *
+ * Add a new argument to @procedure according to the specifications of
+ * the property @prop_name registered on @config.
+ *
+ * The arguments will be ordered according to the call order to
+ * gimp_procedure_add_argument() and
+ * gimp_procedure_add_argument_from_property().
+ */
+void
+gimp_procedure_add_argument_from_property (GimpProcedure *procedure,
+                                           GObject       *config,
+                                           const gchar   *prop_name)
+{
+  GParamSpec *pspec;
+
+  g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
+  g_return_if_fail (prop_name != NULL);
+
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (procedure->priv->plug_in), prop_name);
+
+  g_return_if_fail (pspec != NULL);
+
+  gimp_procedure_add_argument (procedure, pspec);
+}
+
 /**
  * gimp_procedure_add_return_value:
  * @procedure: the #GimpProcedure.
  * @pspec:     (transfer full): the return value specification.
  *
  * Add a new return value to @procedure according to @pspec
- * specifications. The returned values will be ordered according to the
- * call order to gimp_procedure_add_return_value().
+ * specifications.
+ *
+ * The returned values will be ordered according to the call order to
+ * gimp_procedure_add_return_value() and
+ * gimp_procedure_add_return_value_from_property().
  **/
 void
 gimp_procedure_add_return_value (GimpProcedure *procedure,
@@ -694,6 +728,36 @@ gimp_procedure_add_return_value (GimpProcedure *procedure,
   procedure->priv->n_values++;
 }
 
+/**
+ * gimp_procedure_add_return_value_from_property:
+ * @procedure: the #GimpProcedure.
+ * @config:    a #GObject.
+ * @prop_name: property name in @config.
+ *
+ * Add a new return value to @procedure according to the specifications of
+ * the property @prop_name registered on @config.
+ *
+ * The returned values will be ordered according to the call order to
+ * gimp_procedure_add_return_value() and
+ * gimp_procedure_add_return_value_from_property().
+ */
+void
+gimp_procedure_add_return_value_from_property (GimpProcedure *procedure,
+                                               GObject       *config,
+                                               const gchar   *prop_name)
+{
+  GParamSpec *pspec;
+
+  g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
+  g_return_if_fail (prop_name != NULL);
+
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (procedure->priv->plug_in), prop_name);
+
+  g_return_if_fail (pspec != NULL);
+
+  gimp_procedure_add_return_value (procedure, pspec);
+}
+
 /**
  * gimp_procedure_get_arguments:
  * @procedure:   A #GimpProcedure.
diff --git a/libgimp/gimpprocedure.h b/libgimp/gimpprocedure.h
index bd43c610ad..c1143c4a81 100644
--- a/libgimp/gimpprocedure.h
+++ b/libgimp/gimpprocedure.h
@@ -123,8 +123,16 @@ GList          * gimp_procedure_get_menu_paths     (GimpProcedure     *procedure
 
 void             gimp_procedure_add_argument       (GimpProcedure     *procedure,
                                                     GParamSpec        *pspec);
+void             gimp_procedure_add_argument_from_property
+                                                   (GimpProcedure     *procedure,
+                                                    GObject           *config,
+                                                    const gchar       *prop_name);
 void             gimp_procedure_add_return_value   (GimpProcedure     *procedure,
                                                     GParamSpec        *pspec);
+void             gimp_procedure_add_return_value_from_property
+                                                   (GimpProcedure     *procedure,
+                                                    GObject           *config,
+                                                    const gchar       *prop_name);
 
 GParamSpec    ** gimp_procedure_get_arguments      (GimpProcedure     *procedure,
                                                     gint              *n_arguments);


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