[libhandy/wip/exalm/-dark: 3/3] style-manager: Don't allow setting themes with -dark in the name
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy/wip/exalm/-dark: 3/3] style-manager: Don't allow setting themes with -dark in the name
- Date: Mon, 14 Mar 2022 14:20:00 +0000 (UTC)
commit 14bd98a043b35ff054c00ce3851fc79a9eb5b4e1
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Mon Mar 14 15:21:07 2022 +0400
style-manager: Don't allow setting themes with -dark in the name
For example, set Yaru if Yaru-dark is set, so that
HdyStyleManager:color-scheme keeps working.
src/hdy-style-manager.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/src/hdy-style-manager.c b/src/hdy-style-manager.c
index 34f79593..c4865638 100644
--- a/src/hdy-style-manager.c
+++ b/src/hdy-style-manager.c
@@ -216,14 +216,6 @@ get_system_theme_name (void)
return g_value_dup_string (&value);
}
-static gboolean
-check_current_theme_exists (gboolean dark)
-{
- g_autofree gchar *theme_name = get_system_theme_name ();
-
- return check_theme_exists (theme_name, dark ? "dark" : NULL);
-}
-
static void
warn_prefer_dark_theme (HdyStyleManager *self)
{
@@ -321,15 +313,25 @@ update_stylesheet (HdyStyleManager *self)
"gtk-application-prefer-dark-theme", self->dark,
NULL);
- if (hdy_settings_get_high_contrast (self->settings))
+ if (hdy_settings_get_high_contrast (self->settings)) {
g_object_set (gtk_settings,
"gtk-theme-name",
self->dark ? "HighContrastInverse" : "HighContrast",
NULL);
- else if (check_current_theme_exists (self->dark))
- gtk_settings_reset_property (gtk_settings, "gtk-theme-name");
- else
- g_object_set (gtk_settings, "gtk-theme-name", "Adwaita", NULL);
+ } else {
+ g_autofree gchar *theme_name = get_system_theme_name ();
+ gboolean override_theme = FALSE;
+
+ if (g_str_has_suffix (theme_name, "-dark")) {
+ theme_name[strlen (theme_name) - 5] = '\0';
+ override_theme = TRUE;
+ }
+
+ if (!check_theme_exists (theme_name, self->dark ? "dark" : NULL))
+ g_object_set (gtk_settings, "gtk-theme-name", "Adwaita", NULL);
+ else if (override_theme)
+ g_object_set (gtk_settings, "gtk-theme-name", theme_name, NULL);
+ }
g_signal_handlers_unblock_by_func (gtk_settings,
G_CALLBACK (warn_prefer_dark_theme),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]