ShellDBus: export screensaver interface

gnome-session and gnome-settings-daemon rely on the screensaver
interface to know the locked state. Since gnome-screensaver is no
longer running, it's up to gnome-shell to provide it.

https://bugzilla.gnome.org/show_bug.cgi?id=619955
This commit is contained in:
Giovanni Campagna 2012-06-03 01:20:31 +02:00
parent e0bb15e572
commit f7f2f50435
3 changed files with 49 additions and 0 deletions

View File

@ -65,6 +65,7 @@ let recorder = null;
let sessionMode = null; let sessionMode = null;
let shellDBusService = null; let shellDBusService = null;
let shellMountOpDBusService = null; let shellMountOpDBusService = null;
let screenSaverDBus = null;
let modalCount = 0; let modalCount = 0;
let modalActorFocusStack = []; let modalActorFocusStack = [];
let uiGroup = null; let uiGroup = null;
@ -215,6 +216,7 @@ function start() {
magnifier = new Magnifier.Magnifier(); magnifier = new Magnifier.Magnifier();
statusIconDispatcher = new StatusIconDispatcher.StatusIconDispatcher(); statusIconDispatcher = new StatusIconDispatcher.StatusIconDispatcher();
screenShield = new ScreenShield.ScreenShield(); screenShield = new ScreenShield.ScreenShield();
screenSaverDBus = new ShellDBus.ScreenSaverDBus();
panel = new Panel.Panel(); panel = new Panel.Panel();
wm = new WindowManager.WindowManager(); wm = new WindowManager.WindowManager();
messageTray = new MessageTray.MessageTray(); messageTray = new MessageTray.MessageTray();

View File

@ -50,6 +50,20 @@ const GnomeShellIface = <interface name="org.gnome.Shell">
<property name="ShellVersion" type="s" access="read" /> <property name="ShellVersion" type="s" access="read" />
</interface>; </interface>;
const ScreenSaverIface = <interface name="org.gnome.ScreenSaver">
<method name="Lock">
</method>
<method name="GetActive">
<arg name="active" direction="out" type="b" />
</method>
<method name="SetActive">
<arg name="value" direction="in" type="u" />
</method>
<signal name="ActiveChanged">
<arg name="new_value" type="b" />
</signal>
</interface>;
const GnomeShell = new Lang.Class({ const GnomeShell = new Lang.Class({
Name: 'GnomeShellDBus', Name: 'GnomeShellDBus',
@ -319,3 +333,33 @@ const GnomeShellExtensions = new Lang.Class({
GLib.Variant.new('(sis)', [newState.uuid, newState.state, newState.error])); GLib.Variant.new('(sis)', [newState.uuid, newState.state, newState.error]));
} }
}); });
const ScreenSaverDBus = new Lang.Class({
Name: 'ScreenSaverDBus',
_init: function() {
this.parent();
Main.screenShield.connect('lock-status-changed', Lang.bind(this, function(shield, locked) {
this._dbusImpl.emit_signal('ActiveChanged', GLib.Variant.new('(b)', [locked]));
}));
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreenSaverIface, this);
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/ScreenSaver');
},
Lock: function() {
Main.screenShield.lock(true);
},
SetActive: function(active) {
if (active)
Main.screenShield.lock(true);
else
Main.screenShield.unlock();
},
GetActive: function() {
return Main.screenShield.locked;
}
});

View File

@ -34,6 +34,7 @@ extern GType gnome_shell_plugin_get_type (void);
#define SHELL_DBUS_SERVICE "org.gnome.Shell" #define SHELL_DBUS_SERVICE "org.gnome.Shell"
#define MAGNIFIER_DBUS_SERVICE "org.gnome.Magnifier" #define MAGNIFIER_DBUS_SERVICE "org.gnome.Magnifier"
#define SCREENSAVER_DBUS_SERVICE "org.gnome.ScreenSaver"
#define OVERRIDES_SCHEMA "org.gnome.shell.overrides" #define OVERRIDES_SCHEMA "org.gnome.shell.overrides"
@ -152,6 +153,8 @@ shell_dbus_init (gboolean replace)
MAGNIFIER_DBUS_SERVICE, FALSE, MAGNIFIER_DBUS_SERVICE, FALSE,
/* ...and the org.freedesktop.Notifications service. */ /* ...and the org.freedesktop.Notifications service. */
"org.freedesktop.Notifications", FALSE, "org.freedesktop.Notifications", FALSE,
/* ...and the org.gnome.ScreenSaver service. */
SCREENSAVER_DBUS_SERVICE, FALSE,
NULL); NULL);
/* ...and the on-screen keyboard service */ /* ...and the on-screen keyboard service */
shell_dbus_acquire_name (bus, shell_dbus_acquire_name (bus,