aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIain Lane <iain@orangesquash.org.uk>2014-03-19 17:35:47 +0000
committerIain Lane <iain@orangesquash.org.uk>2014-03-19 17:35:47 +0000
commitd5b6485ae8f17525ddc6e2beacb4f7a5dce73bfa (patch)
tree88e9cadf14f962ecc5841176e17c03251327e4f6 /src
parent574547d5b173aa5dc19e5e35207f02f72c9de629 (diff)
downloadayatana-indicator-session-d5b6485ae8f17525ddc6e2beacb4f7a5dce73bfa.tar.gz
ayatana-indicator-session-d5b6485ae8f17525ddc6e2beacb4f7a5dce73bfa.tar.bz2
ayatana-indicator-session-d5b6485ae8f17525ddc6e2beacb4f7a5dce73bfa.zip
Re-add the feature to hide the user list if com.canonical.indicator.session user-show-menu is false
Diffstat (limited to 'src')
-rw-r--r--src/service.c49
1 files changed, 42 insertions, 7 deletions
diff --git a/src/service.c b/src/service.c
index 60ddae0..88ce6b1 100644
--- a/src/service.c
+++ b/src/service.c
@@ -155,6 +155,14 @@ rebuild_settings_section_soon (IndicatorSessionService * self)
****
***/
+static gboolean
+show_user_list (IndicatorSessionService * self)
+{
+ return g_settings_get_boolean (self->priv->indicator_settings,
+ "user-show-menu");
+}
+
+
static GVariant *
action_state_for_header (IndicatorSessionService * self)
{
@@ -267,6 +275,32 @@ on_user_changed (IndicatorSessionUsers * backend_users G_GNUC_UNUSED,
}
static void
+maybe_add_users (IndicatorSessionService * self)
+{
+ if (!show_user_list (self))
+ return;
+
+ GList * uids, * l;
+
+ uids = indicator_session_users_get_uids (self->priv->backend_users);
+ for (l=uids; l!=NULL; l=l->next)
+ add_user (self, GPOINTER_TO_UINT(l->data));
+ g_list_free (uids);
+}
+
+
+static void
+user_show_menu_changed (IndicatorSessionService * self)
+{
+ if (show_user_list (self))
+ maybe_add_users (self);
+ else
+ g_hash_table_remove_all (self->priv->users);
+
+ rebuild_switch_section_soon (self);
+}
+
+static void
on_user_removed (IndicatorSessionUsers * backend_users G_GNUC_UNUSED,
guint uid,
gpointer gself)
@@ -541,7 +575,11 @@ create_switch_section (IndicatorSessionService * self, int profile)
g_object_unref (item);
}
- /* build an array of all the users we know of */
+ /* if we need to show the user list, build an array of all the users we know
+ * of, otherwise get out now */
+ if (!show_user_list (self))
+ return G_MENU_MODEL (menu);
+
users = g_ptr_array_new ();
g_hash_table_iter_init (&iter, p->users);
while (g_hash_table_iter_next (&iter, NULL, &guser))
@@ -1053,8 +1091,6 @@ static void
/* cppcheck-suppress unusedFunction */
indicator_session_service_init (IndicatorSessionService * self)
{
- GList * l;
- GList * uids;
priv_t * p;
gpointer gp;
GIcon * icon;
@@ -1088,10 +1124,7 @@ indicator_session_service_init (IndicatorSessionService * self)
g_direct_equal,
NULL,
(GDestroyNotify)indicator_session_user_free);
- uids = indicator_session_users_get_uids (p->backend_users);
- for (l=uids; l!=NULL; l=l->next)
- add_user (self, GPOINTER_TO_UINT(l->data));
- g_list_free (uids);
+ maybe_add_users (self);
init_gactions (self);
@@ -1138,6 +1171,8 @@ indicator_session_service_init (IndicatorSessionService * self)
G_CALLBACK(rebuild_session_section_soon), self);
g_signal_connect_swapped (gp, "changed::show-real-name-on-panel",
G_CALLBACK(rebuild_header_soon), self);
+ g_signal_connect_swapped (gp, "changed::user-show-menu",
+ G_CALLBACK(user_show_menu_changed), self);
/* watch for changes to the lock keybinding */
gp = p->keybinding_settings;