summaryrefslogtreecommitdiff
path: root/gtk/gtkbuildable.h
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2019-08-26 23:28:18 +0300
committerMatthias Clasen <mclasen@redhat.com>2019-09-10 12:07:15 -0400
commit135cea76fbe41cea7a83ebb3381bdc1410f8f9fb (patch)
tree83fa2157a2601ecf0104f347f5d3915cf36e193b /gtk/gtkbuildable.h
parentff087e126fb12cd3bb9f5d4322cf12fb654da00a (diff)
downloadgtk+-135cea76fbe41cea7a83ebb3381bdc1410f8f9fb.tar.gz
GtkBuildableParser: Add a wrapper for GMarkupParser
This currenly just wraps GMarkupParser, but the plan is to expose this instead of GMarkup in the GtkBuildable interfaces, allowing us to replace the parser with something that handles pre-parsed input instead. Note that we duplicate some of the features of GMarkup to implement the APIs rather then call down to GMarkup, as we need to support these in the pre-parsed case anyway.
Diffstat (limited to 'gtk/gtkbuildable.h')
-rw-r--r--gtk/gtkbuildable.h53
1 files changed, 52 insertions, 1 deletions
diff --git a/gtk/gtkbuildable.h b/gtk/gtkbuildable.h
index 6972abedd6..aec9c7b41a 100644
--- a/gtk/gtkbuildable.h
+++ b/gtk/gtkbuildable.h
@@ -33,10 +33,46 @@ G_BEGIN_DECLS
#define GTK_IS_BUILDABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_BUILDABLE))
#define GTK_BUILDABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_BUILDABLE, GtkBuildableIface))
-
typedef struct _GtkBuildable GtkBuildable; /* Dummy typedef */
typedef struct _GtkBuildableIface GtkBuildableIface;
+typedef struct _GtkBuildableParseContext GtkBuildableParseContext;
+typedef struct _GtkBuildableParser GtkBuildableParser;
+
+struct _GtkBuildableParser
+{
+ /* Called for open tags <foo bar="baz"> */
+ void (*start_element) (GtkBuildableParseContext *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ gpointer user_data,
+ GError **error);
+
+ /* Called for close tags </foo> */
+ void (*end_element) (GtkBuildableParseContext *context,
+ const gchar *element_name,
+ gpointer user_data,
+ GError **error);
+
+ /* Called for character data */
+ /* text is not nul-terminated */
+ void (*text) (GtkBuildableParseContext *context,
+ const gchar *text,
+ gsize text_len,
+ gpointer user_data,
+ GError **error);
+
+ /* Called on error, including one set by other
+ * methods in the vtable. The GError should not be freed.
+ */
+ void (*error) (GtkBuildableParseContext *context,
+ GError *error,
+ gpointer user_data);
+
+ gpointer padding[4];
+};
+
/**
* GtkBuildableIface:
* @g_iface: the parent class
@@ -178,6 +214,21 @@ GObject * gtk_buildable_get_internal_child (GtkBuildable *buildable,
GtkBuilder *builder,
const gchar *childname);
+GDK_AVAILABLE_IN_ALL
+void gtk_buildable_parse_context_push (GtkBuildableParseContext *context,
+ const GtkBuildableParser *parser,
+ gpointer user_data);
+GDK_AVAILABLE_IN_ALL
+gpointer gtk_buildable_parse_context_pop (GtkBuildableParseContext *context);
+GDK_AVAILABLE_IN_ALL
+const char * gtk_buildable_parse_context_get_element (GtkBuildableParseContext *context);
+GDK_AVAILABLE_IN_ALL
+GPtrArray *gtk_buildable_parse_context_get_element_stack (GtkBuildableParseContext *context);
+GDK_AVAILABLE_IN_ALL
+void gtk_buildable_parse_context_get_position (GtkBuildableParseContext *context,
+ gint *line_number,
+ gint *char_number);
+
G_END_DECLS
#endif /* __GTK_BUILDABLE_H__ */