[gtk+] Revert "cssprovider: Remove unused members from scanner"



commit a8d8c02ab756db3b78a7c0714997cc847f8e4f3e
Author: Benjamin Otte <otte redhat com>
Date:   Fri May 11 16:41:25 2012 +0200

    Revert "cssprovider: Remove unused members from scanner"
    
    This reverts commit b501e64a8a78e78c49b0abd1f34fc554ccacfd65.

 gtk/gtkcssprovider.c |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 2569bd9..128edc3 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -999,6 +999,8 @@ struct _GtkCssScanner
   GtkCssParser *parser;
   GtkCssSection *section;
   GtkCssScanner *parent;
+  GFile *file;
+  GFile *base;
   GSList *state;
 };
 
@@ -1309,6 +1311,9 @@ gtk_css_scanner_destroy (GtkCssScanner *scanner)
   if (scanner->section)
     gtk_css_section_unref (scanner->section);
   g_object_unref (scanner->provider);
+  if (scanner->file)
+    g_object_unref (scanner->file);
+  g_object_unref (scanner->base);
   _gtk_css_parser_free (scanner->parser);
 
   g_slice_free (GtkCssScanner, scanner);
@@ -1352,6 +1357,18 @@ gtk_css_scanner_new (GtkCssProvider *provider,
   if (section)
     scanner->section = gtk_css_section_ref (section);
 
+  if (file)
+    {
+      scanner->file = g_object_ref (file);
+      scanner->base = g_file_get_parent (file);
+    }
+  else
+    {
+      char *dir = g_get_current_dir ();
+      scanner->base = g_file_new_for_path (dir);
+      g_free (dir);
+    }
+
   scanner->parser = _gtk_css_parser_new (text,
                                          gtk_css_scanner_parser_error,
                                          scanner);
@@ -1359,14 +1376,19 @@ gtk_css_scanner_new (GtkCssProvider *provider,
   return scanner;
 }
 
+static GFile *
+gtk_css_scanner_get_base_url (GtkCssScanner *scanner)
+{
+  return scanner->base;
+}
+
 static gboolean
 gtk_css_scanner_would_recurse (GtkCssScanner *scanner,
                                GFile         *file)
 {
   while (scanner)
     {
-      GFile *parser_file = _gtk_css_parser_get_file (scanner->parser);
-      if (parser_file && g_file_equal (parser_file, file))
+      if (scanner->file && g_file_equal (scanner->file, file))
         return TRUE;
 
       scanner = scanner->parent;
@@ -1871,7 +1893,7 @@ parse_import (GtkCssScanner *scanner)
       char *uri;
 
       uri = _gtk_css_parser_read_string (scanner->parser);
-      file = _gtk_css_parser_get_file_for_path (scanner->parser, uri);
+      file = g_file_resolve_relative_path (gtk_css_scanner_get_base_url (scanner), uri);
       g_free (uri);
     }
   else



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