[gnome-shell/modekill: 5/10] viewSelector: Hook up the dash's showApps button



commit 47e05f513182b1f03e5ebb08554c2a6e24fcb1db
Author: Joost Verdoorn <jpverdoorn gmail com>
Date:   Sun Jul 22 14:45:53 2012 +0200

    viewSelector: Hook up the dash's showApps button
    
    We pass the dashâs showApps button to the viewSelector, and we connect it
    to the showing and hiding of the appsView. This is necessary because there
    are different mechanisms for switching the views, and it has to stay in
    sync with the buttonâs state.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=682109

 js/ui/dash.js         |   18 ++++++++++--------
 js/ui/overview.js     |    7 ++++---
 js/ui/viewSelector.js |   22 +++++++++++++++-------
 3 files changed, 29 insertions(+), 18 deletions(-)
---
diff --git a/js/ui/dash.js b/js/ui/dash.js
index edcaa46..e438c69 100644
--- a/js/ui/dash.js
+++ b/js/ui/dash.js
@@ -233,19 +233,19 @@ const ShowAppsIcon = new Lang.Class({
     _init: function() {
         this.parent();
 
-        this._button = new St.Button({ style_class: 'show-apps',
-                                        track_hover: true,
-                                        can_focus: true,
-                                        toggle_mode: true });
+        this.toggleButton = new St.Button({ style_class: 'show-apps',
+                                            track_hover: true,
+                                            can_focus: true,
+                                            toggle_mode: true });
         this._iconActor = null;
         this.icon = new IconGrid.BaseIcon(_("Show Apps"),
                                            { setSizeManually: true,
                                              showLabel: false,
                                              createIcon: Lang.bind(this, this._createIcon) });
-        this._button.add_actor(this.icon.actor);
-        this._button._delegate = this;
+        this.toggleButton.add_actor(this.icon.actor);
+        this.toggleButton._delegate = this;
 
-        this.setChild(this._button);
+        this.setChild(this.toggleButton);
     },
 
     _createIcon: function(size) {
@@ -258,7 +258,7 @@ const ShowAppsIcon = new Lang.Class({
     },
 
     setHover: function(hovered) {
-        this._button.set_hover(hovered);
+        this.toggleButton.set_hover(hovered);
         if (this._iconActor)
             this._iconActor.set_hover(hovered);
     },
@@ -327,6 +327,8 @@ const Dash = new Lang.Class({
         this._showAppsIcon = new ShowAppsIcon();
         this._showAppsIcon.icon.setIconSize(this.iconSize);
 
+        this.showAppsButton = this._showAppsIcon.toggleButton;
+
         this._container.add(this._showAppsIcon.actor);
 
         this.actor = new St.Bin({ child: this._container,
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 5943432..664ce90 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -196,15 +196,16 @@ const Overview = new Lang.Class({
                                            can_focus: true });
         this._group.add_actor(this._searchEntry);
 
-        this._viewSelector = new ViewSelector.ViewSelector(this._searchEntry);
+        this._dash = new Dash.Dash();
+        this._viewSelector = new ViewSelector.ViewSelector(this._searchEntry,
+                                                           this._dash.showAppsButton);
         this._group.add_actor(this._viewSelector.actor);
+        this._group.add_actor(this._dash.actor);
 
         // Load remote search providers provided by applications
         RemoteSearch.loadRemoteSearchProviders(Lang.bind(this, this.addSearchProvider));
 
         // TODO - recalculate everything when desktop size changes
-        this._dash = new Dash.Dash();
-        this._group.add_actor(this._dash.actor);
         this._dash.actor.add_constraint(this._viewSelector.constrainY);
         this._dash.actor.add_constraint(this._viewSelector.constrainHeight);
         this.dashIconSize = this._dash.iconSize;
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index 23e5bca..50d266e 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -345,10 +345,19 @@ const SearchTab = new Lang.Class({
 const ViewSelector = new Lang.Class({
     Name: 'ViewSelector',
 
-    _init : function(searchEntry) {
+    _init : function(searchEntry, showAppsButton) {
         this.actor = new St.BoxLayout({ name: 'viewSelector',
                                         vertical: true });
 
+        this._showAppsButton = showAppsButton;
+        this._showAppsButton.connect('notify::checked', Lang.bind(this,
+            function() {
+                if (this._showAppsButton.checked)
+                    this._switchTab(this._appsTab);
+                else
+                    this._switchTab(this._windowsTab);
+            }));
+
         // The tab bar is located at the top of the view selector and
         // holds both "normal" tab labels and the search entry. The former
         // is left aligned, the latter right aligned - unless the text
@@ -406,18 +415,18 @@ const ViewSelector = new Lang.Class({
         this.addSearchProvider(new PlaceDisplay.PlaceSearchProvider());
 
         Main.overview.connect('item-drag-begin',
-                              Lang.bind(this, this._switchDefaultTab));
+                              Lang.bind(this, this._resetShowAppsButton));
 
         this._stageKeyPressId = 0;
         Main.overview.connect('showing', Lang.bind(this,
             function () {
-                this._switchDefaultTab();
+                this._resetShowAppsButton();
                 this._stageKeyPressId = global.stage.connect('key-press-event',
                                                              Lang.bind(this, this._onStageKeyPress));
             }));
         Main.overview.connect('hiding', Lang.bind(this,
             function () {
-                this._switchDefaultTab();
+                this._resetShowAppsButton();
                 if (this._stageKeyPressId != 0) {
                     global.stage.disconnect(this._stageKeyPressId);
                     this._stageKeyPressId = 0;
@@ -502,9 +511,8 @@ const ViewSelector = new Lang.Class({
             }
     },
 
-    _switchDefaultTab: function() {
-        if (this._tabs.length > 0)
-            this._switchTab(this._tabs[0]);
+    _resetShowAppsButton: function() {
+        this._showAppsButton.checked = false;
     },
 
     _nextTab: function() {



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