builder: Fix handling of <binding>
We were only applying <binding> elements when the object is constructed, which can be triggered by various things (e.g. a <style> element). Defer this until we reach </object>, so we can be sure that we pick up all the bindings. Testcase included. Fixes: #4147
This commit is contained in:
@@ -699,7 +699,7 @@ _gtk_builder_add_object (GtkBuilder *builder,
|
||||
g_hash_table_insert (priv->objects, g_strdup (id), g_object_ref (object));
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
gtk_builder_take_bindings (GtkBuilder *builder,
|
||||
GObject *target,
|
||||
GSList *bindings)
|
||||
@@ -926,9 +926,6 @@ _gtk_builder_construct (GtkBuilder *builder,
|
||||
|
||||
object_properties_destroy (¶meters);
|
||||
|
||||
if (info->bindings)
|
||||
gtk_builder_take_bindings (builder, obj, info->bindings);
|
||||
|
||||
/* put it in the hash table. */
|
||||
_gtk_builder_add_object (builder, info->id, obj);
|
||||
|
||||
|
||||
@@ -1962,6 +1962,12 @@ end_element (GtkBuildableParseContext *context,
|
||||
object_info->signals = NULL;
|
||||
}
|
||||
|
||||
if (object_info->bindings)
|
||||
{
|
||||
gtk_builder_take_bindings (data->builder, object_info->object, object_info->bindings);
|
||||
object_info->bindings = NULL;
|
||||
}
|
||||
|
||||
free_object_info (object_info);
|
||||
}
|
||||
else if (strcmp (element_name, "child") == 0)
|
||||
|
||||
@@ -221,6 +221,10 @@ void _gtk_builder_add (GtkBuilder *builder,
|
||||
ChildInfo *child_info);
|
||||
void _gtk_builder_add_signals (GtkBuilder *builder,
|
||||
GPtrArray *signals);
|
||||
void gtk_builder_take_bindings (GtkBuilder *builder,
|
||||
GObject *target,
|
||||
GSList *bindings);
|
||||
|
||||
gboolean _gtk_builder_finish (GtkBuilder *builder,
|
||||
GError **error);
|
||||
void _free_signal_info (SignalInfo *info,
|
||||
|
||||
18
testsuite/reftests/late-binding.ref.ui
Normal file
18
testsuite/reftests/late-binding.ref.ui
Normal file
@@ -0,0 +1,18 @@
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window">
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0.0</property>
|
||||
<binding name="label">
|
||||
<lookup name="label">label2</lookup>
|
||||
</binding>
|
||||
<style>
|
||||
<class name="bold" />
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkLabel" id="label2">
|
||||
<property name="label">Bla</property>
|
||||
</object>
|
||||
</interface>
|
||||
18
testsuite/reftests/late-binding.ui
Normal file
18
testsuite/reftests/late-binding.ui
Normal file
@@ -0,0 +1,18 @@
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window">
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<style>
|
||||
<class name="bold" />
|
||||
</style>
|
||||
<property name="xalign">0.0</property>
|
||||
<binding name="label">
|
||||
<lookup name="label">label2</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkLabel" id="label2">
|
||||
<property name="label">Bla</property>
|
||||
</object>
|
||||
</interface>
|
||||
@@ -331,6 +331,8 @@ testdata = [
|
||||
# that are not valid with subpixel positioning
|
||||
#'label-wrap-justify.ref.ui',
|
||||
#'label-wrap-justify.ui',
|
||||
'late-binding.ui',
|
||||
'late-binding.ref.ui',
|
||||
'late-property.ui',
|
||||
'late-property.ref.ui',
|
||||
'letter-spacing.css',
|
||||
|
||||
Reference in New Issue
Block a user