summaryrefslogtreecommitdiff
path: root/gtk/gtkbuilder.c
diff options
context:
space:
mode:
authorTristan Van Berkom <tristanvb@openismus.com>2013-03-30 18:46:16 +0900
committerTristan Van Berkom <tristanvb@openismus.com>2013-04-08 21:19:27 +0900
commit64b87824c760766b2e83bfc6dad7e69f5c0ca667 (patch)
treec58d69fb70d1a3fd80a56fce9abd223a88333f8b /gtk/gtkbuilder.c
parentb7da0d21f8ca2f9ec4eccf3a96c57327e0a5d601 (diff)
downloadgtk+-64b87824c760766b2e83bfc6dad7e69f5c0ca667.tar.gz
GtkBuilder: Allow G_PARAM_CONSTRUCT properties to be set on internal children.
This patch allows properties of type G_PARAM_CONSTRUCT to be set on internal children or explicitly constructed objects (built with <constructor>) while previously, G_PARAM_CONSTRUCT properties being set on already constructed objects would result in an misinformed warning that "construct-only properties cannot be set". G_PARAM_CONSTRUCT_ONLY properties are still refused as parameters to already constructed children.
Diffstat (limited to 'gtk/gtkbuilder.c')
-rw-r--r--gtk/gtkbuilder.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index 7e0880240d..f51f79a2d9 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -617,6 +617,7 @@ _gtk_builder_construct (GtkBuilder *builder,
GtkBuildableIface *iface;
gboolean custom_set_property;
GtkBuildable *buildable;
+ GParamFlags param_filter_flags;
g_assert (info->class_name != NULL);
object_type = gtk_builder_get_type_from_name (builder, info->class_name);
@@ -641,10 +642,27 @@ _gtk_builder_construct (GtkBuilder *builder,
return NULL;
}
+ /* If there is a manual constructor (like UIManager), or if this is a
+ * reference to an internal child, then we filter out construct-only
+ * and warn that they cannot be set.
+ *
+ * Otherwise if we are calling g_object_newv(), we want to pass
+ * both G_PARAM_CONSTRUCT and G_PARAM_CONSTRUCT_ONLY to the
+ * object's constructor.
+ *
+ * Passing all construct properties to g_object_newv() slightly
+ * improves performance as the construct properties will only be set once.
+ */
+ if (info->constructor ||
+ (info->parent && ((ChildInfo*)info->parent)->internal_child != NULL))
+ param_filter_flags = G_PARAM_CONSTRUCT_ONLY;
+ else
+ param_filter_flags = G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY;
+
gtk_builder_get_parameters (builder, object_type,
info->id,
info->properties,
- (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY),
+ param_filter_flags,
&parameters,
&construct_parameters);