[gtk/prop-list: 89/96] expression: Add a new property expression constructor



commit 51b4768fd77e28829aff938e12c772b5d604f12e
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Dec 23 16:11:36 2019 -0500

    expression: Add a new property expression constructor
    
    Allow creating property expresions from a GParamSpec.
    This lets us avoid a critical, and instead report an
    error in GtkBuilder if the property does not exist.

 gtk/gtkexpression.c | 10 +++++++++-
 gtk/gtkexpression.h |  3 +++
 2 files changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkexpression.c b/gtk/gtkexpression.c
index 0caddd6168..d92cba035b 100644
--- a/gtk/gtkexpression.c
+++ b/gtk/gtkexpression.c
@@ -694,7 +694,6 @@ gtk_property_expression_new (GType          this_type,
                              GtkExpression *expression,
                              const char    *property_name)
 {
-  GtkPropertyExpression *result;
   GParamSpec *pspec;
 
   if (g_type_is_a (this_type, G_TYPE_OBJECT))
@@ -721,6 +720,15 @@ gtk_property_expression_new (GType          this_type,
       return NULL;
     }
 
+  return gtk_property_expression_new_for_pspec (expression, pspec);
+}
+
+GtkExpression *
+gtk_property_expression_new_for_pspec (GtkExpression *expression,
+                                       GParamSpec    *pspec)
+{
+  GtkPropertyExpression *result;
+
   result = gtk_expression_alloc (&GTK_PROPERTY_EXPRESSION_CLASS, pspec->value_type);
 
   result->pspec = pspec;
diff --git a/gtk/gtkexpression.h b/gtk/gtkexpression.h
index ddffee6706..8772954396 100644
--- a/gtk/gtkexpression.h
+++ b/gtk/gtkexpression.h
@@ -84,6 +84,9 @@ GtkExpression *         gtk_property_expression_new             (GType
                                                                  GtkExpression                  *expression,
                                                                  const char                     
*property_name);
 GDK_AVAILABLE_IN_ALL
+GtkExpression *         gtk_property_expression_new_for_pspec   (GtkExpression                  *expression,
+                                                                 GParamSpec                     *pspec);
+GDK_AVAILABLE_IN_ALL
 GtkExpression *         gtk_constant_expression_new             (GType                           value_type,
                                                                  ...);
 GDK_AVAILABLE_IN_ALL


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