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
This commit is contained in:
parent
239aa7b8d5
commit
d16acc43d9
@ -180,10 +180,10 @@ Overview.prototype = {
|
|||||||
this._group.add_actor(this.viewSelector.actor);
|
this._group.add_actor(this.viewSelector.actor);
|
||||||
|
|
||||||
this._workspacesDisplay = new WorkspacesView.WorkspacesDisplay();
|
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();
|
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
|
// Default search providers
|
||||||
this.viewSelector.addSearchProvider(new AppDisplay.AppSearchProvider());
|
this.viewSelector.addSearchProvider(new AppDisplay.AppSearchProvider());
|
||||||
|
@ -77,14 +77,16 @@ BaseTab.prototype = {
|
|||||||
Signals.addSignalMethods(BaseTab.prototype);
|
Signals.addSignalMethods(BaseTab.prototype);
|
||||||
|
|
||||||
|
|
||||||
function ViewTab(label, pageActor, a11yIcon) {
|
function ViewTab(id, label, pageActor, a11yIcon) {
|
||||||
this._init(label, pageActor, a11yIcon);
|
this._init(id, label, pageActor, a11yIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewTab.prototype = {
|
ViewTab.prototype = {
|
||||||
__proto__: BaseTab.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,
|
let titleActor = new St.Button({ label: label,
|
||||||
style_class: 'view-tab-title' });
|
style_class: 'view-tab-title' });
|
||||||
titleActor.connect('clicked', Lang.bind(this, this._activate));
|
titleActor.connect('clicked', Lang.bind(this, this._activate));
|
||||||
@ -383,8 +385,8 @@ ViewSelector.prototype = {
|
|||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
addViewTab: function(title, pageActor, a11yIcon) {
|
addViewTab: function(id, title, pageActor, a11yIcon) {
|
||||||
let viewTab = new ViewTab(title, pageActor, a11yIcon);
|
let viewTab = new ViewTab(id, title, pageActor, a11yIcon);
|
||||||
this._tabs.push(viewTab);
|
this._tabs.push(viewTab);
|
||||||
this._tabBox.add(viewTab.title);
|
this._tabBox.add(viewTab.title);
|
||||||
this._addTab(viewTab);
|
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() {
|
_switchDefaultTab: function() {
|
||||||
if (this._tabs.length > 0)
|
if (this._tabs.length > 0)
|
||||||
this._switchTab(this._tabs[0]);
|
this._switchTab(this._tabs[0]);
|
||||||
|
Loading…
Reference in New Issue
Block a user