[glib/application] Set prgname from argv[0]



commit 7ddfdac3ba30e8631ba36083db25bfe439f2197e
Author: Ryan Lortie <desrt desrt ca>
Date:   Tue Aug 10 23:28:45 2010 -0400

    Set prgname from argv[0]
    
    fix some bugs

 gio/gapplication.c          |   17 ++++++++++++++++-
 gio/gapplicationimpl-dbus.c |    3 +--
 2 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/gio/gapplication.c b/gio/gapplication.c
index ca7364e..948124b 100644
--- a/gio/gapplication.c
+++ b/gio/gapplication.c
@@ -204,7 +204,7 @@ g_application_real_handle_command_line (GApplication  *application,
                 {
                   const gchar *arg;
 
-                  g_variant_get_child (*arguments, i + 1, "&s", &arg);
+                  g_variant_get_child (*arguments, i + 1, "^&ay", &arg);
                   files[i] = g_file_new_for_commandline_arg (arg);
                 }
 
@@ -1198,6 +1198,9 @@ g_application_run (GApplication  *application,
                    int            argc,
                    char         **argv)
 {
+  g_return_val_if_fail (G_IS_APPLICATION (application), 1);
+  g_return_val_if_fail (argc == 0 || argv != NULL, 1);
+
   return g_application_run_with_arguments (application,
     g_variant_new_bytestring_array ((const gchar **) argv, argc));
 }
@@ -1219,9 +1222,21 @@ g_application_run_with_arguments (GApplication *application,
   int status;
 
   g_return_val_if_fail (G_IS_APPLICATION (application), 1);
+  g_return_val_if_fail (G_IS_APPLICATION (application), 1);
 
   g_variant_ref_sink (arguments);
 
+  if (g_get_prgname () == NULL && g_variant_n_children (arguments))
+    {
+      const gchar *argv0;
+      gchar *prgname;
+
+      g_variant_get_child (arguments, 0, "^&ay", &argv0);
+      prgname = g_path_get_basename (argv0);
+      g_set_prgname (prgname);
+      g_free (prgname);
+    }
+
   if (!G_APPLICATION_GET_CLASS (application)
         ->handle_command_line (application, &arguments, &status))
     {
diff --git a/gio/gapplicationimpl-dbus.c b/gio/gapplicationimpl-dbus.c
index b2a46e7..afa594d 100644
--- a/gio/gapplicationimpl-dbus.c
+++ b/gio/gapplicationimpl-dbus.c
@@ -179,6 +179,7 @@ g_application_impl_register (GApplicationImpl  *impl,
   g_assert (impl->session_bus == NULL);
 
   impl->bus_name = appid;
+  impl->app = app;
 
   impl->session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION,
                                       cancellable, error);
@@ -238,8 +239,6 @@ g_application_impl_register (GApplicationImpl  *impl,
     {
       g_dbus_connection_unregister_object (impl->session_bus,
                                            impl->object_id);
-      g_free (impl->object_path);
-      impl->object_path = NULL;
       impl->object_id = 0;
     }
 



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