[gnome-shell/wip/fmuellner/ease-actors: 1038/1052] loginDialog: Use GObject bindings over onUpdate handler



commit a5545445b20dcd7336bf45c7bc2cfc939693f60f
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Jul 26 01:13:59 2019 +0000

    loginDialog: Use GObject bindings over onUpdate handler
    
    Instead of iterating over all actors each frame and sync'ing their
    opacities, we can set up bindings once before the animation.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/654

 js/gdm/loginDialog.js | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)
---
diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
index 2c21c6322..f0690de35 100644
--- a/js/gdm/loginDialog.js
+++ b/js/gdm/loginDialog.js
@@ -910,21 +910,18 @@ var LoginDialog = GObject.registerClass({
         if (this.opacity == 255 && this._authPrompt.verificationStatus == 
AuthPrompt.AuthPromptStatus.NOT_VERIFYING)
             return;
 
+        let bindings = Main.layoutManager.uiGroup.get_children()
+            .filter(c => c != Main.layoutManager.screenShieldGroup)
+            .map(c => this.bind_property('opacity', c, 'opacity', 0));
+
         Tweener.addTween(this,
                          { opacity: 255,
                            time: _FADE_ANIMATION_TIME / 1000,
                            transition: 'easeOutQuad',
-                           onUpdate: () => {
-                               let children = Main.layoutManager.uiGroup.get_children();
-
-                               for (let i = 0; i < children.length; i++) {
-                                   if (children[i] != Main.layoutManager.screenShieldGroup)
-                                       children[i].opacity = this.opacity;
-                               }
-                           },
                            onComplete: () => {
                                if (this._authPrompt.verificationStatus != 
AuthPrompt.AuthPromptStatus.NOT_VERIFYING)
                                    this._authPrompt.reset();
+                               bindings.forEach(b => b.unbind());
                            } });
     }
 
@@ -938,20 +935,17 @@ var LoginDialog = GObject.registerClass({
     }
 
     _startSession(serviceName) {
+        let bindings = Main.layoutManager.uiGroup.get_children()
+            .filter(c => c != Main.layoutManager.screenShieldGroup)
+            .map(c => this.bind_property('opacity', c, 'opacity', 0));
+
         Tweener.addTween(this,
                          { opacity: 0,
                            time: _FADE_ANIMATION_TIME / 1000,
                            transition: 'easeOutQuad',
-                           onUpdate: () => {
-                               let children = Main.layoutManager.uiGroup.get_children();
-
-                               for (let i = 0; i < children.length; i++) {
-                                   if (children[i] != Main.layoutManager.screenShieldGroup)
-                                       children[i].opacity = this.opacity;
-                               }
-                           },
                            onComplete: () => {
                                this._greeter.call_start_session_when_ready_sync(serviceName, true, null);
+                               bindings.forEach(b => b.unbind());
                            } });
     }
 


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