[gnome-shell] statusMenu: change how we stop the system
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] statusMenu: change how we stop the system
- Date: Tue, 22 Feb 2011 23:47:26 +0000 (UTC)
commit 26f4e44d6c78af77343347e8dba3e36eddcc6a63
Author: Ray Strode <rstrode redhat com>
Date: Fri Feb 4 18:37:54 2011 -0500
statusMenu: change how we stop the system
This updates the way we stop the system to
somewhat match the designs here:
https://live.gnome.org/GnomeShell/Design/Whiteboards/SystemStopRestart
We suspend by default unless suspend is unavailable, and offer shutdown
as a choice by hold down the alt key.
https://bugzilla.gnome.org/show_bug.cgi?id=636680
js/ui/statusMenu.js | 44 +++++++++++++++++++++++++++++++++-----------
1 files changed, 33 insertions(+), 11 deletions(-)
---
diff --git a/js/ui/statusMenu.js b/js/ui/statusMenu.js
index dc17f0f..4c1fa5d 100644
--- a/js/ui/statusMenu.js
+++ b/js/ui/statusMenu.js
@@ -5,6 +5,7 @@ const GLib = imports.gi.GLib;
const Lang = imports.lang;
const Shell = imports.gi.Shell;
const St = imports.gi.St;
+const UPowerGlib = imports.gi.UPowerGlib;
const Gettext = imports.gettext.domain('gnome-shell');
const _ = Gettext.gettext;
@@ -38,6 +39,8 @@ StatusMenuButton.prototype = {
this._presence = new GnomeSession.Presence();
this._presenceItems = {};
+ this._upClient = new UPowerGlib.Client();
+
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
this._iconBox = new St.Bin();
@@ -61,6 +64,8 @@ StatusMenuButton.prototype = {
this._gdm.connect('notify::is-loaded', Lang.bind(this, this._updateSwitchUser));
this._gdm.connect('user-added', Lang.bind(this, this._updateSwitchUser));
this._gdm.connect('user-removed', Lang.bind(this, this._updateSwitchUser));
+
+ this._upClient.connect('notify::can-suspend', Lang.bind(this, this._updateSuspendOrPowerOff));
},
_onDestroy: function() {
@@ -82,6 +87,21 @@ StatusMenuButton.prototype = {
this._loginScreenItem.actor.hide();
},
+ _updateSuspendOrPowerOff: function() {
+ this._haveSuspend = this._upClient.get_can_suspend();
+
+ if (!this._suspendOrPowerOffItem)
+ return;
+
+ // If we can't suspend show Power Off... instead
+ // and disable the alt key
+ if (!this._haveSuspend) {
+ this._suspendOrPowerOffItem.updateText(_("Power Off..."), null);
+ } else {
+ this._suspendOrPowerOffItem.updateText(_("Suspend"), ("Power Off..."));
+ }
+ },
+
_updatePresenceIcon: function(presence, status) {
if (status == GnomeSession.PresenceStatus.AVAILABLE)
this._iconBox.child = this._availableIcon;
@@ -139,16 +159,12 @@ StatusMenuButton.prototype = {
item = new PopupMenu.PopupSeparatorMenuItem();
this.menu.addMenuItem(item);
- // This is temporarily removed, see
- // http://bugzilla.gnome.org/show_bug.cgi?id=636680
- // for details.
- //item = new PopupMenu.PopupMenuItem(_("Suspend..."));
- //item.connect('activate', Lang.bind(this, this._onShutDownActivate));
- //this.menu.addMenuItem(item);
-
- item = new PopupMenu.PopupMenuItem(_("Shut Down..."));
- item.connect('activate', Lang.bind(this, this._onShutDownActivate));
+ item = new PopupMenu.PopupAlternatingMenuItem(_("Suspend"),
+ _("Power Off..."));
this.menu.addMenuItem(item);
+ this._suspendOrPowerOffItem = item;
+ item.connect('activate', Lang.bind(this, this._onSuspendOrPowerOffActivate));
+ this._updateSuspendOrPowerOff();
},
_setPresenceStatus: function(item, event, status) {
@@ -181,8 +197,14 @@ StatusMenuButton.prototype = {
Util.spawn(['gnome-session-save', '--logout-dialog']);
},
- _onShutDownActivate: function() {
+ _onSuspendOrPowerOffActivate: function() {
Main.overview.hide();
- Util.spawn(['gnome-session-save', '--shutdown-dialog']);
+
+ if (this._haveSuspend &&
+ this._suspendOrPowerOffItem.state == PopupMenu.PopupAlternatingMenuItemState.DEFAULT) {
+ this._upClient.suspend_sync(null);
+ } else {
+ Util.spawn(['gnome-session-save', '--shutdown-dialog']);
+ }
}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]