[glib/wip/gapplication] Move receive activation handling into plugin



commit 12c9c7d7fb49ee397b3a930fc25076698eb067fc
Author: Colin Walters <walters verbum org>
Date:   Tue Jun 1 15:06:41 2010 -0400

    Move receive activation handling into plugin

 gio/gapplication.c     |   20 +++++++++++---------
 gio/gapplication.h     |   12 ++++++++----
 gio/gunixapplication.c |    8 +++++++-
 3 files changed, 26 insertions(+), 14 deletions(-)
---
diff --git a/gio/gapplication.c b/gio/gapplication.c
index c49ba70..cec3252 100644
--- a/gio/gapplication.c
+++ b/gio/gapplication.c
@@ -97,6 +97,8 @@ struct _GApplicationPrivate
 
   guint actions_changed_id;
 
+  const GApplicationPlugin *plugin;
+
 #ifdef G_OS_UNIX
   char *dbus_path;
   GDBusConnection *session_bus;
@@ -762,6 +764,7 @@ g_application_constructor  (GType                  type,
   const char *appid = NULL;
   gboolean default_quit = TRUE;
   gboolean is_remote;
+  const GApplicationConstructionData *construct_data;
 
   for (i = 0; i < n_construct_properties; i++)
     {
@@ -797,6 +800,10 @@ g_application_constructor  (GType                  type,
   app = G_APPLICATION (object);
   app->priv->is_remote = is_remote;
 
+  construct_data = g_static_private_get (&construction_data);
+  if (construct_data)
+    app->priv->plugin = construct_data->plugin;
+
   if (primary_application == NULL)
     primary_application = app;
   g_hash_table_insert (instances_for_appid, g_strdup (appid), app);
@@ -844,16 +851,11 @@ g_application_class_init (GApplicationClass *klass)
    /**
    * GApplication::activated:
    * @args: Arguments given to non-primary process
-   * @data: Additional platform-specific data
    *
    * This signal is emitted when a non-primary process for a given
    * application is invoked while your application is running; for
    * example, when a file browser launches your program to open a
    * file.  The given arguments are defined to be in UTF-8 encoding.
-   *
-   * There are no predefined contents included with @data; it will
-   * typically be used by #GApplication subclasses which will insert
-   * (for example) window system data.
    */
 
   application_signals[ACTIVATED] =
@@ -862,10 +864,9 @@ g_application_class_init (GApplicationClass *klass)
                   G_SIGNAL_RUN_LAST,
                   G_STRUCT_OFFSET (GApplicationClass, activated),
                   NULL, NULL,
-                  _gio_marshal_VOID__BOXED_BOXED,
-                  G_TYPE_NONE, 2,
-                  G_TYPE_STRV,
-		  G_TYPE_VARIANT);
+                  g_cclosure_marshal_VOID__BOXED,
+                  G_TYPE_NONE, 1,
+                  G_TYPE_STRV);
 
    /**
    * GApplication:appid:
@@ -902,6 +903,7 @@ g_application_class_init (GApplicationClass *klass)
                                                          G_PARAM_CONSTRUCT_ONLY |
                                                          G_PARAM_STATIC_STRINGS));
 
+
   /**
    * GApplication:is-remote:
    *
diff --git a/gio/gapplication.h b/gio/gapplication.h
index 67d269c..b8f6243 100644
--- a/gio/gapplication.h
+++ b/gio/gapplication.h
@@ -85,8 +85,7 @@ struct _GApplicationClass
   gboolean    (* quit)   (GApplication *application,
 			  guint         timestamp);
   void        (* activated)   (GApplication  *application,
-			       const gchar  **arguments,
-			       GVariant      *data);
+			       const gchar  **arguments);
 
   /* vfuncs */
   void        (* run)    (GApplication *application);
@@ -112,8 +111,12 @@ struct _GApplicationClass
  * application exists.  The callback will be invoked in the context of
  * the non-primary process.  This allows environmental data such as
  * windowing system event data to be sent to the primary process.
- * Handlers for this signal should assume @builder has been opened
- * for an "a{sv}" type, and thus only append "sv" elements.
+ * Handlers for this signal should assume @builder has been opened for
+ * an "a{sv}" type, and thus only append "sv" elements.
+ * @receive_activation_data: Invoked when a non-primary process for
+ * this application is invoked.  This callback is invoked in the
+ * context of the primary process, and will be passed environmental
+ * data gathered from the @format_activation_data callback.
  *
  * Since: 2.26
  */
@@ -121,6 +124,7 @@ struct _GApplicationPlugin
 {
   /*< public >*/
   void (*format_activation_data) (GVariantBuilder *builder);
+  void (*receive_activation_data) (GVariant *data);
 
   /*< private >*/
   /* Padding for future expansion */
diff --git a/gio/gunixapplication.c b/gio/gunixapplication.c
index 155f5b2..6c3d865 100644
--- a/gio/gunixapplication.c
+++ b/gio/gunixapplication.c
@@ -105,7 +105,13 @@ application_dbus_method_call (GDBusConnection       *connection,
       char **args;
 
       g_variant_get (parameters, "(^a&s a{sv})", &args, &platform_data);
-      g_signal_emit (app, application_signals[ACTIVATED], 0, args, platform_data);
+
+      if (app->priv->plugin && app->priv->plugin->receive_activation_data)
+	{
+	  app->priv->plugin->receive_activation_data (platform_data);
+	}
+
+      g_signal_emit (app, application_signals[ACTIVATED], 0, args);
       g_free (args);
       g_variant_unref (platform_data);
 



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