Merge lp:~laney/indicator-session/hide-user-list into lp:indicator-session/14.04

Proposed by Iain Lane
Status: Merged
Approved by: Charles Kerr
Approved revision: 437
Merged at revision: 440
Proposed branch: lp:~laney/indicator-session/hide-user-list
Merge into: lp:indicator-session/14.04
Diff against target: 150 lines (+63/-8)
4 files modified
data/com.canonical.indicator.session.gschema.xml.in (+5/-0)
src/service.c (+42/-7)
tests/com.canonical.indicator.session.gschema.xml (+6/-1)
tests/test-service.cc (+10/-0)
To merge this branch: bzr merge lp:~laney/indicator-session/hide-user-list
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+211789@code.launchpad.net

Commit message

Re-add the feature to hide the user list if com.canonical.indicator.session user-show-menu is false

Description of the change

I think this is the right way to handle a boolean GSetting still, but let me know if it's not.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/com.canonical.indicator.session.gschema.xml.in'
2--- data/com.canonical.indicator.session.gschema.xml.in 2012-06-19 17:30:41 +0000
3+++ data/com.canonical.indicator.session.gschema.xml.in 2014-03-19 17:45:02 +0000
4@@ -25,6 +25,11 @@
5 <summary>Determine the visibility of the User's real name on the panel</summary>
6 <description>Allow for the Removal of the users name from the panel</description>
7 </key>
8+ <key type="b" name="user-show-menu">
9+ <default>true</default>
10+ <summary>Show the list of users</summary>
11+ <description>Allow for the user list to be hidden by the user.</description>
12+ </key>
13
14 </schema>
15
16
17=== modified file 'src/service.c'
18--- src/service.c 2014-03-11 14:02:31 +0000
19+++ src/service.c 2014-03-19 17:45:02 +0000
20@@ -155,6 +155,14 @@
21 ****
22 ***/
23
24+static gboolean
25+show_user_list (IndicatorSessionService * self)
26+{
27+ return g_settings_get_boolean (self->priv->indicator_settings,
28+ "user-show-menu");
29+}
30+
31+
32 static GVariant *
33 action_state_for_header (IndicatorSessionService * self)
34 {
35@@ -267,6 +275,32 @@
36 }
37
38 static void
39+maybe_add_users (IndicatorSessionService * self)
40+{
41+ if (!show_user_list (self))
42+ return;
43+
44+ GList * uids, * l;
45+
46+ uids = indicator_session_users_get_uids (self->priv->backend_users);
47+ for (l=uids; l!=NULL; l=l->next)
48+ add_user (self, GPOINTER_TO_UINT(l->data));
49+ g_list_free (uids);
50+}
51+
52+
53+static void
54+user_show_menu_changed (IndicatorSessionService * self)
55+{
56+ if (show_user_list (self))
57+ maybe_add_users (self);
58+ else
59+ g_hash_table_remove_all (self->priv->users);
60+
61+ rebuild_switch_section_soon (self);
62+}
63+
64+static void
65 on_user_removed (IndicatorSessionUsers * backend_users G_GNUC_UNUSED,
66 guint uid,
67 gpointer gself)
68@@ -541,7 +575,11 @@
69 g_object_unref (item);
70 }
71
72- /* build an array of all the users we know of */
73+ /* if we need to show the user list, build an array of all the users we know
74+ * of, otherwise get out now */
75+ if (!show_user_list (self))
76+ return G_MENU_MODEL (menu);
77+
78 users = g_ptr_array_new ();
79 g_hash_table_iter_init (&iter, p->users);
80 while (g_hash_table_iter_next (&iter, NULL, &guser))
81@@ -1053,8 +1091,6 @@
82 /* cppcheck-suppress unusedFunction */
83 indicator_session_service_init (IndicatorSessionService * self)
84 {
85- GList * l;
86- GList * uids;
87 priv_t * p;
88 gpointer gp;
89 GIcon * icon;
90@@ -1088,10 +1124,7 @@
91 g_direct_equal,
92 NULL,
93 (GDestroyNotify)indicator_session_user_free);
94- uids = indicator_session_users_get_uids (p->backend_users);
95- for (l=uids; l!=NULL; l=l->next)
96- add_user (self, GPOINTER_TO_UINT(l->data));
97- g_list_free (uids);
98+ maybe_add_users (self);
99
100 init_gactions (self);
101
102@@ -1138,6 +1171,8 @@
103 G_CALLBACK(rebuild_session_section_soon), self);
104 g_signal_connect_swapped (gp, "changed::show-real-name-on-panel",
105 G_CALLBACK(rebuild_header_soon), self);
106+ g_signal_connect_swapped (gp, "changed::user-show-menu",
107+ G_CALLBACK(user_show_menu_changed), self);
108
109 /* watch for changes to the lock keybinding */
110 gp = p->keybinding_settings;
111
112=== modified file 'tests/com.canonical.indicator.session.gschema.xml'
113--- tests/com.canonical.indicator.session.gschema.xml 2013-03-22 21:34:34 +0000
114+++ tests/com.canonical.indicator.session.gschema.xml 2014-03-19 17:45:02 +0000
115@@ -26,7 +26,12 @@
116 <summary>Determine the visibility of the User's real name on the panel</summary>
117 <description>Allow for the Removal of the users name from the panel</description>
118 </key>
119+ <key type="b" name="user-show-menu">
120+ <default>true</default>
121+ <summary>Show the list of users</summary>
122+ <description>Allow for the user menu to be hidden by the user.</description>
123+ </key>
124
125 </schema>
126
127-</schemalist>
128\ No newline at end of file
129+</schemalist>
130
131=== modified file 'tests/test-service.cc'
132--- tests/test-service.cc 2013-12-19 03:02:17 +0000
133+++ tests/test-service.cc 2014-03-19 17:45:02 +0000
134@@ -812,6 +812,16 @@
135 check_label ("Third Doctor", switch_menu, 8);
136 g_clear_object (&switch_menu);
137
138+ /* Hide the user list */
139+ g_settings_set_boolean (indicator_settings, "user-show-menu", FALSE);
140+ wait_for_menu_resync ();
141+ // now there should be 2 menuitems: greeter + guest
142+ ASSERT_TRUE (find_menu_item_for_action ("indicator.switch-to-screensaver", &switch_menu, &pos));
143+ ASSERT_EQ (0, pos);
144+ ASSERT_EQ (2, g_menu_model_get_n_items (switch_menu));
145+ g_clear_object (&switch_menu);
146+ g_settings_set_boolean (indicator_settings, "user-show-menu", TRUE);
147+
148 // now switch to one of the doctors
149 g_action_group_activate_action (G_ACTION_GROUP(action_group),
150 "switch-to-user",

Subscribers

People subscribed via source and target branches