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
This commit is contained in:
parent
27fbe4cd83
commit
816a29d582
@ -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 Applications"),
|
||||
{ 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,
|
||||
|
@ -195,12 +195,13 @@ 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);
|
||||
|
||||
// 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;
|
||||
|
@ -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
|
||||
@ -409,18 +418,18 @@ const ViewSelector = new Lang.Class({
|
||||
RemoteSearch.loadRemoteSearchProviders(Lang.bind(this, this.addSearchProvider));
|
||||
|
||||
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;
|
||||
@ -505,9 +514,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() {
|
||||
|
Loading…
Reference in New Issue
Block a user