[gtk+/parser: 61/80] cssprovider: Reimplement gtk_css_provider_load_from_path()



commit 8c6e3ba0b96dc8f4b8787b04109258eae7681232
Author: Benjamin Otte <otte redhat com>
Date:   Tue Apr 12 01:22:16 2011 +0200

    cssprovider: Reimplement gtk_css_provider_load_from_path()
    
    Call gtk_css_provider_load_from_file() instead of the internal function.
    This has two advantages:
    1) It simplifies the code a lot
    2) It gets rid of GMappedFile usage. GMappedFile does not work
       everywhere, so this is finally portable.

 gtk/gtkcssprovider.c |   55 +++++++++----------------------------------------
 1 files changed, 10 insertions(+), 45 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index f0f2649..c746b4c 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -2739,49 +2739,6 @@ gtk_css_provider_load_from_file (GtkCssProvider  *css_provider,
   return gtk_css_provider_load_internal (css_provider, file, NULL, 0, error);
 }
 
-static gboolean
-gtk_css_provider_load_from_path_internal (GtkCssProvider  *css_provider,
-                                          const gchar     *path,
-                                          gboolean         reset,
-                                          GError         **error)
-{
-  GtkCssProviderPrivate *priv;
-  GError *internal_error = NULL;
-  GMappedFile *mapped_file;
-  const gchar *data;
-  gsize length;
-  GFile *file;
-  gboolean ret;
-
-  priv = css_provider->priv;
-
-  mapped_file = g_mapped_file_new (path, FALSE, &internal_error);
-
-  if (internal_error)
-    {
-      g_propagate_error (error, internal_error);
-      return FALSE;
-    }
-
-  length = g_mapped_file_get_length (mapped_file);
-  data = g_mapped_file_get_contents (mapped_file);
-
-  if (!data)
-    data = "";
-
-  if (reset)
-    gtk_css_provider_reset (css_provider);
-
-  file = g_file_new_for_path (path);
-
-  ret = gtk_css_provider_load_internal (css_provider, file, data, length, error);
-
-  g_object_unref (file);
-  g_mapped_file_unref (mapped_file);
-
-  return ret;
-}
-
 /**
  * gtk_css_provider_load_from_path:
  * @css_provider: a #GtkCssProvider
@@ -2798,11 +2755,19 @@ gtk_css_provider_load_from_path (GtkCssProvider  *css_provider,
                                  const gchar     *path,
                                  GError         **error)
 {
+  GFile *file;
+  gboolean result;
+
   g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE);
   g_return_val_if_fail (path != NULL, FALSE);
 
-  return gtk_css_provider_load_from_path_internal (css_provider, path,
-                                                   TRUE, error);
+  file = g_file_new_for_path (path);
+  
+  result = gtk_css_provider_load_from_file (css_provider, file, error);
+
+  g_object_unref (file);
+
+  return result;
 }
 
 /**



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