forked from AuroraMiddleware/gtk
GtkBuilder: Emit a more detailed error for templates
Add the class and parent class name to the error message. gtk-builder-tool will parse the error message and use the class names for trying again to parse the file as a template.
This commit is contained in:
parent
569d5ad763
commit
6535276c3e
@ -420,17 +420,6 @@ parse_template (GMarkupParseContext *context,
|
|||||||
|
|
||||||
template_type = _gtk_builder_get_template_type (data->builder);
|
template_type = _gtk_builder_get_template_type (data->builder);
|
||||||
|
|
||||||
if (template_type == 0)
|
|
||||||
{
|
|
||||||
error_unhandled_tag (data, "template", error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (state_peek (data) != NULL)
|
|
||||||
{
|
|
||||||
error_invalid_tag (data, "template", NULL, error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!g_markup_collect_attributes (element_name, names, values, error,
|
if (!g_markup_collect_attributes (element_name, names, values, error,
|
||||||
G_MARKUP_COLLECT_STRING, "class", &object_class,
|
G_MARKUP_COLLECT_STRING, "class", &object_class,
|
||||||
G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "parent", &parent_class,
|
G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "parent", &parent_class,
|
||||||
@ -440,6 +429,22 @@ parse_template (GMarkupParseContext *context,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (template_type == 0)
|
||||||
|
{
|
||||||
|
g_set_error (error,
|
||||||
|
GTK_BUILDER_ERROR,
|
||||||
|
GTK_BUILDER_ERROR_UNHANDLED_TAG,
|
||||||
|
"Not expecting to handle a template (class '%s', parent '%s')",
|
||||||
|
object_class, parent_class ? parent_class : "GtkWidget");
|
||||||
|
_gtk_builder_prefix_error (data->builder, context, error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (state_peek (data) != NULL)
|
||||||
|
{
|
||||||
|
error_invalid_tag (data, "template", NULL, error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
parsed_type = g_type_from_name (object_class);
|
parsed_type = g_type_from_name (object_class);
|
||||||
if (template_type != parsed_type)
|
if (template_type != parsed_type)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user