[gnome-text-editor] themeselector: remove .dark from window



commit c4052012a3dbaa82e43917d4e36511e458b9f109
Author: Christian Hergert <chergert redhat com>
Date:   Tue Dec 7 00:09:00 2021 -0800

    themeselector: remove .dark from window
    
    We don't need it there, it can be more localized.

 src/TextEditor.css          |  2 +-
 src/editor-application.c    | 26 --------------------------
 src/editor-theme-selector.c | 23 +++++++++++++++++++++++
 3 files changed, 24 insertions(+), 27 deletions(-)
---
diff --git a/src/TextEditor.css b/src/TextEditor.css
index d946bc5..5365ace 100644
--- a/src/TextEditor.css
+++ b/src/TextEditor.css
@@ -34,7 +34,7 @@
   background: linear-gradient(to bottom right, #fff 50%, #2e3436 50%);
   border-color: #2e3436;
 }
-.org-gnome-TextEditor.dark themeselector checkbutton.follow {
+.org-gnome-TextEditor themeselector.dark checkbutton.follow {
   border-color: #dcdddd;
 }
 .org-gnome-TextEditor themeselector checkbutton.light {
diff --git a/src/editor-application.c b/src/editor-application.c
index 2100bf9..d60637a 100644
--- a/src/editor-application.c
+++ b/src/editor-application.c
@@ -154,21 +154,6 @@ style_variant_to_color_scheme (GValue   *value,
   return TRUE;
 }
 
-static void
-update_dark (GtkWindow *window)
-{
-  AdwStyleManager *style_manager;
-
-  g_assert (GTK_IS_WINDOW (window));
-
-  style_manager = adw_style_manager_get_default ();
-
-  if (adw_style_manager_get_dark (style_manager))
-    gtk_widget_add_css_class (GTK_WIDGET (window), "dark");
-  else
-    gtk_widget_remove_css_class (GTK_WIDGET (window), "dark");
-}
-
 static void
 update_css (EditorApplication *self)
 {
@@ -199,16 +184,6 @@ on_style_manager_notify_dark (EditorApplication *self,
   g_assert (EDITOR_IS_APPLICATION (self));
   g_assert (ADW_IS_STYLE_MANAGER (style_manager));
 
-  for (const GList *iter = gtk_application_get_windows (GTK_APPLICATION (self));
-       iter != NULL;
-       iter = iter->next)
-    {
-      GtkWindow *window = iter->data;
-
-      if (EDITOR_IS_WINDOW (window))
-        update_dark (window);
-    }
-
   update_css (self);
 
   g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_STYLE_SCHEME]);
@@ -335,7 +310,6 @@ editor_application_window_added (GtkApplication *application,
 
   if (EDITOR_IS_WINDOW (window))
     {
-      update_dark (window);
 #if DEVELOPMENT_BUILD
       gtk_widget_add_css_class (GTK_WIDGET (window), "devel");
 #endif
diff --git a/src/editor-theme-selector.c b/src/editor-theme-selector.c
index 966ed7e..c8d5a27 100644
--- a/src/editor-theme-selector.c
+++ b/src/editor-theme-selector.c
@@ -66,6 +66,22 @@ on_notify_system_supports_color_schemes_cb (EditorThemeSelector *self,
   gtk_widget_set_visible (GTK_WIDGET (self->follow), visible);
 }
 
+static void
+on_notify_dark_cb (EditorThemeSelector *self,
+                   GParamSpec          *pspec,
+                   AdwStyleManager     *style_manager)
+{
+  g_assert (EDITOR_IS_THEME_SELECTOR (self));
+  g_assert (ADW_IS_STYLE_MANAGER (style_manager));
+
+  style_manager = adw_style_manager_get_default ();
+
+  if (adw_style_manager_get_dark (style_manager))
+    gtk_widget_add_css_class (GTK_WIDGET (self), "dark");
+  else
+    gtk_widget_remove_css_class (GTK_WIDGET (self), "dark");
+}
+
 static void
 editor_theme_selector_dispose (GObject *object)
 {
@@ -158,10 +174,17 @@ editor_theme_selector_init (EditorThemeSelector *self)
                            self,
                            G_CONNECT_SWAPPED);
 
+  g_signal_connect_object (style_manager,
+                           "notify::dark",
+                           G_CALLBACK (on_notify_dark_cb),
+                           self,
+                           G_CONNECT_SWAPPED);
+
   dark = adw_style_manager_get_dark (style_manager);
   self->theme = g_strdup (dark ? "dark" : "light");
 
   on_notify_system_supports_color_schemes_cb (self, NULL, style_manager);
+  on_notify_dark_cb (self, NULL, style_manager);
 }
 
 const char *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]