Commit c8446f43 authored by Matthias Clasen's avatar Matthias Clasen

GtkBuilder: Introduce some private helpers

Add functions that help reporting errors from builder
subparsers consistently.
parent 44bf00d5
......@@ -2606,3 +2606,63 @@ gtk_builder_get_application (GtkBuilder *builder)
return builder->priv->application;
}
void
_gtk_builder_prefix_error (GtkBuilder *builder,
GMarkupParseContext *context,
GError **error)
{
gint line, col;
g_markup_parse_context_get_position (context, &line, &col);
g_prefix_error (error, "%s:%d:%d ", builder->priv->filename, line, col);
}
void
_gtk_builder_error_unhandled_tag (GtkBuilder *builder,
GMarkupParseContext *context,
const gchar *object,
const gchar *element_name,
GError **error)
{
gint line, col;
g_markup_parse_context_get_position (context, &line, &col);
g_set_error (error,
GTK_BUILDER_ERROR,
GTK_BUILDER_ERROR_UNHANDLED_TAG,
"%s:%d:%d Unsupported tag for %s: <%s>",
builder->priv->filename, line, col,
object, element_name);
}
gboolean
_gtk_builder_check_parent (GtkBuilder *builder,
GMarkupParseContext *context,
const gchar *parent_name,
GError **error)
{
const GSList *stack;
gint line, col;
const gchar *parent;
const gchar *element;
stack = g_markup_parse_context_get_element_stack (context);
element = (const gchar *)stack->data;
parent = stack->next ? (const gchar *)stack->next->data : "";
if (g_str_equal (parent_name, parent) ||
(g_str_equal (parent_name, "object") && g_str_equal (parent, "template")))
return TRUE;
g_markup_parse_context_get_position (context, &line, &col);
g_set_error (error,
GTK_BUILDER_ERROR,
GTK_BUILDER_ERROR_INVALID_TAG,
"%s:%d:%d Can't use <%s> here",
builder->priv->filename, line, col, element);
return FALSE;
}
......@@ -185,4 +185,17 @@ guint _gtk_builder_extend_with_template (GtkBuilder *builder,
gsize length,
GError **error);
void _gtk_builder_prefix_error (GtkBuilder *builder,
GMarkupParseContext *context,
GError **error);
void _gtk_builder_error_unhandled_tag (GtkBuilder *builder,
GMarkupParseContext *context,
const gchar *object,
const gchar *element_name,
GError **error);
gboolean _gtk_builder_check_parent (GtkBuilder *builder,
GMarkupParseContext *context,
const gchar *parent_name,
GError **error);
#endif /* __GTK_BUILDER_PRIVATE_H__ */
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