Commit 23649d65 authored by Jehan's avatar Jehan Committed by Michael Natterer

app: allow to select if we prefer a dark variant of the current theme.

GTK+ has the concept of theme variants, and in particular if we prefer
the dark variant of a theme. This can be chosen globally but also
per-application. Make this choice customizable in the Theme tab of
Preferences.
By default, the dark variant will be prefered.
parent 4f0a87ff
......@@ -76,6 +76,7 @@ enum
PROP_TOOLBOX_WILBER,
PROP_THEME_PATH,
PROP_THEME,
PROP_PREFER_DARK_THEME,
PROP_ICON_THEME_PATH,
PROP_ICON_THEME,
PROP_ICON_SIZE,
......@@ -323,6 +324,13 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
GIMP_CONFIG_DEFAULT_THEME,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_PREFER_DARK_THEME,
"prefer-dark-theme",
"Prefer Dark Theme",
THEME_BLURB,
TRUE,
GIMP_PARAM_STATIC_STRINGS);
path = gimp_config_build_data_path ("icons");
GIMP_CONFIG_PROP_PATH (object_class, PROP_ICON_THEME_PATH,
"icon-theme-path",
......@@ -645,6 +653,9 @@ gimp_gui_config_set_property (GObject *object,
g_free (gui_config->theme);
gui_config->theme = g_value_dup_string (value);
break;
case PROP_PREFER_DARK_THEME:
gui_config->prefer_dark_theme = g_value_get_boolean (value);
break;
case PROP_ICON_THEME_PATH:
g_free (gui_config->icon_theme_path);
gui_config->icon_theme_path = g_value_dup_string (value);
......@@ -828,6 +839,9 @@ gimp_gui_config_get_property (GObject *object,
case PROP_THEME:
g_value_set_string (value, gui_config->theme);
break;
case PROP_PREFER_DARK_THEME:
g_value_set_boolean (value, gui_config->prefer_dark_theme);
break;
case PROP_ICON_THEME_PATH:
g_value_set_string (value, gui_config->icon_theme_path);
break;
......
......@@ -65,6 +65,7 @@ struct _GimpGuiConfig
gboolean toolbox_wilber;
gchar *theme_path;
gchar *theme;
gboolean prefer_dark_theme;
gchar *icon_theme_path;
gchar *icon_theme;
GimpIconSize icon_size;
......
......@@ -1874,6 +1874,10 @@ prefs_dialog_new (Gimp *gimp,
gimp);
}
prefs_check_button_add (object, "prefer-dark-theme",
_("Use dark theme variant if available"),
GTK_BOX (vbox2));
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
......
......@@ -131,11 +131,6 @@ themes_init (Gimp *gimp)
g_list_free_full (path, (GDestroyNotify) g_object_unref);
}
g_object_set (gtk_settings_get_for_screen (gdk_screen_get_default ()),
"gtk-application-prefer-dark-theme", TRUE,
NULL);
themes_style_provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
/* Use GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 1 so theme files
......@@ -150,6 +145,9 @@ themes_init (Gimp *gimp)
g_signal_connect (config, "notify::theme",
G_CALLBACK (themes_theme_change_notify),
gimp);
g_signal_connect (config, "notify::prefer-dark-theme",
G_CALLBACK (themes_theme_change_notify),
gimp);
themes_theme_change_notify (config, NULL, gimp);
}
......@@ -382,8 +380,14 @@ themes_theme_change_notify (GimpGuiConfig *config,
GParamSpec *pspec,
Gimp *gimp)
{
GFile *theme_css;
GError *error = NULL;
GFile *theme_css;
GError *error = NULL;
gboolean prefer_dark_theme;
g_object_get (config, "prefer-dark-theme", &prefer_dark_theme, NULL);
g_object_set (gtk_settings_get_for_screen (gdk_screen_get_default ()),
"gtk-application-prefer-dark-theme", prefer_dark_theme,
NULL);
themes_apply_theme (gimp, config->theme);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment