[gnome-shell/wip/overview-transition: 78/79] viewSelector: Move to a sync() model for deciding which page to show



commit 51e63233cecdc165d318e65c16b1eeead072a901
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Jan 14 09:21:34 2014 -0500

    viewSelector: Move to a sync() model for deciding which page to show
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722196

 js/ui/viewSelector.js |   64 +++++++++++++++++++++++-------------------------
 1 files changed, 31 insertions(+), 33 deletions(-)
---
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index be046b1..ab16fdd 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -118,13 +118,13 @@ const ViewSelector = new Lang.Class({
         this._stageKeyPressId = 0;
         Main.overview.connect('showing', Lang.bind(this,
             function () {
-                this._resetShowAppsButton();
+                this._showAppsButton.checked = false;
                 this._stageKeyPressId = global.stage.connect('key-press-event',
                                                              Lang.bind(this, this._onStageKeyPress));
             }));
         Main.overview.connect('hiding', Lang.bind(this,
             function () {
-                this._resetShowAppsButton();
+                this._showAppsButton.checked = false;
                 if (this._stageKeyPressId != 0) {
                     global.stage.disconnect(this._stageKeyPressId);
                     this._stageKeyPressId = 0;
@@ -162,7 +162,7 @@ const ViewSelector = new Lang.Class({
 
         this._workspacesDisplay.show();
         this._activePage = null;
-        this._showPage(this._workspacesPage);
+        this._syncActivePage();
 
         if (!this._workspacesDisplay.activeWorkspaceHasMaximizedWindows())
             Main.overview.fadeOutDesktop();
@@ -221,7 +221,7 @@ const ViewSelector = new Lang.Class({
             });
     },
 
-    _showPage: function(page, noFade) {
+    _showPage: function(page) {
         if (page == this._activePage)
             return;
 
@@ -229,7 +229,7 @@ const ViewSelector = new Lang.Class({
         this._activePage = page;
         this.emit('page-changed');
 
-        if (oldPage && !noFade)
+        if (oldPage)
             Tweener.addTween(oldPage,
                              { opacity: 0,
                                time: OverviewControls.SIDE_CONTROLS_ANIMATION_TIME,
@@ -248,20 +248,24 @@ const ViewSelector = new Lang.Class({
         page.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
     },
 
-    _onShowAppsButtonToggled: function() {
-        if (this._showAppsBlocked)
-            return;
-
-        this._showPage(this._showAppsButton.checked ?
-                       this._appsPage : this._workspacesPage);
+    _getActivePage: function() {
+        if (this._searchActive)
+            return this._searchPage;
+        else if (this._showAppsButton.checked)
+            return this._appsPage;
+        else
+            return this._workspacesPage;
     },
 
-    _resetShowAppsButton: function() {
-        this._showAppsBlocked = true;
-        this._showAppsButton.checked = false;
-        this._showAppsBlocked = false;
+    _syncActivePage: function() {
+        let activePage = this._getActivePage();
+        if (activePage == this._activePage)
+            return;
+        this._showPage(activePage);
+    },
 
-        this._showPage(this._workspacesPage, true);
+    _onShowAppsButtonToggled: function() {
+        this._syncActivePage();
     },
 
     _onStageKeyPress: function(actor, event) {
@@ -287,20 +291,6 @@ const ViewSelector = new Lang.Class({
         return Clutter.EVENT_PROPAGATE;
     },
 
-    _searchCancelled: function() {
-        this._showPage(this._showAppsButton.checked ? this._appsPage
-                                                    : this._workspacesPage);
-
-        // Leave the entry focused when it doesn't have any text;
-        // when replacing a selected search term, Clutter emits
-        // two 'text-changed' signals, one for deleting the previous
-        // text and one for the new one - the second one is handled
-        // incorrectly when we remove focus
-        // (https://bugzilla.gnome.org/show_bug.cgi?id=636341) */
-        if (this._text.text != '')
-            this.reset();
-    },
-
     reset: function () {
         global.stage.set_key_focus(null);
 
@@ -391,8 +381,18 @@ const ViewSelector = new Lang.Class({
             }
 
             this._entry.set_secondary_icon(null);
-            this._searchCancelled();
+
+            // Leave the entry focused when it doesn't have any text;
+            // when replacing a selected search term, Clutter emits
+            // two 'text-changed' signals, one for deleting the previous
+            // text and one for the new one - the second one is handled
+            // incorrectly when we remove focus
+            // (https://bugzilla.gnome.org/show_bug.cgi?id=636341) */
+            if (this._text.text != '')
+                this.reset();
         }
+
+        this._syncActivePage();
     },
 
     _onKeyPress: function(entry, event) {
@@ -459,9 +459,7 @@ const ViewSelector = new Lang.Class({
         this._searchTimeoutId = 0;
 
         let terms = getTermsForSearchString(this._entry.get_text());
-
         this._searchResults.setTerms(terms);
-        this._showPage(this._searchPage);
 
         return GLib.SOURCE_REMOVE;
     },


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