[gimp/gtk3-port: 267/444] app: allow to select if we prefer a dark variant of the current theme.
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 267/444] app: allow to select if we prefer a dark variant of the current theme.
- Date: Sun, 13 May 2018 22:00:19 +0000 (UTC)
commit 015549c6c7786398c87591629255723363892e03
Author: Jehan <jehan girinstud io>
Date: Tue May 1 04:43:33 2018 +0200
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.
app/config/gimpguiconfig.c | 14 ++++++++++++++
app/config/gimpguiconfig.h | 1 +
app/dialogs/preferences-dialog.c | 4 ++++
app/gui/themes.c | 18 +++++++++++-------
4 files changed, 30 insertions(+), 7 deletions(-)
---
diff --git a/app/config/gimpguiconfig.c b/app/config/gimpguiconfig.c
index 72e263d..816f4ca 100644
--- a/app/config/gimpguiconfig.c
+++ b/app/config/gimpguiconfig.c
@@ -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;
diff --git a/app/config/gimpguiconfig.h b/app/config/gimpguiconfig.h
index 316f1d2..7b42549 100644
--- a/app/config/gimpguiconfig.h
+++ b/app/config/gimpguiconfig.h
@@ -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;
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 08b8f58..40e9fa4 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -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);
diff --git a/app/gui/themes.c b/app/gui/themes.c
index 54cf671..82801e4 100644
--- a/app/gui/themes.c
+++ b/app/gui/themes.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]