[gtk+] GtkBuilder: Emit a more detailed error for templates
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkBuilder: Emit a more detailed error for templates
- Date: Thu, 30 Apr 2015 10:21:13 +0000 (UTC)
commit 6535276c3e59461eb712a2c283e2b6b7367f3129
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Apr 30 01:21:26 2015 -0400
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.
gtk/gtkbuilderparser.c | 25 +++++++++++++++----------
1 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c
index 998357d..160c7bc 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]