aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2013-03-06 15:37:01 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2013-03-06 15:37:01 +0100
commit146019d9c53b7d8cc31c67d069e7ec055f4002fa (patch)
tree6f5993367ee06f2a48f7bb029468a80b29696304 /src
parentd93ba6784f824c4a19f85f6368a88744743171c9 (diff)
downloadayatana-indicator-session-146019d9c53b7d8cc31c67d069e7ec055f4002fa.tar.gz
ayatana-indicator-session-146019d9c53b7d8cc31c67d069e7ec055f4002fa.tar.bz2
ayatana-indicator-session-146019d9c53b7d8cc31c67d069e7ec055f4002fa.zip
SessionMenuMgr: use the fallback dialog if the dbus SessionManager calls fail
Diffstat (limited to 'src')
-rw-r--r--src/session-menu-mgr.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/session-menu-mgr.c b/src/session-menu-mgr.c
index 2173e86..851f5b1 100644
--- a/src/session-menu-mgr.c
+++ b/src/session-menu-mgr.c
@@ -1172,9 +1172,10 @@ action_func_hibernate (SessionMenuMgr * mgr)
}
}
-static void
+static gboolean
call_session_manager_method (const gchar * method_name, GVariant * parameters)
{
+ gboolean result = TRUE;
GError * error = NULL;
GDBusProxy * proxy = g_dbus_proxy_new_for_bus_sync (
G_BUS_TYPE_SESSION,
@@ -1199,32 +1200,38 @@ call_session_manager_method (const gchar * method_name, GVariant * parameters)
if (error != NULL)
{
+ result = FALSE;
g_warning ("Error shutting down: %s", error->message);
g_clear_error (&error);
}
g_clear_object (&proxy);
+
+ return result;
}
static void
action_func_shutdown (SessionMenuMgr * mgr)
{
+ gboolean result = FALSE;
+
if (mgr->shell_mode)
{
if (g_settings_get_boolean (mgr->indicator_settings,
"suppress-logout-restart-shutdown"))
{
- call_session_manager_method ("Shutdown", NULL);
+ result = call_session_manager_method ("Shutdown", NULL);
}
else
{
/* 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 */
- call_session_manager_method ("Reboot", NULL);
+ result = call_session_manager_method ("Reboot", NULL);
}
}
- else
+
+ if (!result)
{
action_func_spawn_async (CMD_SHUTDOWN);
}
@@ -1233,13 +1240,16 @@ action_func_shutdown (SessionMenuMgr * mgr)
static void
action_func_logout (SessionMenuMgr * mgr)
{
+ gboolean result = FALSE;
+
if (mgr->shell_mode)
{
guint interactive_mode = 0;
- call_session_manager_method ("Logout",
- g_variant_new ("(u)", interactive_mode));
+ result = call_session_manager_method ("Logout",
+ g_variant_new ("(u)", interactive_mode));
}
- else
+
+ if (!result)
{
action_func_spawn_async (CMD_LOGOUT);
}
@@ -1248,11 +1258,14 @@ action_func_logout (SessionMenuMgr * mgr)
static void
action_func_reboot (SessionMenuMgr * mgr)
{
+ gboolean result = FALSE;
+
if (mgr->shell_mode)
{
- call_session_manager_method ("Reboot", NULL);
+ result = call_session_manager_method ("Reboot", NULL);
}
- else
+
+ if (!result)
{
action_func_spawn_async (CMD_RESTART);
}