[gnome-shell/wip/carlosg/cleanup-gtk-usage: 38/40] tweener: Use GSettings instead of GtkSettings



commit c445331ab1ed0fc3bf67ca7d59015d81cf3d3742
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Nov 27 14:52:06 2018 +0100

    tweener: Use GSettings instead of GtkSettings
    
    Cut a middle man by listening to dconf settings directly, and stop relying
    on XSettings for it.

 js/ui/tweener.js | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/tweener.js b/js/ui/tweener.js
index 6c9869c47..4df291e0c 100644
--- a/js/ui/tweener.js
+++ b/js/ui/tweener.js
@@ -1,14 +1,17 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
 const Clutter = imports.gi.Clutter;
+const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
-const Gtk = imports.gi.Gtk;
 const Mainloop = imports.mainloop;
 const Shell = imports.gi.Shell;
 const St = imports.gi.St;
 const Signals = imports.signals;
 const Tweener = imports.tweener.tweener;
 
+var _animSettings = null;
+var _animationsEnabled = true;
+
 // This is a wrapper around imports.tweener.tweener that adds a bit of
 // Clutter integration. If the tweening target is a Clutter.Actor, then
 // the tweenings will automatically be removed if the actor is destroyed.
@@ -52,7 +55,15 @@ function _wrapTweening(target, tweeningParameters) {
         }
     }
 
-    if (!Gtk.Settings.get_default().gtk_enable_animations) {
+    if (_animSettings == null) {
+        _animSettings = new Gio.Settings ({ schema_id: 'org.gnome.desktop.interface' });
+        _animSettings.connect('changed::enable-animations', () => {
+            _animationsEnabled = _animSettings.get_boolean('enable-animations');
+        });
+        _animationsEnabled = _animSettings.get_boolean('enable-animations');
+    }
+
+    if (!_animationsEnabled) {
         tweeningParameters['time'] = 0.000001;
         tweeningParameters['delay'] = 0.000001;
     }


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