system: Remove suspend from the features of the system menu

This will eventually go up in a redesign of the "end session" dialog.

https://bugzilla.gnome.org/show_bug.cgi?id=704368
This commit is contained in:
Jasper St. Pierre 2013-06-11 14:33:59 -04:00
parent ca861d8ff9
commit 14372ba7f3

View File

@ -52,7 +52,6 @@ const Indicator = new Lang.Class({
this._session = new GnomeSession.SessionManager(); this._session = new GnomeSession.SessionManager();
this._haveShutdown = true; this._haveShutdown = true;
this._haveSuspend = true;
this._createSubMenu(); this._createSubMenu();
@ -93,7 +92,6 @@ const Indicator = new Lang.Class({
return; return;
this._updateHaveShutdown(); this._updateHaveShutdown();
this._updateHaveSuspend();
})); }));
this._lockdownSettings.connect('changed::' + DISABLE_LOG_OUT_KEY, this._lockdownSettings.connect('changed::' + DISABLE_LOG_OUT_KEY,
Lang.bind(this, this._updateHaveShutdown)); Lang.bind(this, this._updateHaveShutdown));
@ -146,34 +144,13 @@ const Indicator = new Lang.Class({
if (!error) { if (!error) {
this._haveShutdown = result[0]; this._haveShutdown = result[0];
this._updateInstallUpdates(); this._updateInstallUpdates();
this._updateSuspendOrPowerOff(); this._updatePowerOff();
} }
})); }));
}, },
_updateHaveSuspend: function() { _updatePowerOff: function() {
this._loginManager.canSuspend(Lang.bind(this, this._powerOffItem.actor.visible = this._haveShutdown;
function(result) {
this._haveSuspend = result;
this._updateSuspendOrPowerOff();
}));
},
_updateSuspendOrPowerOff: function() {
if (!this._suspendOrPowerOffItem)
return;
this._suspendOrPowerOffItem.actor.visible = this._haveShutdown || this._haveSuspend;
// If we can't power off show Suspend instead
// and disable the alt key
if (!this._haveShutdown) {
this._suspendOrPowerOffItem.updateText(_("Suspend"), null);
} else if (!this._haveSuspend) {
this._suspendOrPowerOffItem.updateText(_("Power Off"), null);
} else {
this._suspendOrPowerOffItem.updateText(_("Power Off"), _("Suspend"));
}
}, },
_createSubMenu: function() { _createSubMenu: function() {
@ -202,12 +179,10 @@ const Indicator = new Lang.Class({
item = new PopupMenu.PopupSeparatorMenuItem(); item = new PopupMenu.PopupSeparatorMenuItem();
this.menu.addMenuItem(item); this.menu.addMenuItem(item);
item = new PopupMenu.PopupAlternatingMenuItem(_("Power Off"), item = new PopupMenu.PopupMenuItem(_("Power Off"));
_("Suspend"));
this.menu.addMenuItem(item); this.menu.addMenuItem(item);
item.connect('activate', Lang.bind(this, this._onSuspendOrPowerOffActivate)); item.connect('activate', Lang.bind(this, this._onPowerOffActivate));
this._suspendOrPowerOffItem = item; this._powerOffItem = item;
this._updateSuspendOrPowerOff();
item = new PopupMenu.PopupMenuItem(_("Install Updates & Restart")); item = new PopupMenu.PopupMenuItem(_("Install Updates & Restart"));
item.connect('activate', Lang.bind(this, this._onInstallUpdatesActivate)); item.connect('activate', Lang.bind(this, this._onInstallUpdatesActivate));
@ -308,13 +283,9 @@ const Indicator = new Lang.Class({
dialog.open(); dialog.open();
}, },
_onSuspendOrPowerOffActivate: function() { _onPowerOffActivate: function() {
Main.overview.hide(); Main.overview.hide();
this._loginManager.listSessions(Lang.bind(this, function(result) {
if (this._haveShutdown &&
this._suspendOrPowerOffItem.state == PopupMenu.PopupAlternatingMenuItemState.DEFAULT) {
this._loginManager.listSessions(Lang.bind(this,
function(result) {
let sessions = []; let sessions = [];
let n = 0; let n = 0;
for (let i = 0; i < result.length; i++) { for (let i = 0; i < result.length; i++) {
@ -349,9 +320,5 @@ const Indicator = new Lang.Class({
else else
this._session.ShutdownRemote(); this._session.ShutdownRemote();
})); }));
} else {
this.menu.itemActivated(BoxPointer.PopupAnimation.NONE);
this._loginManager.suspend();
}
} }
}); });