[gnome-flashback] end-session-dialog: use D-Bus to lock screen
- From: Alberts MuktupÄvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] end-session-dialog: use D-Bus to lock screen
- Date: Fri, 20 Mar 2020 18:10:59 +0000 (UTC)
commit 7b151e0a947e4b49e1cee80097c1f8946ba46af9
Author: Alberts MuktupÄvels <alberts muktupavels gmail com>
Date: Fri Mar 20 20:09:12 2020 +0200
end-session-dialog: use D-Bus to lock screen
https://gitlab.gnome.org/GNOME/gnome-flashback/issues/43
.../libend-session-dialog/gf-inhibit-dialog.c | 64 ++++++++++++++++++----
1 file changed, 54 insertions(+), 10 deletions(-)
---
diff --git a/gnome-flashback/libend-session-dialog/gf-inhibit-dialog.c
b/gnome-flashback/libend-session-dialog/gf-inhibit-dialog.c
index 8892ad5..e243bea 100644
--- a/gnome-flashback/libend-session-dialog/gf-inhibit-dialog.c
+++ b/gnome-flashback/libend-session-dialog/gf-inhibit-dialog.c
@@ -31,6 +31,7 @@
#include <gdk/gdkx.h>
#include <cairo-xlib.h>
+#include "dbus/gf-screensaver-gen.h"
#include "gf-inhibit-dialog.h"
#define IS_STRING_EMPTY(string) ((string) == NULL || (string)[0] == '\0')
@@ -90,6 +91,52 @@ static void update_dialog_text (GfInhibitDialog *dialog);
G_DEFINE_TYPE_WITH_PRIVATE (GfInhibitDialog, gf_inhibit_dialog, GTK_TYPE_WINDOW)
+static void
+lock_cb (GObject *object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GError *error;
+
+ error = NULL;
+ gf_screensaver_gen_call_lock_finish (GF_SCREENSAVER_GEN (object),
+ res,
+ &error);
+
+ if (error != NULL)
+ {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Couldn't lock screen: %s", error->message);
+
+ g_error_free (error);
+ return;
+ }
+}
+
+static void
+screensaver_ready_cb (GObject *object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GError *error;
+ GfScreensaverGen *proxy;
+
+ error = NULL;
+ proxy = gf_screensaver_gen_proxy_new_for_bus_finish (res, &error);
+
+ if (error != NULL)
+ {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Couldn't lock screen: %s", error->message);
+
+ g_error_free (error);
+ return;
+ }
+
+ gf_screensaver_gen_call_lock (proxy, NULL, lock_cb, NULL);
+ g_object_unref (proxy);
+}
+
static void
gf_inhibit_dialog_set_action (GfInhibitDialog *dialog,
gint action)
@@ -911,16 +958,13 @@ static void
lock_screen_button_clicked (GtkButton *button,
GfInhibitDialog *dialog)
{
- GError *error;
-
- error = NULL;
- g_spawn_command_line_async ("gnome-screensaver-command --lock", &error);
-
- if (error != NULL)
- {
- g_warning ("Couldn't lock screen: %s", error->message);
- g_error_free (error);
- }
+ gf_screensaver_gen_proxy_new_for_bus (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_NONE,
+ "org.gnome.ScreenSaver",
+ "/org/gnome/ScreenSaver",
+ NULL,
+ screensaver_ready_cb,
+ NULL);
gf_inhibit_dialog_close (dialog);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]