From 02ab93a720729796e63b66a521edd647c26182cb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 24 Feb 2010 11:26:24 -0600 Subject: Adding a fallback for now gnome-session detected. --- src/gtk-dialog/gtk-logout-helper.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/gtk-dialog') diff --git a/src/gtk-dialog/gtk-logout-helper.c b/src/gtk-dialog/gtk-logout-helper.c index d8aea6b..29f0add 100644 --- a/src/gtk-dialog/gtk-logout-helper.c +++ b/src/gtk-dialog/gtk-logout-helper.c @@ -29,6 +29,33 @@ with this program. If not, see . #include "ck-pk-helper.h" #include "gconf-helper.h" +static void +consolekit_fallback (LogoutDialogAction action) +{ + DBusGConnection * sbus = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); + g_return_if_fail(sbus != NULL); /* worst case */ + DBusGProxy * proxy = dbus_g_proxy_new_for_name(sbus, "org.freedesktop.ConsoleKit", + "/org/freedesktop/ConsoleKit/Manager", + "org.freedesktop.ConsoleKit.Manager"); + + if (proxy == NULL) { + g_warning("Unable to get consolekit proxy"); + return; + } + + switch (action) { + case LOGOUT_DIALOG_LOGOUT: { + g_warning("Unable to fallback to ConsoleKit for logout as it's a session issue. We need some sort of session handler."); + break; + } + default: + g_warning("Unknown action"); + break; + } + + g_object_unref(proxy); +} + static void session_action (LogoutDialogAction action) { @@ -50,6 +77,8 @@ session_action (LogoutDialogAction action) if (sm_proxy == NULL) { g_warning("Unable to get DBus proxy to SessionManager interface: %s", error->message); g_error_free(error); + + consolekit_fallback(action); return; } -- cgit v1.2.3 From 8985b002f45ca55cabf32225c7a483ea36905c86 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 24 Feb 2010 11:39:50 -0600 Subject: Adding in shutdown and restart --- src/gtk-dialog/gtk-logout-helper.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/gtk-dialog') diff --git a/src/gtk-dialog/gtk-logout-helper.c b/src/gtk-dialog/gtk-logout-helper.c index 29f0add..4c6614c 100644 --- a/src/gtk-dialog/gtk-logout-helper.c +++ b/src/gtk-dialog/gtk-logout-helper.c @@ -44,16 +44,27 @@ consolekit_fallback (LogoutDialogAction action) } switch (action) { - case LOGOUT_DIALOG_LOGOUT: { + case LOGOUT_DIALOG_LOGOUT: g_warning("Unable to fallback to ConsoleKit for logout as it's a session issue. We need some sort of session handler."); break; - } + case LOGOUT_DIALOG_SHUTDOWN: + dbus_g_proxy_call_no_reply(proxy, + "Stop", + G_TYPE_INVALID); + break; + case LOGOUT_DIALOG_RESTART: + dbus_g_proxy_call_no_reply(proxy, + "Restart", + G_TYPE_INVALID); + break; default: g_warning("Unknown action"); break; } g_object_unref(proxy); + + return; } static void -- cgit v1.2.3