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 on 2013-08-23

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
1=== modified file 'src/service.c'
2--- src/service.c 2013-08-22 17:04:31 +0000
3+++ src/service.c 2013-08-23 17:42:28 +0000
4@@ -143,29 +143,28 @@
5 ****
6 ***/
7
8-static void
9-update_header_action (IndicatorSessionService * self)
10+static GVariant *
11+action_state_for_header (IndicatorSessionService * self)
12 {
13- gchar * a11y;
14+ const priv_t * const p = self->priv;
15 gboolean need_attn;
16+ GIcon * icon;
17 gboolean show_name;
18- GVariant * variant;
19 const gchar * real_name;
20 const gchar * label;
21- const gchar * iconstr;
22- const priv_t * const p = self->priv;
23-
24- g_return_if_fail (p->header_action != NULL);
25+ gchar * a11y;
26+ GVariantBuilder b;
27+ GVariant * state;
28
29 if (indicator_session_actions_has_online_account_error (p->backend_actions))
30 {
31 need_attn = TRUE;
32- iconstr = ICON_ALERT;
33+ icon = g_themed_icon_new (ICON_ALERT);
34 }
35 else
36 {
37 need_attn = FALSE;
38- iconstr = ICON_DEFAULT;
39+ icon = g_themed_icon_new (ICON_DEFAULT);
40 }
41
42 show_name = g_settings_get_boolean (p->indicator_settings,
43@@ -194,9 +193,26 @@
44 a11y = g_strdup (_("System"));
45 }
46
47- variant = g_variant_new ("(sssb)", label, iconstr, a11y, TRUE);
48- g_simple_action_set_state (p->header_action, variant);
49+ /* build the state */
50+ g_variant_builder_init (&b, G_VARIANT_TYPE("a{sv}"));
51+ g_variant_builder_add (&b, "{sv}", "accessible-desc", g_variant_new_string (a11y));
52+ g_variant_builder_add (&b, "{sv}", "icon", g_icon_serialize (icon));
53+ if (label && *label)
54+ g_variant_builder_add (&b, "{sv}", "label", g_variant_new_string (label));
55+ g_variant_builder_add (&b, "{sv}", "visible", g_variant_new_boolean (TRUE));
56+ state = g_variant_builder_end (&b);
57+
58+ /* cleanup */
59 g_free (a11y);
60+ g_object_unref (G_OBJECT (icon));
61+
62+ return state;
63+}
64+
65+static void
66+update_header_action (IndicatorSessionService * self)
67+{
68+ g_simple_action_set_state (self->priv->header_action, action_state_for_header (self));
69 }
70
71 /***
72@@ -763,8 +779,8 @@
73 p->user_switcher_action = a;
74
75 /* add the header action */
76- v = g_variant_new ("(sssb)", "label", ICON_DEFAULT, "a11y", TRUE);
77- a = g_simple_action_new_stateful ("_header", NULL, v);
78+ a = g_simple_action_new_stateful ("_header", NULL,
79+ action_state_for_header (self));
80 g_action_map_add_action (G_ACTION_MAP (p->actions), G_ACTION(a));
81 p->header_action = a;
82
83
84=== modified file 'tests/test-service.cc'
85--- tests/test-service.cc 2013-07-16 19:29:35 +0000
86+++ tests/test-service.cc 2013-08-23 17:42:28 +0000
87@@ -318,28 +318,44 @@
88
89 void check_header (const char * expected_label, const char * expected_icon, const char * expected_a11y)
90 {
91- GVariant * variant;
92- const gchar * label = NULL;
93- const gchar * icon = NULL;
94- const gchar * a11y = NULL;
95- gboolean visible;
96-
97- variant = g_action_group_get_action_state (G_ACTION_GROUP(action_group), "_header");
98- g_variant_get (variant, "(&s&s&sb)", &label, &icon, &a11y, &visible);
99+ GVariant * state = g_action_group_get_action_state (G_ACTION_GROUP(action_group), "_header");
100+ ASSERT_TRUE (state != NULL);
101+ ASSERT_TRUE (g_variant_is_of_type (state, G_VARIANT_TYPE ("a{sv}")));
102
103 if (expected_label != NULL)
104- ASSERT_STREQ (expected_label, label);
105+ {
106+ GVariant * v = g_variant_lookup_value (state, "label", G_VARIANT_TYPE_STRING);
107+ if (!v) // if no label in the state, expected_label must be an empty string
108+ ASSERT_FALSE (*expected_label);
109+ else
110+ ASSERT_STREQ (expected_label, g_variant_get_string (v, NULL));
111+ }
112+
113+ if (expected_a11y != NULL)
114+ {
115+ GVariant * v = g_variant_lookup_value (state, "accessible-desc", G_VARIANT_TYPE_STRING);
116+ ASSERT_TRUE (v != NULL);
117+ ASSERT_STREQ (expected_a11y, g_variant_get_string (v, NULL));
118+ g_variant_unref (v);
119+ }
120
121 if (expected_icon != NULL)
122- ASSERT_STREQ (expected_icon, icon);
123-
124- if (expected_a11y != NULL)
125- ASSERT_STREQ (expected_a11y, a11y);
126+ {
127+ GVariant * v = g_variant_lookup_value (state, "icon", NULL);
128+ GIcon * expected = g_themed_icon_new (expected_icon);
129+ GIcon * actual = g_icon_deserialize (v);
130+ ASSERT_TRUE (g_icon_equal (expected, actual));
131+ g_object_unref (actual);
132+ g_object_unref (expected);
133+ g_variant_unref (v);
134+ }
135
136 // the session menu is always visible...
137+ gboolean visible = false;
138+ g_variant_lookup (state, "visible", "b", &visible);
139 ASSERT_TRUE (visible);
140
141- g_variant_unref (variant);
142+ g_variant_unref (state);
143 }
144
145 void check_label (const char * expected_label, GMenuModel * model, int pos)

Subscribers

People subscribed via source and target branches