[gtk+] [GtkApplication] Update for GApplication API changes



commit bdaefd7efe2a18bbffc440187296749f6c097250
Author: Colin Walters <walters verbum org>
Date:   Wed Jun 16 11:02:39 2010 -0400

    [GtkApplication] Update for GApplication API changes
    
    Move appid parameter first to match GApplication.

 gtk/gtkapplication.c    |   52 +++++++++++++++++++++++++++++++++++++---------
 gtk/gtkapplication.h    |    6 ++--
 tests/testapplication.c |    2 +-
 3 files changed, 46 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c
index 2266032..56748f7 100644
--- a/gtk/gtkapplication.c
+++ b/gtk/gtkapplication.c
@@ -204,11 +204,32 @@ gtk_application_format_activation_data (void)
   return g_variant_builder_end (&builder);
 }
 
+static GVariant *
+variant_from_argv (int    argc,
+		   char **argv)
+{
+  GVariantBuilder builder;
+  int i;
+
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("aay"));
+
+  for (i = 1; i < argc; i++)
+    {
+      guint8 *argv_bytes;
+
+      argv_bytes = (guint8*) argv[i];
+      g_variant_builder_add_value (&builder,
+				   g_variant_new_byte_array (argv_bytes, -1));
+    }
+  
+  return g_variant_builder_end (&builder);
+}
+
 /**
  * gtk_application_new:
+ * @appid: System-dependent application identifier
  * @argc: (allow-none) (inout): System argument count
  * @argv: (allow-none) (inout): System argument vector
- * @appid: System-dependent application identifier
  *
  * Create a new #GtkApplication, or if one has already been initialized
  * in this process, return the existing instance. This function will as
@@ -222,14 +243,15 @@ gtk_application_format_activation_data (void)
  * Since: 3.0
  */
 GtkApplication*
-gtk_application_new (gint          *argc,
-                     gchar       ***argv,
-                     const gchar   *appid)
+gtk_application_new (const gchar   *appid,
+		     gint          *argc,
+                     gchar       ***argv)
 {
   GtkApplication *app;
   gint argc_for_app;
   gchar **argv_for_app;
-  GVariant *platform_data;
+  GVariant *argv_variant;
+  GError *error = NULL;
 
   gtk_init (argc, argv);
 
@@ -242,12 +264,20 @@ gtk_application_new (gint          *argc,
   else
     argv_for_app = NULL;
 
-  app = g_object_new (GTK_TYPE_APPLICATION, "application-id", appid, NULL);
+  argv_variant = variant_from_argv (argc_for_app, argv_for_app);
 
-  platform_data = gtk_application_format_activation_data ();
-  g_application_register_with_data (G_APPLICATION (app), argc_for_app, argv_for_app,
-				    platform_data);
-  g_variant_unref (platform_data);
+  app = g_initable_new (GTK_TYPE_APPLICATION, 
+			NULL,
+			&error,
+			"application-id", appid, 
+			"argv", argv_variant, 
+			NULL);
+  if (!app)
+    {
+      g_error ("%s", error->message);
+      g_clear_error (&error);
+      return NULL;
+    }
 
   return app;
 }
@@ -505,6 +535,8 @@ gtk_application_init (GtkApplication *application)
 {
   application->priv = G_TYPE_INSTANCE_GET_PRIVATE (application, GTK_TYPE_APPLICATION, GtkApplicationPrivate);
 
+  g_object_set (application, "platform-data", gtk_application_format_activation_data (), NULL);
+
   setup_default_window_decorations ();
 }
 
diff --git a/gtk/gtkapplication.h b/gtk/gtkapplication.h
index 7782f0a..dc01b42 100644
--- a/gtk/gtkapplication.h
+++ b/gtk/gtkapplication.h
@@ -87,9 +87,9 @@ struct _GtkApplicationClass
 };
 
 GType           gtk_application_get_type         (void) G_GNUC_CONST;
-GtkApplication* gtk_application_new              (gint             *argc,
-                                                  gchar          ***argv,
-                                                  const gchar      *appid);
+GtkApplication* gtk_application_new              (const gchar      *appid,
+						  gint             *argc,
+                                                  gchar          ***argv);
 void            gtk_application_set_action_group (GtkApplication   *app,
                                                   GtkActionGroup   *group);
 GtkWindow *     gtk_application_get_window       (GtkApplication   *app);
diff --git a/tests/testapplication.c b/tests/testapplication.c
index a2883fa..3a60b1c 100644
--- a/tests/testapplication.c
+++ b/tests/testapplication.c
@@ -75,7 +75,7 @@ main (int argc, char **argv)
       exit (0);
     }
 
-  app = gtk_application_new (&argc, &argv, "org.gtk.TestApp");
+  app = gtk_application_new ("org.gtk.TestApp", &argc, &argv);
   builder = gtk_builder_new ();
   if (!gtk_builder_add_from_string (builder, builder_data, -1, NULL))
     g_error ("failed to parse UI");



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