summaryrefslogtreecommitdiff
path: root/gtk/gtkcssprovider.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2014-11-12 18:20:35 -0500
committerMatthias Clasen <mclasen@redhat.com>2014-11-12 18:20:35 -0500
commit55fd3a762c4e4addc3716b6e9e1c1a6622ed7842 (patch)
tree718b15933ae6465120806e8c47a13a4d956c3226 /gtk/gtkcssprovider.c
parent6a618bf48c025aef7cd49248f4a2080247b2648b (diff)
downloadgtk+-55fd3a762c4e4addc3716b6e9e1c1a6622ed7842.tar.gz
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.
Diffstat (limited to 'gtk/gtkcssprovider.c')
-rw-r--r--gtk/gtkcssprovider.c84
1 files changed, 46 insertions, 38 deletions
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index b5b9a2e168..8b495d219b 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;