[gnome-terminal] server: Use application IDs instead of bus names



commit abc15a8b1da35910c97f4b8542600f2e81bbbc28
Author: Christian Persch <chpe gnome org>
Date:   Sun May 27 14:42:02 2012 +0200

    server: Use application IDs instead of bus names
    
    Now that we use GApplication without hacks, change --bus-name to
    --app-id.

 src/client.c           |   22 +++++++++++-----------
 src/server.c           |   18 +++++++++---------
 src/terminal-app.c     |    4 ++--
 src/terminal-app.h     |    2 +-
 src/terminal-defines.h |    2 +-
 src/terminal-options.c |   16 ++++++++--------
 src/terminal-options.h |    2 +-
 src/terminal.c         |   10 +++++-----
 8 files changed, 38 insertions(+), 38 deletions(-)
---
diff --git a/src/client.c b/src/client.c
index aeea712..9b1993b 100644
--- a/src/client.c
+++ b/src/client.c
@@ -158,7 +158,7 @@ modify_argv0_for_command (gint *argc, gchar **argv[], const gchar *command)
 
 typedef struct
 {
-  char       *server_bus_name;
+  char       *server_app_id;
 
   /* Window options */
   char       *startup_id;
@@ -226,7 +226,7 @@ option_zoom_cb (const gchar *option_name,
 }
 
 static gboolean
-option_bus_name_cb (const gchar *option_name,
+option_app_id_cb (const gchar *option_name,
                     const gchar *value,
                     gpointer     user_data,
                     GError     **error)
@@ -239,8 +239,8 @@ option_bus_name_cb (const gchar *option_name,
     return FALSE;
   }
 
-  g_free (data->server_bus_name);
-  data->server_bus_name = g_strdup (value);
+  g_free (data->server_app_id);
+  data->server_app_id = g_strdup (value);
 
   return TRUE;
 }
@@ -331,7 +331,7 @@ get_goption_context (OptionData *data)
   };
 
   const GOptionEntry server_goptions[] = {
-    { "bus-name", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_CALLBACK, option_bus_name_cb, N_("Server D-Bus name"), N_("NAME") },
+    { "app-id", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_CALLBACK, option_app_id_cb, "Server application ID", "ID" },
     { NULL }
   };
 
@@ -450,7 +450,7 @@ option_data_free (OptionData *data)
   if (data == NULL)
     return;
 
-  g_free (data->server_bus_name);
+  g_free (data->server_app_id);
   g_free (data->startup_id);
   g_free (data->geometry);
   g_free (data->role);
@@ -627,15 +627,15 @@ handle_open (int *argc,
   factory = terminal_factory_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
                                                      G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
                                                      G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
-                                                     data->server_bus_name ? data->server_bus_name 
-                                                                           : TERMINAL_UNIQUE_NAME,
+                                                     data->server_app_id ? data->server_app_id
+                                                                         : TERMINAL_APPLICATION_ID,
                                                      TERMINAL_FACTORY_OBJECT_PATH,
                                                      NULL /* cancellable */,
                                                      &error);
   if (factory == NULL) {
     g_dbus_error_strip_remote_error (error);
     _printerr ("Error constructing proxy for %s:%s: %s\n", 
-                TERMINAL_UNIQUE_NAME, TERMINAL_FACTORY_OBJECT_PATH,
+                TERMINAL_APPLICATION_ID, TERMINAL_FACTORY_OBJECT_PATH,
                 error->message);
     g_error_free (error);
     option_data_free (data);
@@ -660,8 +660,8 @@ handle_open (int *argc,
 
   receiver = terminal_receiver_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
                                                        G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
-                                                       data->server_bus_name ? data->server_bus_name
-                                                                             : TERMINAL_UNIQUE_NAME,
+                                                       data->server_app_id ? data->server_app_id
+                                                                             : TERMINAL_APPLICATION_ID,
                                                        object_path,
                                                        NULL /* cancellable */,
                                                        &error);
diff --git a/src/server.c b/src/server.c
index 95069dd..baf65ec 100644
--- a/src/server.c
+++ b/src/server.c
@@ -37,28 +37,28 @@
 #include "terminal-intl.h"
 #include "terminal-defines.h"
 
-static char *bus_name = NULL;
+static char *app_id = NULL;
 
 static gboolean
-option_bus_name_cb (const gchar *option_name,
+option_app_id_cb (const gchar *option_name,
                     const gchar *value,
                     gpointer     data,
                     GError     **error)
 {
-  if (!g_dbus_is_name (value)) {
+  if (!g_application_id_is_valid (value)) {
     g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
-                 "%s is not a valid D-Bus name", value);
+                 "\"%s\" is not a valid application ID", value);
     return FALSE;
   }
 
-  g_free (bus_name);
-  bus_name = g_strdup (value);
+  g_free (app_id);
+  app_id = g_strdup (value);
 
   return TRUE;
 }
 
 static const GOptionEntry options[] = {
-  { "bus-name", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_CALLBACK, option_bus_name_cb, "Server D-Bus name", "NAME" },
+  { "app-id", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_CALLBACK, option_app_id_cb, "Application ID", "ID" },
   { NULL }
 };
 
@@ -97,8 +97,8 @@ main (int argc, char **argv)
     exit (EXIT_FAILURE);
   }
 
-  app = terminal_app_new (bus_name);
-  g_free (bus_name);
+  app = terminal_app_new (app_id);
+  g_free (app_id);
 
   if (!g_application_register (app, NULL, &error)) {
     g_printerr ("Failed to register application: %s\n", error->message);
diff --git a/src/terminal-app.c b/src/terminal-app.c
index 8a1de38..3d175f9 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -1335,12 +1335,12 @@ terminal_app_class_init (TerminalAppClass *klass)
 /* Public API */
 
 GApplication *
-terminal_app_new (const char *bus_name)
+terminal_app_new (const char *app_id)
 {
   const GApplicationFlags flags = G_APPLICATION_IS_SERVICE;
 
   return g_object_new (TERMINAL_TYPE_APP,
-                       "application-id", bus_name ? bus_name : TERMINAL_UNIQUE_NAME,
+                       "application-id", app_id ? app_id : TERMINAL_APPLICATION_ID,
                        "flags", flags,
                        NULL);
 }
diff --git a/src/terminal-app.h b/src/terminal-app.h
index 95d4dfd..0edb941 100644
--- a/src/terminal-app.h
+++ b/src/terminal-app.h
@@ -48,7 +48,7 @@ typedef struct _TerminalApp TerminalApp;
 
 GType terminal_app_get_type (void);
 
-GApplication *terminal_app_new (const char *bus_name);
+GApplication *terminal_app_new (const char *app_id);
 
 #define terminal_app_get (TerminalApp *) g_application_get_default
 
diff --git a/src/terminal-defines.h b/src/terminal-defines.h
index 0a2551d..d5e315d 100644
--- a/src/terminal-defines.h
+++ b/src/terminal-defines.h
@@ -21,7 +21,7 @@
 
 G_BEGIN_DECLS
 
-#define TERMINAL_UNIQUE_NAME                    "org.gnome.Terminal"
+#define TERMINAL_APPLICATION_ID                 "org.gnome.Terminal"
 
 #define TERMINAL_OBJECT_PATH_PREFIX             "/org/gnome/Terminal"
 #define TERMINAL_OBJECT_INTERFACE_PREFIX        "org.gnome.Terminal"
diff --git a/src/terminal-options.c b/src/terminal-options.c
index ac72e10..b7d3245 100644
--- a/src/terminal-options.c
+++ b/src/terminal-options.c
@@ -224,7 +224,7 @@ option_version_cb (const gchar *option_name,
 }
 
 static gboolean
-option_bus_name_callback (const gchar *option_name,
+option_app_id_callback (const gchar *option_name,
                           const gchar *value,
                           gpointer     data,
                           GError     **error)
@@ -237,8 +237,8 @@ option_bus_name_callback (const gchar *option_name,
     return FALSE;
   }
 
-  g_free (options->server_bus_name);
-  options->server_bus_name = g_strdup (value);
+  g_free (options->server_app_id);
+  options->server_app_id = g_strdup (value);
 
   return TRUE;
 }
@@ -893,7 +893,7 @@ terminal_options_free (TerminalOptions *options)
 
   g_free (options->display_name);
   g_free (options->startup_id);
-  g_free (options->server_bus_name);
+  g_free (options->server_app_id);
 
   g_free (options->sm_client_id);
   g_free (options->sm_config_prefix);
@@ -906,13 +906,13 @@ get_goption_context (TerminalOptions *options)
 {
   const GOptionEntry global_unique_goptions[] = {
     {
-      "bus-name",
+      "app-id",
       0,
       G_OPTION_FLAG_HIDDEN,
       G_OPTION_ARG_CALLBACK,
-      option_bus_name_callback,
-      N_("Server D-Bus name"),
-      N_("NAME")
+      option_app_id_callback,
+      "Server application ID",
+      "ID"
     },
     {
       "disable-factory",
diff --git a/src/terminal-options.h b/src/terminal-options.h
index 08585b0..a4964dc 100644
--- a/src/terminal-options.h
+++ b/src/terminal-options.h
@@ -57,7 +57,7 @@ enum
 
 typedef struct
 {
-  char    *server_bus_name;
+  char    *server_app_id;
   gboolean remote_arguments;
   char    *startup_id;
   char    *display_name;
diff --git a/src/terminal.c b/src/terminal.c
index c6f69e6..ffb7c8e 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -148,8 +148,8 @@ handle_options (TerminalFactory *factory,
           receiver = terminal_receiver_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
                                                                G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
                                                                G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
-                                                               options->server_bus_name ? options->server_bus_name 
-                                                                                        : TERMINAL_UNIQUE_NAME,
+                                                               options->server_app_id ? options->server_app_id
+                                                                                      : TERMINAL_APPLICATION_ID,
                                                                object_path,
                                                                NULL /* cancellable */,
                                                                &err);
@@ -246,15 +246,15 @@ main (int argc, char **argv)
   factory = terminal_factory_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
                                                      G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
                                                      G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
-                                                     options->server_bus_name ? options->server_bus_name 
-                                                                              : TERMINAL_UNIQUE_NAME,
+                                                     options->server_app_id ? options->server_app_id 
+                                                                            : TERMINAL_APPLICATION_ID,
                                                      TERMINAL_FACTORY_OBJECT_PATH,
                                                      NULL /* cancellable */,
                                                      &error);
   if (factory == NULL) {
     g_dbus_error_strip_remote_error (error);
     g_printerr ("Error constructing proxy for %s:%s: %s\n", 
-                options->server_bus_name ? options->server_bus_name : TERMINAL_UNIQUE_NAME,
+                options->server_app_id ? options->server_app_id : TERMINAL_APPLICATION_ID,
                 TERMINAL_FACTORY_OBJECT_PATH,
                 error->message);
     g_error_free (error);



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