Make inactive workspace buttons insensitive

Update sensitivity instead of hiding buttons - hiding the
add workspace button looks especially weird.

https://bugzilla.gnome.org/show_bug.cgi?id=607872
This commit is contained in:
Florian Müllner 2010-01-23 12:24:49 +01:00 committed by Colin Walters
parent dc3ff10c6f
commit d9668bd425

View File

@ -234,6 +234,18 @@ GenericWorkspacesView.prototype = {
return [activeWorkspace.gridX, activeWorkspace.gridY]; return [activeWorkspace.gridX, activeWorkspace.gridY];
}, },
_setButtonSensitivity: function(button, sensitive) {
if (button == null)
return;
if (sensitive && !button.reactive) {
button.reactive = true;
button.opacity = 255;
} else if (!sensitive && button.reactive) {
button.reactive = false;
button.opacity = 85;
}
},
createControllerBar: function() { createControllerBar: function() {
throw new Error("Not implemented"); throw new Error("Not implemented");
}, },
@ -433,19 +445,11 @@ MosaicView.prototype = {
}, },
_updateButtonsVisibility: function() { _updateButtonsVisibility: function() {
//_removeButton may yet not exist. let canRemove = (global.screen.n_workspaces > 1);
if (this._removeButton == null) let canAdd = (global.screen.n_workspaces < MAX_WORKSPACES);
return;
if (global.screen.n_workspaces == 1) this._setButtonSensitivity(this._removeButton, canRemove);
this._removeButton.hide(); this._setButtonSensitivity(this._addButton, canAdd);
else
this._removeButton.show();
if (this._addButton == null)
return;
if (global.screen.n_workspaces >= MAX_WORKSPACES)
this._addButton.hide();
else
this._addButton.show();
}, },
_addNewWorkspace: function() { _addNewWorkspace: function() {
@ -787,30 +791,24 @@ SingleView.prototype = {
}, },
_updatePanelVisibility: function() { _updatePanelVisibility: function() {
let n = global.screen.n_workspaces; let canRemove = (global.screen.get_active_workspace_index() != 0);
if (this._removeButton != null) { let canAdd = (global.screen.n_workspaces < MAX_WORKSPACES);
// set opacity here, because if hide it, _scroll will fill this space.
if (global.screen.get_active_workspace_index() == 0) this._setButtonSensitivity(this._removeButton, canRemove);
this._removeButton.set_opacity(0); this._setButtonSensitivity(this._addButton, canAdd);
else
this._removeButton.set_opacity(255); let showSwitches = (global.screen.n_workspaces > 1);
}
if (this._addButton != null) {
// same here
this._addButton.set_opacity((global.screen.n_workspaces < MAX_WORKSPACES) * 255);
}
if (this._scroll != null) { if (this._scroll != null) {
if (n > 1) if (showSwitches)
this._scroll.show(); this._scroll.show();
else else
this._scroll.hide(); this._scroll.hide();
} }
if (this._indicatorsPanel != null) { if (this._indicatorsPanel != null) {
if (n == 1) { if (showSwitches)
this._indicatorsPanel.hide();
} else {
this._indicatorsPanel.show(); this._indicatorsPanel.show();
} else
this._indicatorsPanel.hide();
} }
this._fillPositionalIndicator(); this._fillPositionalIndicator();
}, },