[gnome-shell] loginManager: Add support for suspend()
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] loginManager: Add support for suspend()
- Date: Tue, 23 Oct 2012 19:19:13 +0000 (UTC)
commit 1f183b8a4e0c8470357aa639103951e0c2c517ea
Author: Florian MÃllner <fmuellner gnome org>
Date: Fri Oct 19 17:29:53 2012 +0200
loginManager: Add support for suspend()
Logind provides a Suspend method, which we should use instead of
the UPower API when available. Expose this in loginManager, using
the UPower API for the ConsoleKit implementation.
https://bugzilla.gnome.org/show_bug.cgi?id=686482
js/misc/loginManager.js | 34 +++++++++++++++++++++++++++++++++-
1 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/js/misc/loginManager.js b/js/misc/loginManager.js
index b7c26c3..7fc189f 100644
--- a/js/misc/loginManager.js
+++ b/js/misc/loginManager.js
@@ -3,7 +3,9 @@
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const Lang = imports.lang;
+const Mainloop = imports.mainloop;
const Shell = imports.gi.Shell;
+const UPowerGlib = imports.gi.UPowerGlib;
const SystemdLoginManagerIface = <interface name='org.freedesktop.login1.Manager'>
<method name='PowerOff'>
@@ -12,12 +14,18 @@ const SystemdLoginManagerIface = <interface name='org.freedesktop.login1.Manager
<method name='Reboot'>
<arg type='b' direction='in'/>
</method>
+<method name='Suspend'>
+ <arg type='b' direction='in'/>
+</method>
<method name='CanPowerOff'>
<arg type='s' direction='out'/>
</method>
<method name='CanReboot'>
<arg type='s' direction='out'/>
</method>
+<method name='CanSuspend'>
+ <arg type='s' direction='out'/>
+</method>
</interface>;
const SystemdLoginSessionIface = <interface name='org.freedesktop.login1.Session'>
@@ -123,12 +131,25 @@ const LoginManagerSystemd = new Lang.Class({
});
},
+ canSuspend: function(asyncCallback) {
+ this._proxy.CanSuspendRemote(function(result, error) {
+ if (error)
+ asyncCallback(false);
+ else
+ asyncCallback(result[0] != 'no');
+ });
+ },
+
powerOff: function() {
this._proxy.PowerOffRemote(true);
},
reboot: function() {
this._proxy.RebootRemote(true);
+ },
+
+ suspend: function() {
+ this._proxy.SuspendRemote(true);
}
});
@@ -139,6 +160,7 @@ const LoginManagerConsoleKit = new Lang.Class({
this._proxy = new ConsoleKitManager(Gio.DBus.system,
'org.freedesktop.ConsoleKit',
'/org/freedesktop/ConsoleKit/Manager');
+ this._upClient = new UPowerGlib.Client();
},
// Having this function is a bit of a hack since the Systemd and ConsoleKit
@@ -186,12 +208,22 @@ const LoginManagerConsoleKit = new Lang.Class({
});
},
+ canSuspend: function(asyncCallback) {
+ Mainloop.idle_add(Lang.bind(this, function() {
+ asyncCallback(this._upClient.get_can_suspend());
+ return false;
+ }));
+ },
+
powerOff: function() {
this._proxy.StopRemote();
},
reboot: function() {
this._proxy.RestartRemote();
+ },
+
+ suspend: function() {
+ this._upClient.suspend_sync(null);
}
-
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]