diff options
author | Ted Gould <ted@gould.cx> | 2010-03-03 15:39:16 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-03-03 15:39:16 -0600 |
commit | d694e0a23c44a6c48a6b23509dd8b00a3d622611 (patch) | |
tree | 31f4c1b9095b5fdab639bce415a1c0a2c2d7904d /src/gtk-dialog | |
parent | b51d58db757ccec277216f3e4f3e74c67ea75884 (diff) | |
parent | bb12842de3558842bacbc9bafcff40490a8bc409 (diff) | |
download | ayatana-indicator-session-d694e0a23c44a6c48a6b23509dd8b00a3d622611.tar.gz ayatana-indicator-session-d694e0a23c44a6c48a6b23509dd8b00a3d622611.tar.bz2 ayatana-indicator-session-d694e0a23c44a6c48a6b23509dd8b00a3d622611.zip |
Merging in the consolekit branch to get the interface file.
Diffstat (limited to 'src/gtk-dialog')
-rw-r--r-- | src/gtk-dialog/gtk-logout-helper.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/gtk-dialog/gtk-logout-helper.c b/src/gtk-dialog/gtk-logout-helper.c index 5f087ff..a76a135 100644 --- a/src/gtk-dialog/gtk-logout-helper.c +++ b/src/gtk-dialog/gtk-logout-helper.c @@ -29,6 +29,53 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #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; + } + + GError * error = NULL; + + 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; + case LOGOUT_DIALOG_SHUTDOWN: + dbus_g_proxy_call(proxy, + "Stop", + &error, + G_TYPE_INVALID); + break; + case LOGOUT_DIALOG_RESTART: + dbus_g_proxy_call(proxy, + "Restart", + &error, + G_TYPE_INVALID); + break; + default: + g_warning("Unknown action"); + break; + } + + g_object_unref(proxy); + + if (error != NULL) { + g_error("Unable to signal ConsoleKit: %s", error->message); + g_error_free(error); + } + + return; +} + +static void session_action (LogoutDialogType action) { DBusGConnection * sbus; @@ -49,6 +96,8 @@ session_action (LogoutDialogType 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; } |