[gtk+] cssparser: Keep track of the file



commit a65780902a0b3a0497cf9c021f8a0d3e49a87cbd
Author: Benjamin Otte <otte redhat com>
Date:   Wed Apr 18 16:54:04 2012 +0200

    cssparser: Keep track of the file

 gtk/gtkcssparser.c        |   18 +++++++++++++-----
 gtk/gtkcssparserprivate.h |    1 +
 gtk/gtkcssprovider.c      |    1 +
 3 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkcssparser.c b/gtk/gtkcssparser.c
index 62d9113..7d3fa95 100644
--- a/gtk/gtkcssparser.c
+++ b/gtk/gtkcssparser.c
@@ -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);
 }
 
diff --git a/gtk/gtkcssparserprivate.h b/gtk/gtkcssparserprivate.h
index 2c83589..8609531 100644
--- a/gtk/gtkcssparserprivate.h
+++ b/gtk/gtkcssparserprivate.h
@@ -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);
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 128edc3..6ed7dde 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1370,6 +1370,7 @@ gtk_css_scanner_new (GtkCssProvider *provider,
     }
 
   scanner->parser = _gtk_css_parser_new (text,
+                                         file,
                                          gtk_css_scanner_parser_error,
                                          scanner);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]