Commit a6578090 authored by Benjamin Otte's avatar Benjamin Otte

cssparser: Keep track of the file

parent a8d8c02a
......@@ -38,26 +38,31 @@
struct _GtkCssParser
{
const char *data;
GtkCssParserErrorFunc error_func;
gpointer user_data;
const char *data;
GFile *file;
GtkCssParserErrorFunc error_func;
gpointer user_data;
const char *line_start;
guint line;
const char *line_start;
guint line;
};
GtkCssParser *
_gtk_css_parser_new (const char *data,
GFile *file,
GtkCssParserErrorFunc error_func,
gpointer user_data)
{
GtkCssParser *parser;
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail (file == NULL || G_IS_FILE (file), NULL);
parser = g_slice_new0 (GtkCssParser);
parser->data = data;
if (file)
parser->file = g_object_ref (file);
parser->error_func = error_func;
parser->user_data = user_data;
......@@ -72,6 +77,9 @@ _gtk_css_parser_free (GtkCssParser *parser)
{
g_return_if_fail (GTK_IS_CSS_PARSER (parser));
if (parser->file)
g_object_unref (parser->file);
g_slice_free (GtkCssParser, parser);
}
......
......@@ -30,6 +30,7 @@ typedef void (* GtkCssParserErrorFunc) (GtkCssParser *parser,
gpointer user_data);
GtkCssParser * _gtk_css_parser_new (const char *data,
GFile *file,
GtkCssParserErrorFunc error_func,
gpointer user_data);
void _gtk_css_parser_free (GtkCssParser *parser);
......
......@@ -1370,6 +1370,7 @@ gtk_css_scanner_new (GtkCssProvider *provider,
}
scanner->parser = _gtk_css_parser_new (text,
file,
gtk_css_scanner_parser_error,
scanner);
......
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