diff options
author | Benjamin Otte <otte@redhat.com> | 2019-11-28 02:32:12 +0100 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-05-30 19:26:46 -0400 |
commit | b43c8ae6469d0a52bc281d7beff43bca4b03bd80 (patch) | |
tree | 66c7ab433ab250edc0cf1b3ae23be0667e0a7286 /gtk/gtkbuilder.c | |
parent | 22e6fa3a64024aef798138db7b6e9a3e0ccd1565 (diff) | |
download | gtk+-b43c8ae6469d0a52bc281d7beff43bca4b03bd80.tar.gz |
expression: Allow passing a this object to bind()
This gives a bit more control over the arguments passed to expressions.
Diffstat (limited to 'gtk/gtkbuilder.c')
-rw-r--r-- | gtk/gtkbuilder.c | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c index 6121d2ed8e..385b78db65 100644 --- a/gtk/gtkbuilder.c +++ b/gtk/gtkbuilder.c @@ -1064,11 +1064,13 @@ gtk_builder_create_bindings (GtkBuilder *builder, BindingInfo *info = l->data; GObject *source; - source = _gtk_builder_lookup_object (builder, info->source, info->line, info->col); + source = gtk_builder_lookup_object (builder, info->source, info->line, info->col, error); if (source) g_object_bind_property (source, info->source_property, info->target, info->target_pspec->name, info->flags); + else + error = NULL; _free_binding_info (info, NULL); } @@ -1076,17 +1078,39 @@ gtk_builder_create_bindings (GtkBuilder *builder, { BindingExpressionInfo *info = l->data; GtkExpression *expression; + GObject *object; - expression = expression_info_construct (builder, info->expr, error); - if (expression == NULL) + if (info->object_name) + { + object = gtk_builder_lookup_object (builder, info->object_name, info->line, info->col, error); + if (object == NULL) + { + error = NULL; + result = FALSE; + } + } + else if (priv->current_object) { - g_prefix_error (error, "%s:%d:%d: ", priv->filename, info->line, info->col); - error = NULL; - result = FALSE; + object = priv->current_object; } else { - gtk_expression_bind (expression, info->target, info->target_pspec->name); + object = info->target; + } + + if (object) + { + expression = expression_info_construct (builder, info->expr, error); + if (expression == NULL) + { + g_prefix_error (error, "%s:%d:%d: ", priv->filename, info->line, info->col); + error = NULL; + result = FALSE; + } + else + { + gtk_expression_bind (expression, info->target, info->target_pspec->name, object); + } } free_binding_expression_info (info); |