mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-16 15:14:17 +00:00
builder: Make <lookup> type optional
If no type is set, use the type of the expression.
This commit is contained in:
parent
d3dc9c41b4
commit
ed22af50bc
@ -1144,7 +1144,7 @@ parse_lookup_expression (ParserData *data,
|
||||
{
|
||||
ExpressionInfo *info;
|
||||
const char *property_name;
|
||||
const char *type_name;
|
||||
const char *type_name = NULL;
|
||||
GType type;
|
||||
|
||||
if (!check_expression_parent (data))
|
||||
@ -1154,7 +1154,7 @@ parse_lookup_expression (ParserData *data,
|
||||
}
|
||||
|
||||
if (!g_markup_collect_attributes (element_name, names, values, error,
|
||||
G_MARKUP_COLLECT_STRING, "type", &type_name,
|
||||
G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "type", &type_name,
|
||||
G_MARKUP_COLLECT_STRING, "name", &property_name,
|
||||
G_MARKUP_COLLECT_INVALID))
|
||||
{
|
||||
@ -1162,15 +1162,22 @@ parse_lookup_expression (ParserData *data,
|
||||
return;
|
||||
}
|
||||
|
||||
type = gtk_builder_get_type_from_name (data->builder, type_name);
|
||||
if (type == G_TYPE_INVALID)
|
||||
if (type_name == NULL)
|
||||
{
|
||||
g_set_error (error,
|
||||
GTK_BUILDER_ERROR,
|
||||
GTK_BUILDER_ERROR_INVALID_VALUE,
|
||||
"Invalid type '%s'", type_name);
|
||||
_gtk_builder_prefix_error (data->builder, &data->ctx, error);
|
||||
return;
|
||||
type = G_TYPE_INVALID;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = gtk_builder_get_type_from_name (data->builder, type_name);
|
||||
if (type == G_TYPE_INVALID)
|
||||
{
|
||||
g_set_error (error,
|
||||
GTK_BUILDER_ERROR,
|
||||
GTK_BUILDER_ERROR_INVALID_VALUE,
|
||||
"Invalid type '%s'", type_name);
|
||||
_gtk_builder_prefix_error (data->builder, &data->ctx, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
info = g_slice_new0 (ExpressionInfo);
|
||||
|
Loading…
Reference in New Issue
Block a user