[gtk+] GtkCssProvider: Factor out a function



commit 55fd3a762c4e4addc3716b6e9e1c1a6622ed7842
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Nov 12 18:20:35 2014 -0500

    GtkCssProvider: Factor out a function
    
    Move finding the gtk.css file into its own function. We will
    make this more complicated in the near future.

 gtk/gtkcssprovider.c |   84 +++++++++++++++++++++++++++----------------------
 1 files changed, 46 insertions(+), 38 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index b5b9a2e..8b495d2 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -2956,6 +2956,50 @@ _gtk_css_provider_get_theme_dir (void)
   return path;
 }
 
+static gchar *
+_gtk_css_find_theme (const gchar *name,
+                     const gchar *variant)
+{
+  gchar *subpath;
+  gchar *path;
+
+  if (variant)
+    subpath = g_strdup_printf ("gtk-3.0" G_DIR_SEPARATOR_S "gtk-%s.css", variant);
+  else
+    subpath = g_strdup ("gtk-3.0" G_DIR_SEPARATOR_S "gtk.css");
+
+  /* First look in the user's config directory */
+  path = g_build_filename (g_get_user_data_dir (), "themes", name, subpath, NULL);
+  if (!g_file_test (path, G_FILE_TEST_EXISTS))
+    {
+      g_free (path);
+      /* Next look in the user's home directory
+       */
+      path = g_build_filename (g_get_home_dir (), ".themes", name, subpath, NULL);
+      if (!g_file_test (path, G_FILE_TEST_EXISTS))
+        {
+          gchar *theme_dir;
+
+          g_free (path);
+
+          /* Finally, try in the default theme directory */
+          theme_dir = _gtk_css_provider_get_theme_dir ();
+          path = g_build_filename (theme_dir, name, subpath, NULL);
+          g_free (theme_dir);
+
+          if (!g_file_test (path, G_FILE_TEST_EXISTS))
+            {
+              g_free (path);
+              path = NULL;
+            }
+        }
+    }
+
+  g_free (subpath);
+
+  return path;
+}
+
 /**
  * _gtk_css_provider_load_named:
  * @provider: a #GtkCssProvider
@@ -2997,44 +3041,8 @@ _gtk_css_provider_load_named (GtkCssProvider *provider,
     }
   g_free (resource_path);
 
-
-  /* Next try looking for files in the various theme directories.
-   */
-  if (variant)
-    subpath = g_strdup_printf ("gtk-3.0" G_DIR_SEPARATOR_S "gtk-%s.css", variant);
-  else
-    subpath = g_strdup ("gtk-3.0" G_DIR_SEPARATOR_S "gtk.css");
-
-  /* First look in the user's config directory
-   */
-  path = g_build_filename (g_get_user_data_dir (), "themes", name, subpath, NULL);
-  if (!g_file_test (path, G_FILE_TEST_EXISTS))
-    {
-      g_free (path);
-      /* Next look in the user's home directory
-       */
-      path = g_build_filename (g_get_home_dir (), ".themes", name, subpath, NULL);
-      if (!g_file_test (path, G_FILE_TEST_EXISTS))
-        {
-          gchar *theme_dir;
-
-          g_free (path);
-
-          /* Finally, try in the default theme directory */
-          theme_dir = _gtk_css_provider_get_theme_dir ();
-          path = g_build_filename (theme_dir, name, subpath, NULL);
-          g_free (theme_dir);
-
-          if (!g_file_test (path, G_FILE_TEST_EXISTS))
-            {
-              g_free (path);
-              path = NULL;
-            }
-        }
-    }
-
-  g_free (subpath);
-
+  /* Next try looking for files in the various theme directories. */
+  path = _gtk_css_find_theme (name, variant);
   if (path)
     {
       char *dir, *resource_file;


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