aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2013-03-05 03:00:20 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2013-03-05 03:00:20 +0100
commit7f88c35d7ef9d504dc6b78769bf084fafbbfbcdf (patch)
treeecd8bbad4b56b08154f1f0e6cbaade17ffbc3018 /src
parent6aeffd92d497b1130250eeaf832dfc5fdaeabd10 (diff)
downloadayatana-indicator-session-7f88c35d7ef9d504dc6b78769bf084fafbbfbcdf.tar.gz
ayatana-indicator-session-7f88c35d7ef9d504dc6b78769bf084fafbbfbcdf.tar.bz2
ayatana-indicator-session-7f88c35d7ef9d504dc6b78769bf084fafbbfbcdf.zip
SessionMenuMgr: call gnome SessionManager method to shutdown on shell-mode
Diffstat (limited to 'src')
-rw-r--r--src/session-menu-mgr.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/session-menu-mgr.c b/src/session-menu-mgr.c
index 96781c0..7e87c39 100644
--- a/src/session-menu-mgr.c
+++ b/src/session-menu-mgr.c
@@ -134,6 +134,7 @@ static void update_confirmation_labels (SessionMenuMgr *);
static void action_func_lock (SessionMenuMgr *);
static void action_func_suspend (SessionMenuMgr *);
static void action_func_hibernate (SessionMenuMgr *);
+static void action_func_shutdown (SessionMenuMgr *);
static void action_func_switch_to_lockscreen (SessionMenuMgr *);
static void action_func_switch_to_greeter (SessionMenuMgr *);
static void action_func_switch_to_guest (SessionMenuMgr *);
@@ -568,7 +569,7 @@ build_session_menuitems (SessionMenuMgr* mgr)
mi = mgr->shutdown_mi = mi_new (_("Shut Down\342\200\246"));
dbusmenu_menuitem_child_append (mgr->top_mi, mi);
g_signal_connect_swapped (mi, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
- G_CALLBACK(action_func_spawn_async), CMD_SHUTDOWN);
+ G_CALLBACK(action_func_shutdown), mgr);
update_confirmation_labels (mgr);
update_session_menuitems (mgr);
@@ -1169,6 +1170,46 @@ action_func_hibernate (SessionMenuMgr * mgr)
}
}
+static void
+action_func_shutdown (SessionMenuMgr * mgr)
+{
+ if (mgr->shell_mode)
+ {
+ GError * error = NULL;
+ GDBusProxy * proxy = g_dbus_proxy_new_for_bus_sync (
+ G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ "org.gnome.SessionManager",
+ "/org/gnome/SessionManager",
+ "org.gnome.SessionManager",
+ NULL,
+ &error);
+
+ if (error == NULL)
+ {
+ /* We call 'Reboot' method instead of 'Shutdown' because
+ * Unity SessionManager handles the Shutdown request as a more
+ * general request as the default SessionManager dialog would do */
+ g_dbus_proxy_call_sync (proxy, "Reboot",
+ NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL,
+ &error);
+ }
+
+ if (error != NULL)
+ {
+ g_warning ("Error shutting down: %s", error->message);
+ g_clear_error (&error);
+ }
+
+ g_clear_object (&proxy);
+ }
+ else
+ {
+ action_func_spawn_async (CMD_SHUTDOWN);
+ }
+}
+
/***
****
***/