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.
This commit is contained in:
Matthias Clasen
2019-12-23 16:11:36 -05:00
parent 8febf5e98a
commit 51b4768fd7
2 changed files with 12 additions and 1 deletions

View File

@@ -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;

View File

@@ -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