aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2013-03-13 22:24:42 +0000
committerTarmac <Unknown>2013-03-13 22:24:42 +0000
commitdaf0dc90ac1f87ce02debd1cba9b1f084decee12 (patch)
treeeeb44bb407a76e37ebede196919156c735613b60
parent208d1ba79fd677e4b42f88a6f7d1f9c66ac09929 (diff)
parent610b2cc6eff717d18a30d0dbec2a1382e61ad7a1 (diff)
downloadlibayatana-indicator-daf0dc90ac1f87ce02debd1cba9b1f084decee12.tar.gz
libayatana-indicator-daf0dc90ac1f87ce02debd1cba9b1f084decee12.tar.bz2
libayatana-indicator-daf0dc90ac1f87ce02debd1cba9b1f084decee12.zip
indicator-ng: allow a dictionary as the root action's state
Hopefully, this is more straightforward to use than (sssb). It's also extensible. (sssb) is still supported for backwards compatibility, but I wouldn't recommend using it anymore. Approved by Charles Kerr, PS Jenkins bot.
-rw-r--r--libindicator/indicator-ng.c31
-rw-r--r--tests/indicator-test-service.c4
2 files changed, 23 insertions, 12 deletions
diff --git a/libindicator/indicator-ng.c b/libindicator/indicator-ng.c
index f2b957b..1e95785 100644
--- a/libindicator/indicator-ng.c
+++ b/libindicator/indicator-ng.c
@@ -236,6 +236,10 @@ static void
indicator_ng_update_entry (IndicatorNg *self)
{
GVariant *state;
+ const gchar *label = NULL;
+ const gchar *iconstr = NULL;
+ const gchar *accessible_desc = NULL;
+ gboolean visible = TRUE;
g_return_if_fail (self->menu != NULL);
g_return_if_fail (self->actions != NULL);
@@ -250,20 +254,25 @@ indicator_ng_update_entry (IndicatorNg *self)
state = g_action_group_get_action_state (self->actions, self->header_action);
if (state && g_variant_is_of_type (state, G_VARIANT_TYPE ("(sssb)")))
{
- const gchar *label;
- const gchar *iconstr;
- const gchar *accessible_desc;
- gboolean visible;
-
g_variant_get (state, "(&s&s&sb)", &label, &iconstr, &accessible_desc, &visible);
-
- indicator_ng_set_label (self, label);
- indicator_ng_set_icon_from_string (self, iconstr);
- indicator_ng_set_accessible_desc (self, accessible_desc);
- indicator_object_set_visible (INDICATOR_OBJECT (self), visible);
+ }
+ else if (state && g_variant_is_of_type (state, G_VARIANT_TYPE ("a{sv}")))
+ {
+ g_variant_lookup (state, "label", "&s", &label);
+ g_variant_lookup (state, "icon", "&s", &iconstr);
+ g_variant_lookup (state, "accessible-desc", "&s", &accessible_desc);
+ g_variant_lookup (state, "visible", "b", &visible);
}
else
- g_warning ("the action of the indicator menu item must have state with type (sssb)");
+ g_warning ("the action of the indicator menu item must have state with type (sssb) or a{sv}");
+
+ if (label)
+ indicator_ng_set_label (self, label);
+ if (iconstr)
+ indicator_ng_set_icon_from_string (self, iconstr);
+ if (accessible_desc)
+ indicator_ng_set_accessible_desc (self, accessible_desc);
+ indicator_object_set_visible (INDICATOR_OBJECT (self), visible);
if (state)
g_variant_unref (state);
diff --git a/tests/indicator-test-service.c b/tests/indicator-test-service.c
index 0393677..a40945f 100644
--- a/tests/indicator-test-service.c
+++ b/tests/indicator-test-service.c
@@ -70,7 +70,9 @@ main (int argc, char **argv)
GMenuItem *item;
GMenu *submenu;
GActionEntry entries[] = {
- { "_header", NULL, NULL, "('Test', 'indicator-test', 'Test indicator', true)", NULL },
+ { "_header", NULL, NULL, "{'label': <'Test'>,"
+ " 'icon': <'indicator-test'>,"
+ " 'accessible-desc': <'Test indicator'> }", NULL },
{ "show", activate_show, NULL, NULL, NULL }
};
GMainLoop *loop;