[gnome-shell] viewSelector: allow programmatically switching to tabs



commit d16acc43d9816b03c01627b1e10ef26080001438
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Tue Mar 8 19:26:28 2011 -0500

    viewSelector: allow programmatically switching to tabs
    
    Add the idea of an 'id' for a tab, and add a public switchTab method
    so you can switch to 'applications' or 'windows'. This will be useful
    for performance tests that test tab switching performance.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=644266

 js/ui/overview.js     |    4 ++--
 js/ui/viewSelector.js |   20 +++++++++++++++-----
 2 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 2d67286..b6c30d9 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -180,10 +180,10 @@ Overview.prototype = {
         this._group.add_actor(this.viewSelector.actor);
 
         this._workspacesDisplay = new WorkspacesView.WorkspacesDisplay();
-        this.viewSelector.addViewTab(_("Windows"), this._workspacesDisplay.actor, 'text-x-generic');
+        this.viewSelector.addViewTab('windows', _("Windows"), this._workspacesDisplay.actor, 'text-x-generic');
 
         let appView = new AppDisplay.AllAppDisplay();
-        this.viewSelector.addViewTab(_("Applications"), appView.actor, 'system-run');
+        this.viewSelector.addViewTab('applications', _("Applications"), appView.actor, 'system-run');
 
         // Default search providers
         this.viewSelector.addSearchProvider(new AppDisplay.AppSearchProvider());
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index 5cad9cd..6cb0596 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -77,14 +77,16 @@ BaseTab.prototype = {
 Signals.addSignalMethods(BaseTab.prototype);
 
 
-function ViewTab(label, pageActor, a11yIcon) {
-    this._init(label, pageActor, a11yIcon);
+function ViewTab(id, label, pageActor, a11yIcon) {
+    this._init(id, label, pageActor, a11yIcon);
 }
 
 ViewTab.prototype = {
     __proto__: BaseTab.prototype,
 
-    _init: function(label, pageActor, a11yIcon) {
+    _init: function(id, label, pageActor, a11yIcon) {
+        this.id = id;
+
         let titleActor = new St.Button({ label: label,
                                          style_class: 'view-tab-title' });
         titleActor.connect('clicked', Lang.bind(this, this._activate));
@@ -383,8 +385,8 @@ ViewSelector.prototype = {
         }));
     },
 
-    addViewTab: function(title, pageActor, a11yIcon) {
-        let viewTab = new ViewTab(title, pageActor, a11yIcon);
+    addViewTab: function(id, title, pageActor, a11yIcon) {
+        let viewTab = new ViewTab(id, title, pageActor, a11yIcon);
         this._tabs.push(viewTab);
         this._tabBox.add(viewTab.title);
         this._addTab(viewTab);
@@ -433,6 +435,14 @@ ViewSelector.prototype = {
         }
     },
 
+    switchTab: function(id) {
+        for (let i = 0; i < this._tabs.length; i++)
+            if (this._tabs[i].id == id) {
+                this._switchTab(this._tabs[i]);
+                break;
+            }
+    },
+
     _switchDefaultTab: function() {
         if (this._tabs.length > 0)
             this._switchTab(this._tabs[0]);



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