[gnome-builder] Revert "app: avoid immediate second parse of the theme in some cases"



commit cad2e3f3acf3bd4044ecfbb0b35103592212ecb1
Author: Christian Hergert <chergert redhat com>
Date:   Mon Nov 13 05:34:11 2017 -0800

    Revert "app: avoid immediate second parse of the theme in some cases"
    
    This reverts commit 110736a4be5b1b70dc238d299ce4c43a07f22137.

 src/libide/application/ide-application.c |   58 ++---------------------------
 1 files changed, 4 insertions(+), 54 deletions(-)
---
diff --git a/src/libide/application/ide-application.c b/src/libide/application/ide-application.c
index 3669eec..5842a87 100644
--- a/src/libide/application/ide-application.c
+++ b/src/libide/application/ide-application.c
@@ -370,37 +370,6 @@ ide_application_language_defaults_cb (GObject      *object,
 }
 
 static void
-gtk_changed_dark_mode (GtkSettings    *settings,
-                       GParamSpec     *pspec,
-                       IdeApplication *self)
-{
-  gboolean value;
-
-  g_object_get (settings,
-                "gtk-application-prefer-dark-theme", &value,
-                NULL);
-  if (value != g_settings_get_boolean (self->settings, "night-mode"))
-    g_settings_set_boolean (self->settings, "night-mode", value);
-}
-
-static void
-settings_changed_dark_mode (GSettings      *settings,
-                            const gchar    *key,
-                            IdeApplication *self)
-{
-  GtkSettings *gtk_settings = gtk_settings_get_default ();
-  gboolean value;
-
-  g_object_get (gtk_settings,
-                "gtk-application-prefer-dark-theme", &value,
-                NULL);
-  if (value != g_settings_get_boolean (settings, "night-mode"))
-    g_object_set (gtk_settings,
-                  "gtk-application-prefer-dark-theme", value,
-                  NULL);
-}
-
-static void
 ide_application_register_settings (IdeApplication *self)
 {
   IDE_ENTRY;
@@ -410,29 +379,10 @@ ide_application_register_settings (IdeApplication *self)
   if (g_getenv ("GTK_THEME") == NULL)
     {
       GtkSettings *gtk_settings = gtk_settings_get_default ();
-      gboolean night_mode = g_settings_get_boolean (self->settings, "night-mode");
-
-      /*
-       * This tries to avoid using g_settings_bind() because it will always
-       * apply the initial value from settings. We want to avoid that in the
-       * case that night_mode is not set because it doesn't cause an immediate
-       * reloading of the theme.
-       */
-
-      g_signal_connect_object (gtk_settings,
-                               "notify::gtk-application-prefer-dark-theme",
-                               G_CALLBACK (gtk_changed_dark_mode),
-                               self,
-                               0);
-      g_signal_connect_object (self->settings,
-                               "changed::night-mode",
-                               G_CALLBACK (settings_changed_dark_mode),
-                               self,
-                               0);
-      if (night_mode)
-        g_object_set (gtk_settings,
-                      "gtk-application-prefer-dark-theme", TRUE,
-                      NULL);
+
+      g_settings_bind (self->settings, "night-mode",
+                       gtk_settings, "gtk-application-prefer-dark-theme",
+                       G_SETTINGS_BIND_DEFAULT);
     }
 
   IDE_EXIT;


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