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
=== modified file 'src/service.c'
--- src/service.c 2014-03-11 14:02:31 +0000
+++ src/service.c 2014-03-19 15:50:34 +0000
@@ -108,9 +108,6 @@
108 int rebuild_flags;108 int rebuild_flags;
109 GDBusConnection * conn;109 GDBusConnection * conn;
110 GCancellable * cancellable;110 GCancellable * cancellable;
111
112 /* serialized icon cache */
113 GVariant * alert_icon_serialized;
114 GVariant * default_icon_serialized;111 GVariant * default_icon_serialized;
115};112};
116113
@@ -159,8 +156,6 @@
159action_state_for_header (IndicatorSessionService * self)156action_state_for_header (IndicatorSessionService * self)
160{157{
161 const priv_t * const p = self->priv;158 const priv_t * const p = self->priv;
162 gboolean need_attn;
163 GVariant * serialized_icon;
164 gboolean show_name;159 gboolean show_name;
165 const gchar * real_name;160 const gchar * real_name;
166 const gchar * label;161 const gchar * label;
@@ -168,38 +163,17 @@
168 GVariantBuilder b;163 GVariantBuilder b;
169 GVariant * state;164 GVariant * state;
170165
171 if (indicator_session_actions_has_online_account_error (p->backend_actions))
172 {
173 need_attn = TRUE;
174 serialized_icon = p->alert_icon_serialized;
175 }
176 else
177 {
178 need_attn = FALSE;
179 serialized_icon = p->default_icon_serialized;
180 }
181
182 show_name = g_settings_get_boolean (p->indicator_settings,166 show_name = g_settings_get_boolean (p->indicator_settings,
183 "show-real-name-on-panel");167 "show-real-name-on-panel");
184168
185 real_name = get_current_real_name (self);169 real_name = get_current_real_name (self);
186 label = show_name && real_name ? real_name : "";170 label = show_name && real_name ? real_name : "";
187171
188 if (*label && need_attn)172 if (*label)
189 {
190 /* Translators: the name of the menu ("System"), then the user's name,
191 then a hint that something in this menu requires user attention */
192 a11y = g_strdup_printf (_("System, %s (Attention Required)"), real_name);
193 }
194 else if (*label)
195 {173 {
196 /* Translators: the name of the menu ("System"), then the user's name */174 /* Translators: the name of the menu ("System"), then the user's name */
197 a11y = g_strdup_printf (_("System, %s"), label);175 a11y = g_strdup_printf (_("System, %s"), label);
198 }176 }
199 else if (need_attn)
200 {
201 a11y = g_strdup (_("System (Attention Required)"));
202 }
203 else177 else
204 {178 {
205 a11y = g_strdup (_("System"));179 a11y = g_strdup (_("System"));
@@ -208,8 +182,7 @@
208 /* build the state */182 /* build the state */
209 g_variant_builder_init (&b, G_VARIANT_TYPE("a{sv}"));183 g_variant_builder_init (&b, G_VARIANT_TYPE("a{sv}"));
210 g_variant_builder_add (&b, "{sv}", "accessible-desc", g_variant_new_string (a11y));184 g_variant_builder_add (&b, "{sv}", "accessible-desc", g_variant_new_string (a11y));
211 if (serialized_icon != NULL)185 g_variant_builder_add (&b, "{sv}", "icon", p->default_icon_serialized);
212 g_variant_builder_add (&b, "{sv}", "icon", serialized_icon);
213 if (label && *label)186 if (label && *label)
214 g_variant_builder_add (&b, "{sv}", "label", g_variant_new_string (label));187 g_variant_builder_add (&b, "{sv}", "label", g_variant_new_string (label));
215 g_variant_builder_add (&b, "{sv}", "visible", g_variant_new_boolean (TRUE));188 g_variant_builder_add (&b, "{sv}", "visible", g_variant_new_boolean (TRUE));
@@ -1073,12 +1046,6 @@
1073 &p->backend_users,1046 &p->backend_users,
1074 &p->backend_guest);1047 &p->backend_guest);
10751048
1076 /* build the serialized icon cache */
1077
1078 icon = g_themed_icon_new_with_default_fallbacks (ICON_ALERT);
1079 p->alert_icon_serialized = g_icon_serialize (icon);
1080 g_object_unref (icon);
1081
1082 icon = g_themed_icon_new_with_default_fallbacks (ICON_DEFAULT);1049 icon = g_themed_icon_new_with_default_fallbacks (ICON_DEFAULT);
1083 p->default_icon_serialized = g_icon_serialize (icon);1050 p->default_icon_serialized = g_icon_serialize (icon);
1084 g_object_unref (icon);1051 g_object_unref (icon);
@@ -1244,8 +1211,6 @@
1244 g_clear_object (&p->guest_switcher_action);1211 g_clear_object (&p->guest_switcher_action);
1245 g_clear_object (&p->conn);1212 g_clear_object (&p->conn);
12461213
1247 /* clear the serialized icon cache */
1248 g_clear_pointer (&p->alert_icon_serialized, g_variant_unref);
1249 g_clear_pointer (&p->default_icon_serialized, g_variant_unref);1214 g_clear_pointer (&p->default_icon_serialized, g_variant_unref);
12501215
1251 G_OBJECT_CLASS (indicator_session_service_parent_class)->dispose (o);1216 G_OBJECT_CLASS (indicator_session_service_parent_class)->dispose (o);
12521217
=== modified file 'tests/gtest-dbus-fixture.h'
--- tests/gtest-dbus-fixture.h 2013-03-22 21:34:34 +0000
+++ tests/gtest-dbus-fixture.h 2014-03-19 15:50:34 +0000
@@ -54,13 +54,6 @@
54 g_main_loop_quit (self->loop);54 g_main_loop_quit (self->loop);
55 }55 }
5656
57 static gboolean
58 wait_for_signal__timeout (gpointer name)
59 {
60 g_error ("%s: timed out waiting for signal '%s'", G_STRLOC, (char*)name);
61 return G_SOURCE_REMOVE;
62 }
63
64 protected:57 protected:
6558
66 virtual void SetUp ()59 virtual void SetUp ()
@@ -103,29 +96,45 @@
103 g_clear_pointer (&loop, g_main_loop_unref);96 g_clear_pointer (&loop, g_main_loop_unref);
104 }97 }
10598
99 private:
100
101 static gboolean
102 wait_for_signal__timeout(gpointer name)
103 {
104 g_error("%s: timed out waiting for signal '%s'", G_STRLOC, (char*)name);
105 return G_SOURCE_REMOVE;
106 }
107
108 static gboolean
109 wait_msec__timeout(gpointer loop)
110 {
111 g_main_loop_quit(static_cast<GMainLoop*>(loop));
112 return G_SOURCE_CONTINUE;
113 }
114
115 protected:
116
106 /* convenience func to loop while waiting for a GObject's signal */117 /* convenience func to loop while waiting for a GObject's signal */
107 void wait_for_signal (gpointer o, const gchar * signal)118 void wait_for_signal(gpointer o, const gchar * signal, const int timeout_seconds=5)
108 {119 {
109 const int timeout_seconds = 5; // arbitrary
110
111 // wait for the signal or for timeout, whichever comes first120 // wait for the signal or for timeout, whichever comes first
112 guint handler_id = g_signal_connect_swapped (o, signal,121 const auto handler_id = g_signal_connect_swapped(o, signal,
113 G_CALLBACK(g_main_loop_quit),122 G_CALLBACK(g_main_loop_quit),
114 loop);123 loop);
115 gulong timeout_id = g_timeout_add_seconds (timeout_seconds,124 const auto timeout_id = g_timeout_add_seconds(timeout_seconds,
116 wait_for_signal__timeout,125 wait_for_signal__timeout,
117 loop);126 loop);
118 g_main_loop_run (loop);127 g_main_loop_run(loop);
119 g_source_remove (timeout_id);128 g_source_remove(timeout_id);
120 g_signal_handler_disconnect (o, handler_id);129 g_signal_handler_disconnect(o, handler_id);
121 }130 }
122131
123 /* convenience func to loop for N msec */132 /* convenience func to loop for N msec */
124 void wait_msec (int msec)133 void wait_msec(int msec=50)
125 {134 {
126 guint id = g_timeout_add (msec, (GSourceFunc)g_main_loop_quit, loop);135 const auto id = g_timeout_add(msec, wait_msec__timeout, loop);
127 g_main_loop_run (loop);136 g_main_loop_run(loop);
128 g_source_remove (id);137 g_source_remove(id);
129 }138 }
130139
131 GMainLoop * loop;140 GMainLoop * loop;
132141
=== modified file 'tests/test-service.cc'
--- tests/test-service.cc 2013-12-19 03:02:17 +0000
+++ tests/test-service.cc 2014-03-19 15:50:34 +0000
@@ -616,7 +616,7 @@
616 check_last_command_is ("online-accounts");616 check_last_command_is ("online-accounts");
617617
618 // check that the header's icon and a11y adjusted to the error state618 // check that the header's icon and a11y adjusted to the error state
619 check_header ("", "system-devices-panel-alert", "System (Attention Required)");619 check_header ("", "system-devices-panel", "System");
620620
621 // cleanup621 // cleanup
622 g_settings_reset (mock_settings, error_key);622 g_settings_reset (mock_settings, error_key);
@@ -756,12 +756,7 @@
756 g_settings_set_boolean (indicator_settings, show_name_key, true);756 g_settings_set_boolean (indicator_settings, show_name_key, true);
757 wait_for_signal (action_group, "action-state-changed");757 wait_for_signal (action_group, "action-state-changed");
758 check_header ("Third Doctor", "system-devices-panel", "System, Third Doctor");758 check_header ("Third Doctor", "system-devices-panel", "System, Third Doctor");
759 g_settings_set_boolean (mock_settings, error_key, true);
760 wait_for_signal (action_group, "action-state-changed");
761 check_header ("Third Doctor", "system-devices-panel-alert", "System, Third Doctor (Attention Required)");
762 g_settings_reset (mock_settings, error_key);
763 g_settings_reset (indicator_settings, show_name_key);759 g_settings_reset (indicator_settings, show_name_key);
764 wait_for_menu_resync ();
765760
766 // try setting the max user count to 2...761 // try setting the max user count to 2...
767 // since troughton has the fewest logins, he should get culled762 // since troughton has the fewest logins, he should get culled

Subscribers

People subscribed via source and target branches