[gtk+] gtksettings: Allow setting the GTK+ theme with an envvar
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gtksettings: Allow setting the GTK+ theme with an envvar
- Date: Fri, 1 Nov 2013 20:19:15 +0000 (UTC)
commit 1e70ad1cd126942b38e83c2d01712e8dc7ca675e
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Nov 1 16:03:56 2013 -0400
gtksettings: Allow setting the GTK+ theme with an envvar
To test with Raleigh much easier.
gtk/gtksettings.c | 56 ++++++++++++++++++++++++++++++++--------------------
1 files changed, 34 insertions(+), 22 deletions(-)
---
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index 140d15b..e61a4b7 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -2881,45 +2881,57 @@ settings_update_provider (GdkScreen *screen,
}
}
+static char *
+get_theme_name (GtkSettings *settings)
+{
+ char *theme_name = NULL;
+
+ if (g_getenv ("GTK_THEME"))
+ theme_name = g_strdup (g_getenv ("GTK_THEME"));
+
+ if (theme_name && *theme_name)
+ return theme_name;
+
+ g_free (theme_name);
+ g_object_get (settings,
+ "gtk-theme-name", &theme_name,
+ NULL);
+
+ if (theme_name && *theme_name)
+ return theme_name;
+
+ g_free (theme_name);
+ return g_strdup ("Raleigh");
+}
+
static void
settings_update_theme (GtkSettings *settings)
{
GtkSettingsPrivate *priv = settings->priv;
gboolean prefer_dark_theme;
gchar *theme_name;
+ gchar *theme_dir;
+ gchar *path;
g_object_get (settings,
- "gtk-theme-name", &theme_name,
"gtk-application-prefer-dark-theme", &prefer_dark_theme,
NULL);
- if (!theme_name || !*theme_name)
- {
- g_free (theme_name);
- theme_name = g_strdup ("Raleigh");
- }
-
+ theme_name = get_theme_name (settings);
+
_gtk_css_provider_load_named (priv->theme_provider,
theme_name,
prefer_dark_theme ? "dark" : NULL);
- if (theme_name && *theme_name)
- {
- gchar *theme_dir;
- gchar *path;
-
- /* reload per-theme settings */
- theme_dir = _gtk_css_provider_get_theme_dir ();
- path = g_build_filename (theme_dir, theme_name, "gtk-3.0", "settings.ini", NULL);
-
- if (g_file_test (path, G_FILE_TEST_EXISTS))
- gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_THEME);
+ /* reload per-theme settings */
+ theme_dir = _gtk_css_provider_get_theme_dir ();
+ path = g_build_filename (theme_dir, theme_name, "gtk-3.0", "settings.ini", NULL);
- g_free (theme_dir);
- g_free (path);
- }
+ if (g_file_test (path, G_FILE_TEST_EXISTS))
+ gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_THEME);
- g_free (theme_name);
+ g_free (theme_dir);
+ g_free (path);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]