Make GtkBuilder do not delay construct properties that can be resolved

(so construct is respected when possible) and skip construct only props that
can not.
This commit is contained in:
Juan Pablo Ugarte 2011-06-29 11:45:33 -03:00
parent 9f83204d48
commit a5b92540d0

View File

@ -280,29 +280,29 @@ gtk_builder_get_parameters (GtkBuilder *builder,
if (G_IS_PARAM_SPEC_OBJECT (pspec) && if (G_IS_PARAM_SPEC_OBJECT (pspec) &&
(G_PARAM_SPEC_VALUE_TYPE (pspec) != GDK_TYPE_PIXBUF)) (G_PARAM_SPEC_VALUE_TYPE (pspec) != GDK_TYPE_PIXBUF))
{ {
if (pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)) GObject *object = gtk_builder_get_object (builder, prop->data);
if (object)
{ {
GObject *object; g_value_init (&parameter.value, G_OBJECT_TYPE (object));
object = gtk_builder_get_object (builder, prop->data); g_value_set_object (&parameter.value, object);
if (!object) }
else
{
if (pspec->flags & G_PARAM_CONSTRUCT_ONLY)
{ {
g_warning ("Failed to get constuct only property " g_warning ("Failed to get constuct only property "
"%s of %s with value `%s'", "%s of %s with value `%s'",
prop->name, object_name, prop->data); prop->name, object_name, prop->data);
continue; continue;
} }
g_value_init (&parameter.value, G_OBJECT_TYPE (object)); /* Delay setting property */
g_value_set_object (&parameter.value, object);
}
else
{
property = g_slice_new (DelayedProperty); property = g_slice_new (DelayedProperty);
property->object = g_strdup (object_name); property->object = g_strdup (object_name);
property->name = g_strdup (prop->name); property->name = g_strdup (prop->name);
property->value = g_strdup (prop->data); property->value = g_strdup (prop->data);
builder->priv->delayed_properties = builder->priv->delayed_properties =
g_slist_prepend (builder->priv->delayed_properties, property); g_slist_prepend (builder->priv->delayed_properties, property);
continue; continue;
} }
} }