Commit cc478fbd authored by Matthias Clasen's avatar Matthias Clasen

GtkTreeStore: Use the new helpers

Use the new GtkBuilder helpers and g_markup_collect_attributes
in all builder subparsers.
parent 9a512c6f
......@@ -23,6 +23,7 @@
#include "gtktreedatalist.h"
#include "gtktreednd.h"
#include "gtkbuildable.h"
#include "gtkbuilderprivate.h"
#include "gtkdebug.h"
#include "gtkintl.h"
......@@ -3339,28 +3340,56 @@ typedef struct {
} GSListSubParserData;
static void
tree_model_start_element (GMarkupParseContext *context,
const gchar *element_name,
const gchar **names,
const gchar **values,
gpointer user_data,
GError **error)
{
guint i;
tree_model_start_element (GMarkupParseContext *context,
const gchar *element_name,
const gchar **names,
const gchar **values,
gpointer user_data,
GError **error)
{
GSListSubParserData *data = (GSListSubParserData*)user_data;
for (i = 0; names[i]; i++)
if (strcmp (element_name, "columns") == 0)
{
if (strcmp (names[i], "type") == 0)
data->items = g_slist_prepend (data->items, g_strdup (values[i]));
if (!_gtk_builder_check_parent (data->builder, context, "object", error))
return;
if (!g_markup_collect_attributes (element_name, names, values, error,
G_MARKUP_COLLECT_INVALID, NULL, NULL,
G_MARKUP_COLLECT_INVALID))
_gtk_builder_prefix_error (data->builder, context, error);
}
else if (strcmp (element_name, "column") == 0)
{
const gchar *type;
if (!_gtk_builder_check_parent (data->builder, context, "columns", error))
return;
if (!g_markup_collect_attributes (element_name, names, values, error,
G_MARKUP_COLLECT_STRING, "type", &type,
G_MARKUP_COLLECT_INVALID))
{
_gtk_builder_prefix_error (data->builder, context, error);
return;
}
data->items = g_slist_prepend (data->items, g_strdup (type));
}
else
{
_gtk_builder_error_unhandled_tag (data->builder, context,
"GtkTreeStore", element_name,
error);
}
}
static void
tree_model_end_element (GMarkupParseContext *context,
const gchar *element_name,
gpointer user_data,
GError **error)
tree_model_end_element (GMarkupParseContext *context,
const gchar *element_name,
gpointer user_data,
GError **error)
{
GSListSubParserData *data = (GSListSubParserData*)user_data;
......@@ -3407,26 +3436,27 @@ static const GMarkupParser tree_model_parser =
static gboolean
gtk_tree_store_buildable_custom_tag_start (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const gchar *tagname,
GMarkupParser *parser,
gpointer *data)
GtkBuilder *builder,
GObject *child,
const gchar *tagname,
GMarkupParser *parser,
gpointer *parser_data)
{
GSListSubParserData *parser_data;
GSListSubParserData *data;
if (child)
return FALSE;
if (strcmp (tagname, "columns") == 0)
{
parser_data = g_slice_new0 (GSListSubParserData);
parser_data->builder = builder;
parser_data->items = NULL;
parser_data->object = G_OBJECT (buildable);
data = g_slice_new0 (GSListSubParserData);
data->builder = builder;
data->items = NULL;
data->object = G_OBJECT (buildable);
*parser = tree_model_parser;
*data = parser_data;
*parser_data = data;
return TRUE;
}
......@@ -3435,10 +3465,10 @@ gtk_tree_store_buildable_custom_tag_start (GtkBuildable *buildable,
static void
gtk_tree_store_buildable_custom_finished (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const gchar *tagname,
gpointer user_data)
GtkBuilder *builder,
GObject *child,
const gchar *tagname,
gpointer user_data)
{
GSListSubParserData *data;
......
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