[gtk+/parser: 59/79] cssprovider: Introduce gtk_css_provider_take_error_full()



commit 9fd25aed63d1092855fe14b1d8a5e9802ef9547e
Author: Benjamin Otte <otte redhat com>
Date:   Mon Apr 11 20:06:39 2011 +0200

    cssprovider: Introduce gtk_css_provider_take_error_full()
    
    Emits the error without the need for a scanner. Also simplifies
    gtk_css_provider_take_error() because we now can assert an available
    scanner at all times.

 gtk/gtkcssprovider.c |   60 ++++++++++++++++++++++++++-----------------------
 1 files changed, 32 insertions(+), 28 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index fa75c1e..703f43f 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -846,9 +846,6 @@ static gboolean gtk_css_provider_load_from_path_internal (GtkCssProvider  *css_p
                                                           const gchar     *path,
                                                           gboolean         reset,
                                                           GError         **error);
-static void     gtk_css_provider_take_error (GtkCssProvider *provider,
-                                             GScanner       *scanner,
-                                             GError         *error);
 
 GQuark
 gtk_css_provider_error_quark (void)
@@ -926,6 +923,27 @@ gtk_css_provider_class_init (GtkCssProviderClass *klass)
   g_type_class_add_private (object_class, sizeof (GtkCssProviderPrivate));
 }
 
+static void
+gtk_css_provider_take_error_full (GtkCssProvider *provider,
+                                  GFile          *file,
+                                  guint           line,
+                                  guint           position,
+                                  GError         *error)
+{
+  char *filename;
+
+  if (file)
+    filename = g_file_get_path (file);
+  else
+    filename = NULL;
+
+  g_signal_emit (provider, css_provider_signals[PARSING_ERROR], 0,
+                 filename, line, position, error);
+
+  g_free (filename);
+  g_error_free (error);
+}
+
 static SelectorPath *
 selector_path_new (void)
 {
@@ -1582,7 +1600,11 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider,
           if (found)
             break;
           
-          gtk_css_provider_take_error (GTK_CSS_PROVIDER (provider), NULL, error);
+          /* error location should be _way_ better */
+          gtk_css_provider_take_error_full (GTK_CSS_PROVIDER (provider),
+                                            NULL,
+                                            0, 0,
+                                            error);
         }
     }
 
@@ -1634,31 +1656,13 @@ gtk_css_provider_take_error (GtkCssProvider *provider,
                              GScanner       *scanner,
                              GError         *error)
 {
-  char *filename;
-  guint line, position;
-
-  if (scanner)
-    {
-      GtkCssScannerPrivate *priv = scanner->user_data;
-      if (priv->file)
-        filename = g_file_get_path (priv->file);
-      else
-        filename = NULL;
-      line = scanner->line;
-      position = scanner->position;
-    }
-  else
-    {
-      filename = NULL;
-      line = 0;
-      position = 0;
-    }
-
-  g_signal_emit (provider, css_provider_signals[PARSING_ERROR], 0,
-                 filename, line, position, error);
+  GtkCssScannerPrivate *priv = scanner->user_data;
 
-  g_free (filename);
-  g_error_free (error);
+  gtk_css_provider_take_error_full (provider,
+                                    priv->file,
+                                    scanner->line,
+                                    scanner->position,
+                                    error);
 }
 
 static void



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