[glib/wip/menus: 7/61] GActionGroup exporter: include state in Describe



commit df656d611e4a2ff934165f586a810281d0ee7c48
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Jun 30 10:05:46 2011 +0100

    GActionGroup exporter: include state in Describe
    
    Not just the state type.

 gio/gactiongroupexporter.c |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/gio/gactiongroupexporter.c b/gio/gactiongroupexporter.c
index 8f613b8..d5828bb 100644
--- a/gio/gactiongroupexporter.c
+++ b/gio/gactiongroupexporter.c
@@ -48,8 +48,9 @@ g_action_group_describe_action (GActionGroup *action_group,
   const GVariantType *type;
   GVariantBuilder builder;
   gboolean enabled;
+  GVariant *state;
 
-  g_variant_builder_init (&builder, G_VARIANT_TYPE ("(bgg)"));
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("(bgav)"));
 
   enabled = g_action_group_get_action_enabled (action_group, name);
   g_variant_builder_add (&builder, "b", enabled);
@@ -63,14 +64,13 @@ g_action_group_describe_action (GActionGroup *action_group,
   else
     g_variant_builder_add (&builder, "g", "");
 
-  if ((type = g_action_group_get_action_state_type (action_group, name)))
+  g_variant_builder_open (&builder, G_VARIANT_TYPE ("av"));
+  if ((state = g_action_group_get_action_state (action_group, name)))
     {
-      gchar *str = g_variant_type_dup_string (type);
-      g_variant_builder_add (&builder, "g", str);
-      g_free (str);
+      g_variant_builder_add (&builder, "v", state);
+      g_variant_unref (state);
     }
-  else
-    g_variant_builder_add (&builder, "g", "");
+  g_variant_builder_close (&builder);
 
   return g_variant_builder_end (&builder);
 }
@@ -89,10 +89,10 @@ const char org_gtk_Actions_xml[] =
   "    </method>"
   "    <method name='Describe'>"
   "      <arg type='s' name='action_name' direction='in'>"
-  "      <arg type='(bgg)' name='description' direction='out'>"
+  "      <arg type='(bgav)' name='description' direction='out'>"
   "    </method>"
   "    <method name='DescribeAll'>"
-  "      <arg type='a{s(bgg)}' name='descriptions' direction='out'/>"
+  "      <arg type='a{s(bgav)}' name='descriptions' direction='out'/>"
   "    </method>"
   "    <method name='Activate'>"
   "      <arg type='s' name='action_name' direction='in'/>"
@@ -108,7 +108,7 @@ const char org_gtk_Actions_xml[] =
   "      <arg type='as' name='removals'/>"
   "      <arg type='a{sb}' name='enable_changes'/>"
   "      <arg type='a{sv}' name='state_changes'/>"
-  "      <arg type='a{s(bgg)}' name='additions'/>"
+  "      <arg type='a{s(bgav)}' name='additions'/>"
   "    </signal>"
   "  </interface>"
   "</node>";
@@ -147,7 +147,7 @@ g_action_group_exporter_dispatch_events (gpointer user_data)
   g_variant_builder_init (&removes, G_VARIANT_TYPE_STRING_ARRAY);
   g_variant_builder_init (&enabled_changes, G_VARIANT_TYPE ("a{sb}"));
   g_variant_builder_init (&state_changes, G_VARIANT_TYPE ("a{sv}"));
-  g_variant_builder_init (&adds, G_VARIANT_TYPE ("a{s(bgg)}"));
+  g_variant_builder_init (&adds, G_VARIANT_TYPE ("a{s(bgav)}"));
 
   g_hash_table_iter_init (&iter, exporter->pending_changes);
   while (g_hash_table_iter_next (&iter, &key, &value))
@@ -187,13 +187,13 @@ g_action_group_exporter_dispatch_events (gpointer user_data)
           GVariant *description;
 
           description = g_action_group_describe_action (exporter->action_group, name);
-          g_variant_builder_add (&state_changes, "{s@(bgg)}", name, description);
+          g_variant_builder_add (&state_changes, "{s@(bgav)}", name, description);
         }
     }
 
   g_dbus_connection_emit_signal (exporter->connection, NULL, exporter->object_path,
                                  "org.gtk.Actions", "Changed",
-                                 g_variant_new ("(asa{sb}a{sv}a{s(bgg)})",
+                                 g_variant_new ("(asa{sb}a{sv}a{s(bgav)})",
                                                 &removes, &enabled_changes,
                                                 &state_changes, &adds),
                                  NULL);
@@ -389,16 +389,16 @@ org_gtk_Actions_method_call (GDBusConnection       *connection,
       gint i;
 
       list = g_action_group_list_actions (exporter->action_group);
-      g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{s(bgg)}"));
+      g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{s(bgav)}"));
       for (i = 0; list[i]; i++)
         {
           const gchar *name = list[i];
           GVariant *description;
 
           description = g_action_group_describe_action (exporter->action_group, name);
-          g_variant_builder_add (&builder, "{s@(bgg)}", name, description);
+          g_variant_builder_add (&builder, "{s@(bgav)}", name, description);
         }
-      result = g_variant_new ("(a{s(bgg)})", &builder);
+      result = g_variant_new ("(a{s(bgav)})", &builder);
       g_strfreev (list);
     }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]