expression: Add some introspection

Add a few apis to peek inside expressions, mainly
for the benefit of GtkInspector and similar uses.
This commit is contained in:
Matthias Clasen
2020-07-13 20:19:07 -04:00
parent b7eb663b82
commit 7b36b339aa
3 changed files with 89 additions and 0 deletions

View File

@@ -7541,9 +7541,13 @@ gtk_expression_watch_unwatch
<SUBSECTION>
gtk_property_expression_new
gtk_property_expression_new_for_pspec
gtk_property_expression_get_expression
gtk_property_expression_get_pspec
gtk_constant_expression_new
gtk_constant_expression_new_for_value
gtk_constant_expression_get_value
gtk_object_expression_new
gtk_object_expression_get_object
gtk_closure_expression_new
gtk_cclosure_expression_new

View File

@@ -855,6 +855,24 @@ gtk_constant_expression_new_for_value (const GValue *value)
return result;
}
/**
* gtk_constant_expression_get_value:
* @expression: a constant #GtkExpression
*
* Gets the value that a constant expression evaluates to.
*
* Returns: (transfer none): the value
*/
const GValue *
gtk_constant_expression_get_value (GtkExpression *expression)
{
GtkConstantExpression *self = (GtkConstantExpression *) expression;
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (expression, GTK_TYPE_CONSTANT_EXPRESSION), NULL);
return &self->value;
}
/* }}} */
/* {{{ GtkObjectExpression */
@@ -1002,6 +1020,24 @@ gtk_object_expression_new (GObject *object)
return result;
}
/**
* gtk_object_expression_get_object:
* @expression: an object #GtkExpression
*
* Gets the object that the expression evaluates to.
*
* Returns: (transfer none): the object, or %NULL
*/
GObject *
gtk_object_expression_get_object (GtkExpression *expression)
{
GtkObjectExpression *self = (GtkObjectExpression *) expression;
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (expression, GTK_TYPE_OBJECT_EXPRESSION), NULL);
return self->object;
}
/* }}} */
/* {{{ GtkPropertyExpression */
@@ -1307,6 +1343,44 @@ gtk_property_expression_new_for_pspec (GtkExpression *expression,
return result;
}
/**
* gtk_property_expression_get_expression:
* @expression: a property #GtkExpression
*
* Gets the expression specifying the object of
* a property expression.
*
* Returns: (transfer none): the object expression
*/
GtkExpression *
gtk_property_expression_get_expression (GtkExpression *expression)
{
GtkPropertyExpression *self = (GtkPropertyExpression *) expression;
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (expression, GTK_TYPE_PROPERTY_EXPRESSION), NULL);
return self->expr;
}
/**
* gtk_property_expression_get_pspec:
* @expression: a property #GtkExpression
*
* Gets the #GParamSpec specifying the property of
* a property expression.
*
* Returns: (transfer none): the #GParamSpec
*/
GParamSpec *
gtk_property_expression_get_pspec (GtkExpression *expression)
{
GtkPropertyExpression *self = (GtkPropertyExpression *) expression;
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (expression, GTK_TYPE_PROPERTY_EXPRESSION), NULL);
return self->pspec;
}
/* }}} */
/* {{{ GtkClosureExpression */

View File

@@ -93,6 +93,11 @@ GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_property_expression_new_for_pspec (GtkExpression *expression,
GParamSpec *pspec);
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_property_expression_get_expression (GtkExpression *expression);
GDK_AVAILABLE_IN_ALL
GParamSpec * gtk_property_expression_get_pspec (GtkExpression *expression);
#define GTK_TYPE_CONSTANT_EXPRESSION (gtk_constant_expression_get_type())
typedef struct _GtkConstantExpression GtkConstantExpression;
@@ -105,6 +110,9 @@ GtkExpression * gtk_constant_expression_new (GType
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_constant_expression_new_for_value (const GValue *value);
GDK_AVAILABLE_IN_ALL
const GValue * gtk_constant_expression_get_value (GtkExpression *expression);
#define GTK_TYPE_OBJECT_EXPRESSION (gtk_object_expression_get_type())
typedef struct _GtkObjectExpression GtkObjectExpression;
@@ -114,6 +122,9 @@ GType gtk_object_expression_get_type (void) G_GNUC_CO
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_object_expression_new (GObject *object);
GDK_AVAILABLE_IN_ALL
GObject * gtk_object_expression_get_object (GtkExpression *expression);
#define GTK_TYPE_CLOSURE_EXPRESSION (gtk_closure_expression_get_type())
typedef struct _GtkClosureExpression GtkClosureExpression;