[glib/wip/actions: 4/11] action exporter: Pass platform_data to GApplication



commit 1dbcdba17e81161460e5c455550281003c89f84b
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Jun 30 09:40:48 2011 +0100

    action exporter: Pass platform_data to GApplication
    
    If the exporter GActionGroup happens to be a GApplication then use its
    before_emit and after_emit hooks to handle the platform_data.

 gio/gactiongroupexporter.c |   33 +++++++++++++++++++++++++++++++--
 1 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/gio/gactiongroupexporter.c b/gio/gactiongroupexporter.c
index 0cccc00..8f613b8 100644
--- a/gio/gactiongroupexporter.c
+++ b/gio/gactiongroupexporter.c
@@ -28,6 +28,7 @@
 #include "gdbusintrospection.h"
 #include "gdbusconnection.h"
 #include "gactiongroup.h"
+#include "gapplication.h"
 #include "gdbuserror.h"
 
 /**
@@ -334,6 +335,24 @@ g_action_group_exporter_action_enabled_changed (GActionGroup *action_group,
 }
 
 static void
+g_action_group_exporter_pre_emit (GActionGroupExporter *exporter,
+                                  GVariant             *platform_data)
+{
+  if (G_IS_APPLICATION (exporter->action_group))
+    G_APPLICATION_GET_CLASS (exporter->action_group)
+      ->before_emit (G_APPLICATION (exporter->action_group), platform_data);
+}
+
+static void
+g_action_group_exporter_post_emit (GActionGroupExporter *exporter,
+                                   GVariant             *platform_data)
+{
+  if (G_IS_APPLICATION (exporter->action_group))
+    G_APPLICATION_GET_CLASS (exporter->action_group)
+      ->after_emit (G_APPLICATION (exporter->action_group), platform_data);
+}
+
+static void
 org_gtk_Actions_method_call (GDBusConnection       *connection,
                              const gchar           *sender,
                              const gchar           *object_path,
@@ -386,25 +405,35 @@ org_gtk_Actions_method_call (GDBusConnection       *connection,
   else if (g_str_equal (method_name, "Activate"))
     {
       GVariant *parameter = NULL;
+      GVariant *platform_data;
       GVariantIter *iter;
       const gchar *name;
 
-      g_variant_get (parameters, "(&sav)", &name, &iter);
+      g_variant_get (parameters, "(&sav a{sv})", &name, &iter, &platform_data);
       g_variant_iter_next (iter, "v", &parameter);
       g_variant_iter_free (iter);
 
+      g_action_group_exporter_pre_emit (exporter, platform_data);
       g_action_group_activate_action (exporter->action_group, name, parameter);
+      g_action_group_exporter_post_emit (exporter, platform_data);
+
       if (parameter)
         g_variant_unref (parameter);
+
+      g_variant_unref (platform_data);
     }
 
   else if (g_str_equal (method_name, "SetState"))
     {
+      GVariant *platform_data;
       const gchar *name;
       GVariant *state;
 
-      g_variant_get (parameters, "(&sv)", &name, &state);
+      g_variant_get (parameters, "(&sv a{sv})", &name, &state, &platform_data);
+      g_action_group_exporter_pre_emit (exporter, platform_data);
       g_action_group_change_action_state (exporter->action_group, name, state);
+      g_action_group_exporter_post_emit (exporter, platform_data);
+      g_variant_unref (platform_data);
       g_variant_unref (state);
     }
 



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