mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-17 23:10:22 +00:00
gtksettings: Allow setting the GTK+ theme with an envvar
To test with Raleigh much easier.
This commit is contained in:
parent
08053cbbb8
commit
1e70ad1cd1
@ -2881,33 +2881,48 @@ 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);
|
||||
@ -2917,9 +2932,6 @@ settings_update_theme (GtkSettings *settings)
|
||||
|
||||
g_free (theme_dir);
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
g_free (theme_name);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user