aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2013-03-05 02:43:35 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2013-03-05 02:43:35 +0100
commit6aeffd92d497b1130250eeaf832dfc5fdaeabd10 (patch)
tree6b5c626432e52ae869cb206cd634709bc478d607 /src
parent165992775c830dcf59870691963b90ed78bc0038 (diff)
downloadayatana-indicator-session-6aeffd92d497b1130250eeaf832dfc5fdaeabd10.tar.gz
ayatana-indicator-session-6aeffd92d497b1130250eeaf832dfc5fdaeabd10.tar.bz2
ayatana-indicator-session-6aeffd92d497b1130250eeaf832dfc5fdaeabd10.zip
SessionManager: add shell name watcher and hide reboot 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 b618135..96781c0 100644
--- a/src/session-menu-mgr.c
+++ b/src/session-menu-mgr.c
@@ -110,8 +110,10 @@ struct _SessionMenuMgr
gboolean allow_hibernate;
gboolean allow_suspend;
+ gboolean shell_mode;
gboolean greeter_mode;
+ guint shell_name_watcher;
GCancellable * cancellable;
DBusUPower * upower_proxy;
SessionDbus * session_dbus;
@@ -122,6 +124,7 @@ struct _SessionMenuMgr
static SwitcherMode get_switcher_mode (SessionMenuMgr *);
static void init_upower_proxy (SessionMenuMgr *);
+static void init_shell_watcher (SessionMenuMgr *);
static void update_screensaver_shortcut (SessionMenuMgr *);
static void update_user_menuitems (SessionMenuMgr *);
@@ -196,6 +199,7 @@ session_menu_mgr_init (SessionMenuMgr *mgr)
G_CALLBACK(on_guest_logged_in_changed), mgr);
init_upower_proxy (mgr);
+ init_shell_watcher (mgr);
/* Online accounts menu item */
mgr->online_accounts_mgr = online_accounts_mgr_new ();
@@ -224,6 +228,11 @@ session_menu_mgr_dispose (GObject *object)
g_slist_free (mgr->user_menuitems);
mgr->user_menuitems = NULL;
+ if (mgr->shell_name_watcher)
+ {
+ g_bus_unwatch_name (mgr->shell_name_watcher);
+ }
+
G_OBJECT_CLASS (session_menu_mgr_parent_class)->dispose (object);
}
@@ -328,6 +337,37 @@ init_upower_proxy (SessionMenuMgr * mgr)
}
}
+static void
+on_shell_name_appeared (GDBusConnection *connection, const gchar *name,
+ const gchar *name_owner, gpointer user_data)
+{
+ SessionMenuMgr * mgr = SESSION_MENU_MGR(user_data);
+
+ g_debug("Shell appeared");
+ mgr->shell_mode = TRUE;
+ update_session_menuitems (mgr);
+}
+
+static void
+on_shell_name_vanished (GDBusConnection *connection, const gchar *name, gpointer user_data)
+{
+ SessionMenuMgr * mgr = SESSION_MENU_MGR(user_data);
+
+ g_debug("Shell vanished");
+ mgr->shell_mode = FALSE;
+ update_session_menuitems (mgr);
+}
+
+static void
+init_shell_watcher (SessionMenuMgr * mgr)
+{
+ mgr->shell_name_watcher = g_bus_watch_name (G_BUS_TYPE_SESSION, "org.gnome.Shell",
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ on_shell_name_appeared,
+ on_shell_name_vanished,
+ mgr, NULL);
+}
+
/***
**** Menuitem Helpers
***/
@@ -468,7 +508,8 @@ update_session_menuitems (SessionMenuMgr * mgr)
&& mgr->allow_hibernate;
mi_set_visible (mgr->hibernate_mi, v);
- v = HAVE_RESTART_CMD
+ v = !mgr->shell_mode
+ && HAVE_RESTART_CMD
&& !g_settings_get_boolean (s, "suppress-restart-menuitem");
mi_set_visible (mgr->restart_mi, v);