[gnome-builder] app: disable theme tracking in IdeApplication



commit 5677e1a59990d30410ba2ac039ff8a84aca070ed
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jun 5 14:54:16 2017 -0700

    app: disable theme tracking in IdeApplication
    
    This should mostly be handled for us by DzlApplication now. We do still
    need to setup settings tracking for our nighthack/dayhack stuff.

 libide/application/ide-application-private.h |    6 --
 libide/application/ide-application.c         |   89 +++++++-------------------
 libide/preferences/ide-preferences-builtin.c |    2 +-
 3 files changed, 25 insertions(+), 72 deletions(-)
---
diff --git a/libide/application/ide-application-private.h b/libide/application/ide-application-private.h
index 65de80f..c7c5cf4 100644
--- a/libide/application/ide-application-private.h
+++ b/libide/application/ide-application-private.h
@@ -27,7 +27,6 @@
 #include "gsettings/ide-language-defaults.h"
 #include "keybindings/ide-keybindings.h"
 #include "projects/ide-recent-projects.h"
-#include "theming/ide-theme-manager.h"
 #include "workers/ide-worker-manager.h"
 
 G_BEGIN_DECLS
@@ -53,8 +52,6 @@ struct _IdeApplication
 
   GDateTime           *started_at;
 
-  IdeThemeManager     *theme_manager;
-
   GHashTable          *plugin_css;
   GHashTable          *plugin_gresources;
 
@@ -63,8 +60,6 @@ struct _IdeApplication
   GHashTable          *plugin_settings;
 
   GPtrArray           *reapers;
-
-  guint                disable_theme_tracking : 1;
 };
 
 void     ide_application_discover_plugins           (IdeApplication        *self) G_GNUC_INTERNAL;
@@ -75,7 +70,6 @@ gboolean ide_application_local_command_line         (GApplication          *appl
                                                      gchar               ***arguments,
                                                      gint                  *exit_status) G_GNUC_INTERNAL;
 void     ide_application_run_tests                  (IdeApplication        *self);
-gboolean ide_application_get_disable_theme_tracking (IdeApplication        *self) G_GNUC_INTERNAL;
 void     ide_application_open_async                 (IdeApplication        *self,
                                                      GFile                **files,
                                                      gint                   n_files,
diff --git a/libide/application/ide-application.c b/libide/application/ide-application.c
index 8d60e36..a421fb1 100644
--- a/libide/application/ide-application.c
+++ b/libide/application/ide-application.c
@@ -92,61 +92,6 @@ ide_application_make_skeleton_dirs (IdeApplication *self)
 }
 
 static void
-ide_application_register_theme_overrides (IdeApplication *self)
-{
-  g_autoptr(GSettings) settings = NULL;
-  GtkSettings *gtk_settings;
-  GdkScreen *screen;
-  gboolean wants_dark_theme = FALSE;
-
-  IDE_ENTRY;
-
-  g_assert (IDE_IS_APPLICATION (self));
-
-  screen = gdk_screen_get_default ();
-  gtk_settings = gtk_settings_get_for_screen (screen);
-  settings = g_settings_new ("org.gnome.builder");
-
-  /*
-   * As early as possible, overwrite the gtk theme if we are running in
-   * flatpak. We want to ensure that we provide the best visual appearance
-   * that we can, for which we only support the internal Gtk theme currently.
-   *
-   * If we can get a designer that manages other themes and keeps them up
-   * to date and working inside flatpak, we can consider doing something
-   * different here.
-   */
-  if (ide_is_flatpak () && g_getenv ("GTK_THEME") == NULL)
-    {
-      g_object_set (gtk_settings,
-                    "gtk-theme-name", "Adwaita",
-                    NULL);
-    }
-
-  self->theme_manager = ide_theme_manager_new ();
-
-  /*
-   * Some users override the "default to dark theme" in gnome-tweak-tool,
-   * which means if they haven't selected the dark theme, we will
-   * inadvertantly set the application to light-mode. If we detect this,
-   * we will avoid tracking the dark status.
-   */
-  g_object_get (gtk_settings,
-                "gtk-application-prefer-dark-theme", &wants_dark_theme,
-                NULL);
-
-  if (wants_dark_theme || g_getenv ("GTK_THEME") != NULL)
-    self->disable_theme_tracking = TRUE;
-
-  if (!self->disable_theme_tracking)
-    g_settings_bind (settings, "night-mode",
-                     gtk_settings, "gtk-application-prefer-dark-theme",
-                     G_SETTINGS_BIND_DEFAULT);
-
-  IDE_EXIT;
-}
-
-static void
 ide_application_register_keybindings (IdeApplication *self)
 {
   g_autoptr(GSettings) settings = NULL;
@@ -374,6 +319,29 @@ ide_application_language_defaults_cb (GObject      *object,
 }
 
 static void
+ide_application_register_settings (IdeApplication *self)
+{
+  IDE_ENTRY;
+
+  g_assert (IDE_IS_APPLICATION (self));
+
+  if (g_getenv ("GTK_THEME") == NULL)
+    {
+      g_autoptr(GSettings) settings = NULL;
+      GtkSettings *gtk_settings;
+
+      settings = g_settings_new ("org.gnome.builder");
+      gtk_settings = gtk_settings_get_default ();
+
+      g_settings_bind (settings, "night-mode",
+                     gtk_settings, "gtk-application-prefer-dark-theme",
+                     G_SETTINGS_BIND_DEFAULT);
+    }
+
+  IDE_EXIT;
+}
+
+static void
 ide_application_startup (GApplication *application)
 {
   IdeApplication *self = (IdeApplication *)application;
@@ -394,7 +362,7 @@ ide_application_startup (GApplication *application)
     {
       ide_application_make_skeleton_dirs (self);
       ide_language_defaults_init_async (NULL, ide_application_language_defaults_cb, NULL);
-      ide_application_register_theme_overrides (self);
+      ide_application_register_settings (self);
       ide_application_register_keybindings (self);
       ide_application_actions_init (self);
 
@@ -495,7 +463,6 @@ ide_application_finalize (GObject *object)
   g_clear_object (&self->worker_manager);
   g_clear_object (&self->keybindings);
   g_clear_object (&self->recent_projects);
-  g_clear_object (&self->theme_manager);
 
   G_OBJECT_CLASS (ide_application_parent_class)->finalize (object);
 }
@@ -803,14 +770,6 @@ ide_application_open_project (IdeApplication *self,
     return FALSE;
 }
 
-gboolean
-ide_application_get_disable_theme_tracking (IdeApplication *self)
-{
-  g_return_val_if_fail (IDE_IS_APPLICATION (self), FALSE);
-
-  return self->disable_theme_tracking;
-}
-
 /**
  * ide_application_get_main_thread:
  *
diff --git a/libide/preferences/ide-preferences-builtin.c b/libide/preferences/ide-preferences-builtin.c
index 9fed1fe..345e97a 100644
--- a/libide/preferences/ide-preferences-builtin.c
+++ b/libide/preferences/ide-preferences-builtin.c
@@ -128,7 +128,7 @@ ide_preferences_builtin_register_appearance (IdePreferences *preferences)
       ide_preferences_add_radio (preferences, "appearance", "schemes", "org.gnome.builder.editor", 
"style-scheme-name", NULL, variant_str, title, NULL, title, i);
     }
 
-  if (ide_application_get_disable_theme_tracking (IDE_APPLICATION_DEFAULT))
+  if (g_getenv ("GTK_THEME") != NULL)
     {
       bin = ide_preferences_get_widget (preferences, dark_mode);
       gtk_widget_set_sensitive (bin, FALSE);


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