[gnome-settings-daemon] media-keys: Use D-Bus API to lock the screen



commit 04050b66ba6241d9c986734c37022ade1aff251d
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Jan 23 17:23:23 2013 +0100

    media-keys: Use D-Bus API to lock the screen
    
    gnome-screensaver-command was shipped by gnome-screensaver, which
    has been removed from the GNOME desktop proper.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=692401

 plugins/media-keys/gsd-media-keys-manager.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index 750b857..32eb148 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -69,6 +69,10 @@
 #define GNOME_KEYRING_DBUS_PATH "/org/gnome/keyring/daemon"
 #define GNOME_KEYRING_DBUS_INTERFACE "org.gnome.keyring.Daemon"
 
+#define GS_DBUS_NAME                            "org.gnome.ScreenSaver"
+#define GS_DBUS_PATH                            "/org/gnome/ScreenSaver"
+#define GS_DBUS_INTERFACE                       "org.gnome.ScreenSaver"
+
 #define CUSTOM_BINDING_SCHEMA SETTINGS_BINDING_DIR ".custom-keybinding"
 
 static const gchar introspection_xml[] =
@@ -930,6 +934,25 @@ do_touchpad_action (GsdMediaKeysManager *manager)
 }
 
 static void
+do_lock_screensaver (GsdMediaKeysManager *manager)
+{
+        GsdMediaKeysManagerPrivate *priv = manager->priv;
+
+        if (priv->connection == NULL) {
+                g_warning ("No existing D-Bus connection trying to handle screensaver lock key");
+                return;
+        }
+        g_dbus_connection_call (manager->priv->connection,
+                                GS_DBUS_NAME,
+                                GS_DBUS_PATH,
+                                GS_DBUS_INTERFACE,
+                                "Lock",
+                                NULL, NULL,
+                                G_DBUS_CALL_FLAGS_NONE, -1,
+                                NULL, NULL, NULL);
+}
+
+static void
 update_dialog (GsdMediaKeysManager *manager,
                GvcMixerStream      *stream,
                guint                vol,
@@ -1946,7 +1969,7 @@ do_action (GsdMediaKeysManager *manager,
                 do_url_action (manager, "mailto", timestamp);
                 break;
         case SCREENSAVER_KEY:
-                execute (manager, "gnome-screensaver-command --lock", FALSE);
+                do_lock_screensaver (manager);
                 break;
         case HELP_KEY:
                 do_url_action (manager, "ghelp", timestamp);



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