[glib/wip/gapplication] Make ListActions return a{s(sb)}
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/gapplication] Make ListActions return a{s(sb)}
- Date: Fri, 21 May 2010 04:05:32 +0000 (UTC)
commit ef6666b2a23e567b52ee1292844a58161a784a57
Author: Matthias Clasen <mclasen redhat com>
Date: Thu May 20 23:50:53 2010 -0400
Make ListActions return a{s(sb)}
Previously, there was no way for a shell to get the action description
and enabledness status. Now ListActions returns all this information.
gio/gunixapplication.c | 21 ++++++++++-----------
gio/tests/testapps.c | 4 ++--
2 files changed, 12 insertions(+), 13 deletions(-)
---
diff --git a/gio/gunixapplication.c b/gio/gunixapplication.c
index 095992a..7b56949 100644
--- a/gio/gunixapplication.c
+++ b/gio/gunixapplication.c
@@ -55,26 +55,25 @@ application_dbus_method_call (GDBusConnection *connection,
}
else if (strcmp (method_name, "ListActions") == 0)
{
- char **actions;
GHashTableIter iter;
- gpointer key, value;
- int i;
+ GApplicationAction *value;
+ GVariantBuilder builder;
GVariant *return_args;
GVariant *result;
- actions = g_new (char *, g_hash_table_size (app->priv->actions) + 1);
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
g_hash_table_iter_init (&iter, app->priv->actions);
- i = 0;
- while (g_hash_table_iter_next (&iter, &key, &value))
- actions[i++] = key;
- actions[i] = NULL;
+ while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&value))
+ g_variant_builder_add (&builder, "{s(sb)}",
+ value->name,
+ value->description,
+ value->enabled);
- result = g_variant_new_strv ((const char *const*)actions, -1);
+ result = g_variant_builder_end (&builder);
return_args = g_variant_new_tuple (&result, 1);
g_dbus_method_invocation_return_value (invocation, return_args);
g_variant_unref (return_args);
g_variant_unref (result);
- g_free (actions);
}
else if (strcmp (method_name, "InvokeAction") == 0)
{
@@ -120,7 +119,7 @@ static const GDBusArgInfo application_list_actions_out_args[] =
{
-1,
"actions",
- "as",
+ "a{s(sb)}",
NULL
}
};
diff --git a/gio/tests/testapps.c b/gio/tests/testapps.c
index 30935be..4ec31ee 100644
--- a/gio/tests/testapps.c
+++ b/gio/tests/testapps.c
@@ -244,9 +244,9 @@ list_actions (void)
NULL);
strv = g_new0 (gchar *, 32);
- g_variant_get (res, "(as)", &iter);
+ g_variant_get (res, "(a{s(sb)})", &iter);
i = 0;
- while (g_variant_iter_loop (iter, "s", &str))
+ while (g_variant_iter_loop (iter, "{s(sb)}", &str, NULL, NULL))
{
strv[i] = g_strdup (str);
i++;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]