Commit bfe42558 authored by Benjamin Otte's avatar Benjamin Otte

builder: Allow objects in gtk_builder_value_from_string_type()

Instead of throwing an error, lookup objects with
gtk_builder_get_object().
parent a15fb95c
......@@ -2167,7 +2167,31 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
ret = TRUE;
}
else
ret = FALSE;
{
GObject *object = g_hash_table_lookup (priv->objects, string);
if (object && g_value_type_compatible (G_OBJECT_TYPE (object), type))
{
g_value_set_object (value, object);
}
else if (object)
{
g_set_error (error,
GTK_BUILDER_ERROR,
GTK_BUILDER_ERROR_INVALID_VALUE,
"Object named \"%s\" is of type \"%s\" which is not compatible with expected type \%s\"",
string, G_OBJECT_TYPE_NAME (object), g_type_name (type));
ret = FALSE;
}
else
{
g_set_error (error,
GTK_BUILDER_ERROR,
GTK_BUILDER_ERROR_INVALID_VALUE,
"No object named \"%s\"", string);
ret = FALSE;
}
}
break;
case G_TYPE_POINTER:
if (G_VALUE_HOLDS (value, G_TYPE_GTYPE))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment