Merge lp:~charlesk/indicator-session/header-action-state-dict into lp:indicator-session/13.10

Proposed by Charles Kerr
Status: Merged
Approved by: Ted Gould
Approved revision: 410
Merged at revision: 410
Proposed branch: lp:~charlesk/indicator-session/header-action-state-dict
Merge into: lp:indicator-session/13.10
Diff against target: 145 lines (+60/-28)
2 files modified
src/service.c (+30/-14)
tests/test-service.cc (+30/-14)
To merge this branch: bzr merge lp:~charlesk/indicator-session/header-action-state-dict
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Mathieu Trudel-Lapierre Approve
Review via email: mp+179291@code.launchpad.net

Description of the change

use an a{sv}, rather than the obsoleted (sssb), for the root action's state.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Approve.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

Retrying the landing.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

Conflicts.

review: Needs Fixing
410. By Charles Kerr

sync with trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ted Gould (ted) :
review: Approve

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 2013-08-22 17:04:31 +0000
+++ src/service.c 2013-08-23 17:42:28 +0000
@@ -143,29 +143,28 @@
143****143****
144***/144***/
145145
146static void146static GVariant *
147update_header_action (IndicatorSessionService * self)147action_state_for_header (IndicatorSessionService * self)
148{148{
149 gchar * a11y;149 const priv_t * const p = self->priv;
150 gboolean need_attn;150 gboolean need_attn;
151 GIcon * icon;
151 gboolean show_name;152 gboolean show_name;
152 GVariant * variant;
153 const gchar * real_name;153 const gchar * real_name;
154 const gchar * label;154 const gchar * label;
155 const gchar * iconstr;155 gchar * a11y;
156 const priv_t * const p = self->priv;156 GVariantBuilder b;
157157 GVariant * state;
158 g_return_if_fail (p->header_action != NULL);
159158
160 if (indicator_session_actions_has_online_account_error (p->backend_actions))159 if (indicator_session_actions_has_online_account_error (p->backend_actions))
161 {160 {
162 need_attn = TRUE;161 need_attn = TRUE;
163 iconstr = ICON_ALERT;162 icon = g_themed_icon_new (ICON_ALERT);
164 }163 }
165 else164 else
166 {165 {
167 need_attn = FALSE;166 need_attn = FALSE;
168 iconstr = ICON_DEFAULT;167 icon = g_themed_icon_new (ICON_DEFAULT);
169 }168 }
170169
171 show_name = g_settings_get_boolean (p->indicator_settings,170 show_name = g_settings_get_boolean (p->indicator_settings,
@@ -194,9 +193,26 @@
194 a11y = g_strdup (_("System"));193 a11y = g_strdup (_("System"));
195 }194 }
196195
197 variant = g_variant_new ("(sssb)", label, iconstr, a11y, TRUE);196 /* build the state */
198 g_simple_action_set_state (p->header_action, variant);197 g_variant_builder_init (&b, G_VARIANT_TYPE("a{sv}"));
198 g_variant_builder_add (&b, "{sv}", "accessible-desc", g_variant_new_string (a11y));
199 g_variant_builder_add (&b, "{sv}", "icon", g_icon_serialize (icon));
200 if (label && *label)
201 g_variant_builder_add (&b, "{sv}", "label", g_variant_new_string (label));
202 g_variant_builder_add (&b, "{sv}", "visible", g_variant_new_boolean (TRUE));
203 state = g_variant_builder_end (&b);
204
205 /* cleanup */
199 g_free (a11y);206 g_free (a11y);
207 g_object_unref (G_OBJECT (icon));
208
209 return state;
210}
211
212static void
213update_header_action (IndicatorSessionService * self)
214{
215 g_simple_action_set_state (self->priv->header_action, action_state_for_header (self));
200}216}
201217
202/***218/***
@@ -763,8 +779,8 @@
763 p->user_switcher_action = a;779 p->user_switcher_action = a;
764780
765 /* add the header action */781 /* add the header action */
766 v = g_variant_new ("(sssb)", "label", ICON_DEFAULT, "a11y", TRUE);782 a = g_simple_action_new_stateful ("_header", NULL,
767 a = g_simple_action_new_stateful ("_header", NULL, v);783 action_state_for_header (self));
768 g_action_map_add_action (G_ACTION_MAP (p->actions), G_ACTION(a));784 g_action_map_add_action (G_ACTION_MAP (p->actions), G_ACTION(a));
769 p->header_action = a;785 p->header_action = a;
770786
771787
=== modified file 'tests/test-service.cc'
--- tests/test-service.cc 2013-07-16 19:29:35 +0000
+++ tests/test-service.cc 2013-08-23 17:42:28 +0000
@@ -318,28 +318,44 @@
318318
319 void check_header (const char * expected_label, const char * expected_icon, const char * expected_a11y)319 void check_header (const char * expected_label, const char * expected_icon, const char * expected_a11y)
320 {320 {
321 GVariant * variant;321 GVariant * state = g_action_group_get_action_state (G_ACTION_GROUP(action_group), "_header");
322 const gchar * label = NULL;322 ASSERT_TRUE (state != NULL);
323 const gchar * icon = NULL;323 ASSERT_TRUE (g_variant_is_of_type (state, G_VARIANT_TYPE ("a{sv}")));
324 const gchar * a11y = NULL;
325 gboolean visible;
326
327 variant = g_action_group_get_action_state (G_ACTION_GROUP(action_group), "_header");
328 g_variant_get (variant, "(&s&s&sb)", &label, &icon, &a11y, &visible);
329324
330 if (expected_label != NULL)325 if (expected_label != NULL)
331 ASSERT_STREQ (expected_label, label);326 {
327 GVariant * v = g_variant_lookup_value (state, "label", G_VARIANT_TYPE_STRING);
328 if (!v) // if no label in the state, expected_label must be an empty string
329 ASSERT_FALSE (*expected_label);
330 else
331 ASSERT_STREQ (expected_label, g_variant_get_string (v, NULL));
332 }
333
334 if (expected_a11y != NULL)
335 {
336 GVariant * v = g_variant_lookup_value (state, "accessible-desc", G_VARIANT_TYPE_STRING);
337 ASSERT_TRUE (v != NULL);
338 ASSERT_STREQ (expected_a11y, g_variant_get_string (v, NULL));
339 g_variant_unref (v);
340 }
332341
333 if (expected_icon != NULL)342 if (expected_icon != NULL)
334 ASSERT_STREQ (expected_icon, icon);343 {
335344 GVariant * v = g_variant_lookup_value (state, "icon", NULL);
336 if (expected_a11y != NULL)345 GIcon * expected = g_themed_icon_new (expected_icon);
337 ASSERT_STREQ (expected_a11y, a11y);346 GIcon * actual = g_icon_deserialize (v);
347 ASSERT_TRUE (g_icon_equal (expected, actual));
348 g_object_unref (actual);
349 g_object_unref (expected);
350 g_variant_unref (v);
351 }
338352
339 // the session menu is always visible...353 // the session menu is always visible...
354 gboolean visible = false;
355 g_variant_lookup (state, "visible", "b", &visible);
340 ASSERT_TRUE (visible);356 ASSERT_TRUE (visible);
341357
342 g_variant_unref (variant);358 g_variant_unref (state);
343 }359 }
344360
345 void check_label (const char * expected_label, GMenuModel * model, int pos)361 void check_label (const char * expected_label, GMenuModel * model, int pos)

Subscribers

People subscribed via source and target branches