[glib/wip/gapplication] Use some #defines, clean up docs a bit, add appid to object path



commit 3d3acd241df5c5ef06b1df44d12182a63084b020
Author: Colin Walters <walters verbum org>
Date:   Thu May 27 17:44:00 2010 -0400

    Use some #defines, clean up docs a bit, add appid to object path

 gio/gapplication.c     |    8 +++-----
 gio/gunixapplication.c |   26 +++++++++++++++++++-------
 2 files changed, 22 insertions(+), 12 deletions(-)
---
diff --git a/gio/gapplication.c b/gio/gapplication.c
index b29d4e1..2713dd2 100644
--- a/gio/gapplication.c
+++ b/gio/gapplication.c
@@ -742,17 +742,15 @@ g_application_class_init (GApplicationClass *klass)
    /**
    * GApplication:appid:
    *
-   * On Freedesktop platforms, this is a DBus name that will be acquired on the
-   * session bus.
+   * The unique identifier for this application.  See the documentation for
+   * #GApplication for more information about this property.
    *
-   * @TODO on windows, have this be the guid?
-   * @TODO MacOS X
    */
   g_object_class_install_property (gobject_class,
                                    PROP_APPID,
                                    g_param_spec_string ("appid",
                                                         P_("Application ID"),
-                                                        P_("Platform-specific identifier for this application"),
+                                                        P_("Identifier for this application"),
                                                         NULL,
                                                         G_PARAM_READWRITE |
                                                         G_PARAM_CONSTRUCT_ONLY |
diff --git a/gio/gunixapplication.c b/gio/gunixapplication.c
index 14b6171..49eadc0 100644
--- a/gio/gunixapplication.c
+++ b/gio/gunixapplication.c
@@ -29,6 +29,9 @@
 #include "gdbusintrospection.h"
 #include "gdbusmethodinvocation.h"
 
+#define G_APPLICATION_PATH "/org/gtk/Application"
+#define G_APPLICATION_IFACE "org.gtk.Application"
+
 static void
 application_dbus_method_call (GDBusConnection       *connection,
                               const gchar           *sender,
@@ -88,7 +91,7 @@ application_dbus_method_call (GDBusConnection       *connection,
       if (!action)
         {
           char *errmsg  = g_strdup_printf ("Invalid action: %s", action_name);
-          g_dbus_method_invocation_return_dbus_error (invocation, "org.gtk.Application.InvalidAction", errmsg);
+          g_dbus_method_invocation_return_dbus_error (invocation, G_APPLICATION_IFACE ".InvalidAction", errmsg);
           g_free (errmsg);
           return;
         }
@@ -204,7 +207,7 @@ static const GDBusSignalInfo * const application_dbus_signal_info_p[] = {
 static const GDBusInterfaceInfo application_dbus_interface_info =
 {
   -1,
-  "org.gtk.Application",
+  G_APPLICATION_IFACE,
   (GDBusMethodInfo **) application_dbus_method_info_p,
   (GDBusSignalInfo **) application_dbus_signal_info_p,
   NULL,
@@ -223,6 +226,7 @@ _g_application_platform_init (GApplication *app)
   GApplicationPrivate *priv = app->priv;
   GError *error = NULL;
   guint registration_id;
+  char *appid_path, *iter;
   
   priv->session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
   if (priv->session_bus == NULL)
@@ -237,12 +241,20 @@ _g_application_platform_init (GApplication *app)
 
       return;
     }
+
+  appid_path = g_strconcat (G_APPLICATION_PATH, app->priv->appid, NULL);
+  for (iter = appid_path + strlen (G_APPLICATION_PATH); *iter; iter++)
+    {
+      if (*iter == '.')
+	*iter = '/';
+    }
     
-  registration_id = g_dbus_connection_register_object (priv->session_bus, "/org/gtk/Application",
+  registration_id = g_dbus_connection_register_object (priv->session_bus, appid_path,
                                                        &application_dbus_interface_info,
                                                        &application_dbus_vtable,
                                                        app, NULL,
                                                        &error);
+  g_free (appid_path);
   if (registration_id == 0)
     g_error ("%s", error->message);
 }
@@ -294,8 +306,8 @@ static void
 _g_application_platform_on_actions_changed (GApplication *app)
 {
   g_dbus_connection_emit_signal (app->priv->session_bus, NULL,
-                                 "/org/gtk/Application",
-                                 "org.gtk.Application",
+                                 G_APPLICATION_PATH,
+                                 G_APPLICATION_IFACE,
                                  "ActionsChanged", NULL, NULL);
 }
 
@@ -307,8 +319,8 @@ _g_application_platform_remote_invoke_action (GApplication  *app,
   GVariant *result;
   result = g_dbus_connection_call_sync (app->priv->session_bus,
                                         app->priv->appid,
-                                        "/org/gtk/Application",
-                                        "org.gtk.Application",
+                                        G_APPLICATION_PATH,
+                                        G_APPLICATION_IFACE,
                                         "InvokeAction",
                                         g_variant_new ("(su)",
                                                        action,



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