diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-04-30 01:21:26 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-04-30 06:19:10 -0400 |
commit | 6535276c3e59461eb712a2c283e2b6b7367f3129 (patch) | |
tree | cfbc2f9624d051cf342325155a0bc0449e9be660 /gtk/gtkbuilderparser.c | |
parent | 569d5ad763ff6a971b206373a89bfb97259bf33b (diff) | |
download | gtk+-6535276c3e59461eb712a2c283e2b6b7367f3129.tar.gz |
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.
Diffstat (limited to 'gtk/gtkbuilderparser.c')
-rw-r--r-- | gtk/gtkbuilderparser.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c index 998357de48..160c7bcdb5 100644 --- a/gtk/gtkbuilderparser.c +++ b/gtk/gtkbuilderparser.c @@ -420,23 +420,28 @@ parse_template (GMarkupParseContext *context, template_type = _gtk_builder_get_template_type (data->builder); - if (template_type == 0) + if (!g_markup_collect_attributes (element_name, names, values, error, + G_MARKUP_COLLECT_STRING, "class", &object_class, + G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "parent", &parent_class, + G_MARKUP_COLLECT_INVALID)) { - error_unhandled_tag (data, "template", error); + _gtk_builder_prefix_error (data->builder, data->ctx, error); return; } - else if (state_peek (data) != NULL) + + if (template_type == 0) { - error_invalid_tag (data, "template", NULL, error); + 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; } - - if (!g_markup_collect_attributes (element_name, names, values, error, - G_MARKUP_COLLECT_STRING, "class", &object_class, - G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "parent", &parent_class, - G_MARKUP_COLLECT_INVALID)) + else if (state_peek (data) != NULL) { - _gtk_builder_prefix_error (data->builder, data->ctx, error); + error_invalid_tag (data, "template", NULL, error); return; } |