[gnome-documents] embed: wait until sidebar fades in before switching mode



commit f324487a8bbfe16242fbfbd3f4bfb59b0ac52444
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Oct 31 21:50:49 2011 -0400

    embed: wait until sidebar fades in before switching mode
    
    This makes going back from preview a lot smoother, as GTK doesn't have
    to relayout the icon view while the sidebar moves.
    In the future we might want to use a fancier effect here.

 src/embed.js   |   18 +++++++++++++++---
 src/filters.js |   13 +++++++++++++
 src/sidebar.js |   12 ++++++++++--
 3 files changed, 38 insertions(+), 5 deletions(-)
---
diff --git a/src/embed.js b/src/embed.js
index 3c645a8..e57dcba 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -151,10 +151,22 @@ ViewEmbed.prototype  = {
     _onWindowModeChanged: function() {
         let mode = Global.modeController.getWindowMode();
 
-        if (mode == WindowMode.WindowMode.OVERVIEW)
-            this._prepareForOverview();
-        else
+        if (mode == WindowMode.WindowMode.OVERVIEW) {
+            // if the sidebar is visible, wait until it completed fading in before
+            // putting back the view
+            if (Global.sideFilterController.getSidebarVisible()) {
+                let sidebarInId =
+                    Global.sideFilterController.connect('sidebar-in-changed', Lang.bind(this,
+                        function() {
+                            Global.sideFilterController.disconnect(sidebarInId);
+                            this._prepareForOverview();
+                        }));
+            } else {
+                this._prepareForOverview();
+            }
+        } else {
             this._prepareForPreview();
+        }
     },
 
     _destroyScrollPreviewChild: function() {
diff --git a/src/filters.js b/src/filters.js
index 45cd7b2..0dfe069 100644
--- a/src/filters.js
+++ b/src/filters.js
@@ -102,6 +102,7 @@ SideFilterController.prototype = {
         this._whereItem = Global.categoryManager.getActiveItem();
 
         this._sidebarVisible = true;
+        this._sidebarIn = false;
     },
 
     setActiveItem: function(controller, item) {
@@ -126,6 +127,18 @@ SideFilterController.prototype = {
         return this._sidebarVisible;
     },
 
+    setSidebarIn: function(setting) {
+        if (this._sidebarIn == setting)
+            return;
+
+        this._sidebarIn = setting;
+        this.emit('sidebar-in-changed', this._sidebarIn);
+    },
+
+    getSidebarIn: function() {
+        return this._sidebarIn;
+    },
+
     getWhere: function() {
         if (!this._whereItem)
             return '';
diff --git a/src/sidebar.js b/src/sidebar.js
index 20cf6b0..9cad582 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -383,13 +383,21 @@ Sidebar.prototype = {
     _moveOut: function() {
         Tweener.addTween(this.actor, { width: 0,
                                        time: 0.15,
-                                       transition: 'easeInQuad' });
+                                       transition: 'easeInQuad',
+                                       onComplete: function() {
+                                           Global.sideFilterController.setSidebarIn(false);
+                                       },
+                                       onCompleteScope: this });
     },
 
     _moveIn: function() {
         Tweener.addTween(this.actor, { width: this.widget.get_preferred_width()[1],
                                        time: 0.15,
-                                       transition: 'easeOutQuad' });
+                                       transition: 'easeOutQuad',
+                                       onComplete: function() {
+                                           Global.sideFilterController.setSidebarIn(true);
+                                       },
+                                       onCompleteScope: this });
     },
 
     _onWindowModeChanged: function(controller, mode) {



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