[gnome-shell] ShellDBus: export screensaver interface



commit f7f2f5043594e099912962162ad789bb0f978971
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sun Jun 3 01:20:31 2012 +0200

    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

 js/ui/main.js      |    2 ++
 js/ui/shellDBus.js |   44 ++++++++++++++++++++++++++++++++++++++++++++
 src/main.c         |    3 +++
 3 files changed, 49 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/main.js b/js/ui/main.js
index 2dc152f..790dd80 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -65,6 +65,7 @@ let recorder = null;
 let sessionMode = null;
 let shellDBusService = null;
 let shellMountOpDBusService = null;
+let screenSaverDBus = null;
 let modalCount = 0;
 let modalActorFocusStack = [];
 let uiGroup = null;
@@ -215,6 +216,7 @@ function start() {
     magnifier = new Magnifier.Magnifier();
     statusIconDispatcher = new StatusIconDispatcher.StatusIconDispatcher();
     screenShield = new ScreenShield.ScreenShield();
+    screenSaverDBus = new ShellDBus.ScreenSaverDBus();
     panel = new Panel.Panel();
     wm = new WindowManager.WindowManager();
     messageTray = new MessageTray.MessageTray();
diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js
index 661818e..53a6523 100644
--- a/js/ui/shellDBus.js
+++ b/js/ui/shellDBus.js
@@ -50,6 +50,20 @@ const GnomeShellIface = <interface name="org.gnome.Shell">
 <property name="ShellVersion" type="s" access="read" />
 </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({
     Name: 'GnomeShellDBus',
 
@@ -319,3 +333,33 @@ const GnomeShellExtensions = new Lang.Class({
                                    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;
+    }
+});
diff --git a/src/main.c b/src/main.c
index ad4fb3a..c4d2d28 100644
--- a/src/main.c
+++ b/src/main.c
@@ -34,6 +34,7 @@ extern GType gnome_shell_plugin_get_type (void);
 
 #define SHELL_DBUS_SERVICE "org.gnome.Shell"
 #define MAGNIFIER_DBUS_SERVICE "org.gnome.Magnifier"
+#define SCREENSAVER_DBUS_SERVICE "org.gnome.ScreenSaver"
 
 #define OVERRIDES_SCHEMA "org.gnome.shell.overrides"
 
@@ -152,6 +153,8 @@ shell_dbus_init (gboolean replace)
                             MAGNIFIER_DBUS_SERVICE, FALSE,
   /* ...and the org.freedesktop.Notifications service. */
                             "org.freedesktop.Notifications", FALSE,
+  /* ...and the org.gnome.ScreenSaver service. */
+                            SCREENSAVER_DBUS_SERVICE, FALSE,
                             NULL);
   /* ...and the on-screen keyboard service */
   shell_dbus_acquire_name (bus,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]