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,50 +283,42 @@ 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) {
let sessions = [];
let n = 0;
for (let i = 0; i < result.length; i++) {
let[id, uid, userName, seat, sessionPath] = result[i];
let proxy = new SystemdLoginSession(Gio.DBus.system,
'org.freedesktop.login1',
sessionPath);
if (this._haveShutdown && if (proxy.Class != 'user')
this._suspendOrPowerOffItem.state == PopupMenu.PopupAlternatingMenuItemState.DEFAULT) { continue;
this._loginManager.listSessions(Lang.bind(this,
function(result) {
let sessions = [];
let n = 0;
for (let i = 0; i < result.length; i++) {
let[id, uid, userName, seat, sessionPath] = result[i];
let proxy = new SystemdLoginSession(Gio.DBus.system,
'org.freedesktop.login1',
sessionPath);
if (proxy.Class != 'user') if (proxy.State == 'closing')
continue; continue;
if (proxy.State == 'closing') if (proxy.Id == GLib.getenv('XDG_SESSION_ID'))
continue; continue;
if (proxy.Id == GLib.getenv('XDG_SESSION_ID')) sessions.push({ user: this._userManager.get_user(userName),
continue; username: userName,
info: { type: proxy.Type,
remote: proxy.Remote }
});
sessions.push({ user: this._userManager.get_user(userName), // limit the number of entries
username: userName, n++;
info: { type: proxy.Type, if (n == MAX_USERS_IN_SESSION_DIALOG)
remote: proxy.Remote } break;
}); }
// limit the number of entries if (n != 0)
n++; this._openSessionWarnDialog(sessions);
if (n == MAX_USERS_IN_SESSION_DIALOG) else
break; this._session.ShutdownRemote();
} }));
if (n != 0)
this._openSessionWarnDialog(sessions);
else
this._session.ShutdownRemote();
}));
} else {
this.menu.itemActivated(BoxPointer.PopupAnimation.NONE);
this._loginManager.suspend();
}
} }
}); });