summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammed Sadiq <sadiq@sadiqpk.org>2019-08-07 07:42:03 +0530
committerMohammed Sadiq <sadiq@sadiqpk.org>2019-08-10 19:01:36 +0530
commitc1bb699151f4f3098762bb85aeaa1e37cae271ea (patch)
treef2d0a27866fbabf27d99ca1b9e4f5e1b48550e0a
parent120cfcc120b03b2a552ce4e77eba0bcc97a3ac54 (diff)
downloadgtk+-c1bb699151f4f3098762bb85aeaa1e37cae271ea.tar.gz
builderparser: Allow bind-source without bind-property
This allow users to bind same property of two objects with only specifing “name” and “bind-source” in UI file. Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2080
-rw-r--r--gtk/gtkbuilder.c6
-rw-r--r--gtk/gtkbuilderparser.c10
-rw-r--r--gtk/tools/gtk4builder.rng8
3 files changed, 13 insertions, 11 deletions
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index 138cf07c97..220a51c33c 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -131,9 +131,9 @@
*
* It is also possible to bind a property value to another object's
* property value using the attributes
- * "bind-source" to specify the source object of the binding,
- * "bind-property" to specify the source property and optionally
- * "bind-flags" to specify the binding flags
+ * "bind-source" to specify the source object of the binding, and
+ * optionally, "bind-property" and "bind-flags" to specify the
+ * source property and source binding flags respectively.
* Internally builder implement this using GBinding objects.
* For more information see g_object_bind_property()
*
diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c
index fc1c80db28..8a5a1608d6 100644
--- a/gtk/gtkbuilderparser.c
+++ b/gtk/gtkbuilderparser.c
@@ -598,7 +598,7 @@ parse_property (ParserData *data,
g_markup_parse_context_get_position (data->ctx, &line, &col);
- if (bind_source && bind_property)
+ if (bind_source)
{
BindingInfo *binfo;
@@ -606,17 +606,17 @@ parse_property (ParserData *data,
binfo->target = NULL;
binfo->target_pspec = pspec;
binfo->source = g_strdup (bind_source);
- binfo->source_property = g_strdup (bind_property);
+ binfo->source_property = bind_property ? g_strdup (bind_property) : g_strdup (name);
binfo->flags = bind_flags;
binfo->line = line;
binfo->col = col;
object_info->bindings = g_slist_prepend (object_info->bindings, binfo);
}
- else if (bind_source || bind_property)
+ else if (bind_property)
{
error_missing_attribute (data, element_name,
- (bind_source) ? "bind-property" : "bind-source",
+ "bind-source",
error);
return;
}
@@ -626,7 +626,7 @@ parse_property (ParserData *data,
info->pspec = pspec;
info->text = g_string_new ("");
info->translatable = translatable;
- info->bound = (bind_source && bind_property);
+ info->bound = bind_source != NULL;
info->context = g_strdup (context);
info->line = line;
info->col = col;
diff --git a/gtk/tools/gtk4builder.rng b/gtk/tools/gtk4builder.rng
index 032d84d142..125051511c 100644
--- a/gtk/tools/gtk4builder.rng
+++ b/gtk/tools/gtk4builder.rng
@@ -103,9 +103,11 @@
<attribute name="bind-source">
<text/>
</attribute>
- <attribute name="bind-property">
- <text/>
- </attribute>
+ <optional>
+ <attribute name="bind-property">
+ <text/>
+ </attribute>
+ </optional>
<optional>
<attribute name="bind-flags">
<text/>