Merge lp:~charlesk/indicator-session/lp-1206550 into lp:indicator-session/14.04

Proposed by Charles Kerr
Status: Merged
Merged at revision: 441
Proposed branch: lp:~charlesk/indicator-session/lp-1206550
Merge into: lp:indicator-session/14.04
Diff against target: 200 lines (+35/-66)
3 files modified
src/service.c (+2/-37)
tests/gtest-dbus-fixture.h (+32/-23)
tests/test-service.cc (+1/-6)
To merge this branch: bzr merge lp:~charlesk/indicator-session/lp-1206550
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Indicator Applet Developers Pending
Review via email: mp+211764@code.launchpad.net

Commit message

Don't show a red icon in indicator-session when there's an online user account error.

Description of the change

Don't show a red icon in indicator-session when there's an online user account error.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/service.c'
2--- src/service.c 2014-03-11 14:02:31 +0000
3+++ src/service.c 2014-03-19 15:50:34 +0000
4@@ -108,9 +108,6 @@
5 int rebuild_flags;
6 GDBusConnection * conn;
7 GCancellable * cancellable;
8-
9- /* serialized icon cache */
10- GVariant * alert_icon_serialized;
11 GVariant * default_icon_serialized;
12 };
13
14@@ -159,8 +156,6 @@
15 action_state_for_header (IndicatorSessionService * self)
16 {
17 const priv_t * const p = self->priv;
18- gboolean need_attn;
19- GVariant * serialized_icon;
20 gboolean show_name;
21 const gchar * real_name;
22 const gchar * label;
23@@ -168,38 +163,17 @@
24 GVariantBuilder b;
25 GVariant * state;
26
27- if (indicator_session_actions_has_online_account_error (p->backend_actions))
28- {
29- need_attn = TRUE;
30- serialized_icon = p->alert_icon_serialized;
31- }
32- else
33- {
34- need_attn = FALSE;
35- serialized_icon = p->default_icon_serialized;
36- }
37-
38 show_name = g_settings_get_boolean (p->indicator_settings,
39 "show-real-name-on-panel");
40
41 real_name = get_current_real_name (self);
42 label = show_name && real_name ? real_name : "";
43
44- if (*label && need_attn)
45- {
46- /* Translators: the name of the menu ("System"), then the user's name,
47- then a hint that something in this menu requires user attention */
48- a11y = g_strdup_printf (_("System, %s (Attention Required)"), real_name);
49- }
50- else if (*label)
51+ if (*label)
52 {
53 /* Translators: the name of the menu ("System"), then the user's name */
54 a11y = g_strdup_printf (_("System, %s"), label);
55 }
56- else if (need_attn)
57- {
58- a11y = g_strdup (_("System (Attention Required)"));
59- }
60 else
61 {
62 a11y = g_strdup (_("System"));
63@@ -208,8 +182,7 @@
64 /* build the state */
65 g_variant_builder_init (&b, G_VARIANT_TYPE("a{sv}"));
66 g_variant_builder_add (&b, "{sv}", "accessible-desc", g_variant_new_string (a11y));
67- if (serialized_icon != NULL)
68- g_variant_builder_add (&b, "{sv}", "icon", serialized_icon);
69+ g_variant_builder_add (&b, "{sv}", "icon", p->default_icon_serialized);
70 if (label && *label)
71 g_variant_builder_add (&b, "{sv}", "label", g_variant_new_string (label));
72 g_variant_builder_add (&b, "{sv}", "visible", g_variant_new_boolean (TRUE));
73@@ -1073,12 +1046,6 @@
74 &p->backend_users,
75 &p->backend_guest);
76
77- /* build the serialized icon cache */
78-
79- icon = g_themed_icon_new_with_default_fallbacks (ICON_ALERT);
80- p->alert_icon_serialized = g_icon_serialize (icon);
81- g_object_unref (icon);
82-
83 icon = g_themed_icon_new_with_default_fallbacks (ICON_DEFAULT);
84 p->default_icon_serialized = g_icon_serialize (icon);
85 g_object_unref (icon);
86@@ -1244,8 +1211,6 @@
87 g_clear_object (&p->guest_switcher_action);
88 g_clear_object (&p->conn);
89
90- /* clear the serialized icon cache */
91- g_clear_pointer (&p->alert_icon_serialized, g_variant_unref);
92 g_clear_pointer (&p->default_icon_serialized, g_variant_unref);
93
94 G_OBJECT_CLASS (indicator_session_service_parent_class)->dispose (o);
95
96=== modified file 'tests/gtest-dbus-fixture.h'
97--- tests/gtest-dbus-fixture.h 2013-03-22 21:34:34 +0000
98+++ tests/gtest-dbus-fixture.h 2014-03-19 15:50:34 +0000
99@@ -54,13 +54,6 @@
100 g_main_loop_quit (self->loop);
101 }
102
103- static gboolean
104- wait_for_signal__timeout (gpointer name)
105- {
106- g_error ("%s: timed out waiting for signal '%s'", G_STRLOC, (char*)name);
107- return G_SOURCE_REMOVE;
108- }
109-
110 protected:
111
112 virtual void SetUp ()
113@@ -103,29 +96,45 @@
114 g_clear_pointer (&loop, g_main_loop_unref);
115 }
116
117+ private:
118+
119+ static gboolean
120+ wait_for_signal__timeout(gpointer name)
121+ {
122+ g_error("%s: timed out waiting for signal '%s'", G_STRLOC, (char*)name);
123+ return G_SOURCE_REMOVE;
124+ }
125+
126+ static gboolean
127+ wait_msec__timeout(gpointer loop)
128+ {
129+ g_main_loop_quit(static_cast<GMainLoop*>(loop));
130+ return G_SOURCE_CONTINUE;
131+ }
132+
133+ protected:
134+
135 /* convenience func to loop while waiting for a GObject's signal */
136- void wait_for_signal (gpointer o, const gchar * signal)
137+ void wait_for_signal(gpointer o, const gchar * signal, const int timeout_seconds=5)
138 {
139- const int timeout_seconds = 5; // arbitrary
140-
141 // wait for the signal or for timeout, whichever comes first
142- guint handler_id = g_signal_connect_swapped (o, signal,
143- G_CALLBACK(g_main_loop_quit),
144- loop);
145- gulong timeout_id = g_timeout_add_seconds (timeout_seconds,
146- wait_for_signal__timeout,
147- loop);
148- g_main_loop_run (loop);
149- g_source_remove (timeout_id);
150- g_signal_handler_disconnect (o, handler_id);
151+ const auto handler_id = g_signal_connect_swapped(o, signal,
152+ G_CALLBACK(g_main_loop_quit),
153+ loop);
154+ const auto timeout_id = g_timeout_add_seconds(timeout_seconds,
155+ wait_for_signal__timeout,
156+ loop);
157+ g_main_loop_run(loop);
158+ g_source_remove(timeout_id);
159+ g_signal_handler_disconnect(o, handler_id);
160 }
161
162 /* convenience func to loop for N msec */
163- void wait_msec (int msec)
164+ void wait_msec(int msec=50)
165 {
166- guint id = g_timeout_add (msec, (GSourceFunc)g_main_loop_quit, loop);
167- g_main_loop_run (loop);
168- g_source_remove (id);
169+ const auto id = g_timeout_add(msec, wait_msec__timeout, loop);
170+ g_main_loop_run(loop);
171+ g_source_remove(id);
172 }
173
174 GMainLoop * loop;
175
176=== modified file 'tests/test-service.cc'
177--- tests/test-service.cc 2013-12-19 03:02:17 +0000
178+++ tests/test-service.cc 2014-03-19 15:50:34 +0000
179@@ -616,7 +616,7 @@
180 check_last_command_is ("online-accounts");
181
182 // check that the header's icon and a11y adjusted to the error state
183- check_header ("", "system-devices-panel-alert", "System (Attention Required)");
184+ check_header ("", "system-devices-panel", "System");
185
186 // cleanup
187 g_settings_reset (mock_settings, error_key);
188@@ -756,12 +756,7 @@
189 g_settings_set_boolean (indicator_settings, show_name_key, true);
190 wait_for_signal (action_group, "action-state-changed");
191 check_header ("Third Doctor", "system-devices-panel", "System, Third Doctor");
192- g_settings_set_boolean (mock_settings, error_key, true);
193- wait_for_signal (action_group, "action-state-changed");
194- check_header ("Third Doctor", "system-devices-panel-alert", "System, Third Doctor (Attention Required)");
195- g_settings_reset (mock_settings, error_key);
196 g_settings_reset (indicator_settings, show_name_key);
197- wait_for_menu_resync ();
198
199 // try setting the max user count to 2...
200 // since troughton has the fewest logins, he should get culled

Subscribers

People subscribed via source and target branches