[gnome-shell] switcherPopup: Factor the initial selection into the base class



commit 2b1077aaa169f5b6244264eee5c2fd46c132180e
Author: Rui Matos <tiagomatos gmail com>
Date:   Wed Sep 3 17:17:26 2014 +0200

    switcherPopup: Factor the initial selection into the base class
    
    Only the application switcher needs to keep its own implementation
    since it has two modes of operation depending on the binding.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=735976

 js/ui/altTab.js          |    9 ---------
 js/ui/ctrlAltTab.js      |   11 -----------
 js/ui/status/keyboard.js |   11 -----------
 js/ui/switcherPopup.js   |   12 ++++++------
 4 files changed, 6 insertions(+), 37 deletions(-)
---
diff --git a/js/ui/altTab.js b/js/ui/altTab.js
index b11c4f1..cee81b0 100644
--- a/js/ui/altTab.js
+++ b/js/ui/altTab.js
@@ -378,15 +378,6 @@ const WindowSwitcherPopup = new Lang.Class({
         return global.display.get_tab_list(Meta.TabList.NORMAL, workspace);
     },
 
-    _initialSelection: function(backward, binding) {
-        if (binding == 'switch-windows-backward' || backward)
-            this._select(this._items.length - 1);
-        else if (this._items.length == 1)
-            this._select(0);
-        else
-            this._select(1);
-    },
-
     _keyPressHandler: function(keysym, action) {
         if (action == Meta.KeyBindingAction.SWITCH_WINDOWS) {
             this._select(this._next());
diff --git a/js/ui/ctrlAltTab.js b/js/ui/ctrlAltTab.js
index 85e39df..5694990 100644
--- a/js/ui/ctrlAltTab.js
+++ b/js/ui/ctrlAltTab.js
@@ -146,17 +146,6 @@ const CtrlAltTabPopup = new Lang.Class({
         this._switcherList = new CtrlAltTabSwitcher(this._items);
     },
 
-    _initialSelection: function(backward, binding) {
-        if (binding == 'switch-panels') {
-            if (backward)
-                this._selectedIndex = this._items.length - 1;
-        } else if (binding == 'switch-panels-backward') {
-            if (!backward)
-                this._selectedIndex = this._items.length - 1;
-        }
-        this._select(this._selectedIndex);
-    },
-
     _keyPressHandler: function(keysym, action) {
         if (action == Meta.KeyBindingAction.SWITCH_PANELS)
             this._select(this._next());
diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js
index ea02f6f..4bb9225 100644
--- a/js/ui/status/keyboard.js
+++ b/js/ui/status/keyboard.js
@@ -269,17 +269,6 @@ const InputSourcePopup = new Lang.Class({
         this._switcherList = new InputSourceSwitcher(this._items);
     },
 
-    _initialSelection: function(backward, binding) {
-        if (binding == 'switch-input-source') {
-            if (backward)
-                this._selectedIndex = this._items.length - 1;
-        } else if (binding == 'switch-input-source-backward') {
-            if (!backward)
-                this._selectedIndex = this._items.length - 1;
-        }
-        this._select(this._selectedIndex);
-    },
-
     _keyPressHandler: function(keysym, action) {
         if (action == this._action)
             this._select(this._next());
diff --git a/js/ui/switcherPopup.js b/js/ui/switcherPopup.js
index c9d3884..24ad279 100644
--- a/js/ui/switcherPopup.js
+++ b/js/ui/switcherPopup.js
@@ -103,7 +103,12 @@ const SwitcherPopup = new Lang.Class({
     },
 
     _initialSelection: function(backward, binding) {
-        throw new Error('Not implemented');
+        if (backward)
+            this._select(this._items.length - 1);
+        else if (this._items.length == 1)
+            this._select(0);
+        else
+            this._select(1);
     },
 
     show: function(backward, binding, mask) {
@@ -135,11 +140,6 @@ const SwitcherPopup = new Lang.Class({
         this.actor.show();
         this.actor.get_allocation_box();
 
-        if (this._items.length > 1)
-            this._selectedIndex = 1;
-        else
-            this._selectedIndex = 0;
-
         this._initialSelection(backward, binding);
 
         // There's a race condition; if the user released Alt before


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