aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/com.canonical.indicator.session.gschema.xml.in5
-rw-r--r--src/service.c49
-rw-r--r--tests/com.canonical.indicator.session.gschema.xml7
-rw-r--r--tests/test-service.cc10
4 files changed, 63 insertions, 8 deletions
diff --git a/data/com.canonical.indicator.session.gschema.xml.in b/data/com.canonical.indicator.session.gschema.xml.in
index 6010b3f..d5e852e 100644
--- a/data/com.canonical.indicator.session.gschema.xml.in
+++ b/data/com.canonical.indicator.session.gschema.xml.in
@@ -25,6 +25,11 @@
<summary>Determine the visibility of the User's real name on the panel</summary>
<description>Allow for the Removal of the users name from the panel</description>
</key>
+ <key type="b" name="user-show-menu">
+ <default>true</default>
+ <summary>Show the list of users</summary>
+ <description>Allow for the user list to be hidden by the user.</description>
+ </key>
</schema>
diff --git a/src/service.c b/src/service.c
index 2321d0a..5136a44 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)
@@ -545,7 +579,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))
@@ -1057,8 +1095,6 @@ static void
/* cppcheck-suppress unusedFunction */
indicator_session_service_init (IndicatorSessionService * self)
{
- GList * l;
- GList * uids;
priv_t * p;
gpointer gp;
GIcon * icon;
@@ -1092,10 +1128,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);
@@ -1142,6 +1175,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;
diff --git a/tests/com.canonical.indicator.session.gschema.xml b/tests/com.canonical.indicator.session.gschema.xml
index 76b2be3..60e680b 100644
--- a/tests/com.canonical.indicator.session.gschema.xml
+++ b/tests/com.canonical.indicator.session.gschema.xml
@@ -26,7 +26,12 @@
<summary>Determine the visibility of the User's real name on the panel</summary>
<description>Allow for the Removal of the users name from the panel</description>
</key>
+ <key type="b" name="user-show-menu">
+ <default>true</default>
+ <summary>Show the list of users</summary>
+ <description>Allow for the user menu to be hidden by the user.</description>
+ </key>
</schema>
-</schemalist> \ No newline at end of file
+</schemalist>
diff --git a/tests/test-service.cc b/tests/test-service.cc
index f14fe61..20c70f5 100644
--- a/tests/test-service.cc
+++ b/tests/test-service.cc
@@ -812,6 +812,16 @@ TEST_F (ServiceTest, User)
check_label ("Third Doctor", switch_menu, 8);
g_clear_object (&switch_menu);
+ /* Hide the user list */
+ g_settings_set_boolean (indicator_settings, "user-show-menu", FALSE);
+ wait_for_menu_resync ();
+ // now there should be 2 menuitems: greeter + guest
+ ASSERT_TRUE (find_menu_item_for_action ("indicator.switch-to-screensaver", &switch_menu, &pos));
+ ASSERT_EQ (0, pos);
+ ASSERT_EQ (2, g_menu_model_get_n_items (switch_menu));
+ g_clear_object (&switch_menu);
+ g_settings_set_boolean (indicator_settings, "user-show-menu", TRUE);
+
// now switch to one of the doctors
g_action_group_activate_action (G_ACTION_GROUP(action_group),
"switch-to-user",