Use one button to toggle between single and grid view
Currently we use two buttons to toggle between the different views, one of them always being redundant. Fix that by only use one button that changes it's style depending on the current view. https://bugzilla.gnome.org/show_bug.cgi?id=610801
This commit is contained in:
parent
db96437f18
commit
8b792f8942
@ -1170,8 +1170,7 @@ WorkspacesControls.prototype = {
|
|||||||
_init: function() {
|
_init: function() {
|
||||||
this.actor = null;
|
this.actor = null;
|
||||||
this._gconf = Shell.GConf.get_default();
|
this._gconf = Shell.GConf.get_default();
|
||||||
this._mosaicViewButton = null;
|
this._toggleViewButton = null;
|
||||||
this._singleViewButton = null;
|
|
||||||
this._addButton = null;
|
this._addButton = null;
|
||||||
this._removeButton = null;
|
this._removeButton = null;
|
||||||
|
|
||||||
@ -1186,13 +1185,18 @@ WorkspacesControls.prototype = {
|
|||||||
this._switchWorkspaceNotifyId = 0;
|
this._switchWorkspaceNotifyId = 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
_setView: function(view) {
|
_updateToggleButtonStyle: function() {
|
||||||
this._mosaicViewButton.set_checked(WorkspacesViewType.GRID == view);
|
if (this._currentViewType == WorkspacesViewType.SINGLE)
|
||||||
this._singleViewButton.set_checked(WorkspacesViewType.SINGLE == view);
|
this._toggleViewButton.set_style_class_name('workspace-controls switch-mosaic');
|
||||||
|
else
|
||||||
|
this._toggleViewButton.set_style_class_name('workspace-controls switch-single');
|
||||||
|
},
|
||||||
|
|
||||||
|
_setView: function(view) {
|
||||||
if (this._currentViewType == view)
|
if (this._currentViewType == view)
|
||||||
return;
|
return;
|
||||||
this._currentViewType = view;
|
this._currentViewType = view;
|
||||||
|
this._updateToggleButtonStyle();
|
||||||
this._gconf.set_string(WORKSPACES_VIEW_KEY, view);
|
this._gconf.set_string(WORKSPACES_VIEW_KEY, view);
|
||||||
this.emit('view-changed');
|
this.emit('view-changed');
|
||||||
},
|
},
|
||||||
@ -1217,27 +1221,18 @@ WorkspacesControls.prototype = {
|
|||||||
else
|
else
|
||||||
this.actor = new St.BoxLayout({ style_class: 'workspaces-bar' });
|
this.actor = new St.BoxLayout({ style_class: 'workspaces-bar' });
|
||||||
|
|
||||||
// View switcher buttons
|
// View switcher button
|
||||||
this._mosaicViewButton = new St.Button({ style_class: 'workspace-controls switch-mosaic',
|
this._toggleViewButton = new St.Button();
|
||||||
toggle_mode: true });
|
this._updateToggleButtonStyle();
|
||||||
this._mosaicViewButton.connect('clicked', Lang.bind(this, function() {
|
|
||||||
this._setView(WorkspacesViewType.GRID);
|
|
||||||
}));
|
|
||||||
this.actor.add(this._mosaicViewButton, { y_fill: false,
|
|
||||||
y_align: St.Align.START });
|
|
||||||
|
|
||||||
this._singleViewButton = new St.Button({ style_class: 'workspace-controls switch-single',
|
this._toggleViewButton.connect('clicked', Lang.bind(this, function() {
|
||||||
toggle_mode: true });
|
if (this._currentViewType == WorkspacesViewType.SINGLE)
|
||||||
this._singleViewButton.connect('clicked', Lang.bind(this, function() {
|
this._setView(WorkspacesViewType.GRID);
|
||||||
this._setView(WorkspacesViewType.SINGLE);
|
else
|
||||||
}));
|
this._setView(WorkspacesViewType.SINGLE);
|
||||||
this.actor.add(this._singleViewButton, { y_fill: false,
|
}));
|
||||||
y_align: St.Align.START });
|
|
||||||
|
|
||||||
if (this._currentViewType == WorkspacesViewType.GRID)
|
this.actor.add(this._toggleViewButton, { y_fill: false, y_align: St.Align.START });
|
||||||
this._mosaicViewButton.set_checked(true);
|
|
||||||
else
|
|
||||||
this._singleViewButton.set_checked(true);
|
|
||||||
|
|
||||||
// View specific controls
|
// View specific controls
|
||||||
let bar = this._currentView.createControllerBar();
|
let bar = this._currentView.createControllerBar();
|
||||||
@ -1316,13 +1311,10 @@ WorkspacesControls.prototype = {
|
|||||||
|
|
||||||
this._updateButtonSensitivity();
|
this._updateButtonSensitivity();
|
||||||
|
|
||||||
if (global.screen.n_workspaces == 1) {
|
if (global.screen.n_workspaces == 1)
|
||||||
this._mosaicViewButton.hide();
|
this._toggleViewButton.hide();
|
||||||
this._singleViewButton.hide();
|
else
|
||||||
} else {
|
this._toggleViewButton.show();
|
||||||
this._mosaicViewButton.show();
|
|
||||||
this._singleViewButton.show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user