diff options
author | Colin Walters <walters@verbum.org> | 2010-06-16 11:02:39 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2010-06-16 11:02:39 -0400 |
commit | bdaefd7efe2a18bbffc440187296749f6c097250 (patch) | |
tree | 91a9c5ef96971a95aa84df9484184bed3cfa14c2 | |
parent | c5a4bd0578f6b0f612e2f9866c645fdecdddf720 (diff) | |
download | gtk+-bdaefd7efe2a18bbffc440187296749f6c097250.tar.gz |
[GtkApplication] Update for GApplication API changes
Move appid parameter first to match GApplication.
-rw-r--r-- | gtk/gtkapplication.c | 52 | ||||
-rw-r--r-- | gtk/gtkapplication.h | 6 | ||||
-rw-r--r-- | tests/testapplication.c | 2 |
3 files changed, 46 insertions, 14 deletions
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c index 22660321ab..56748f72e0 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 7782f0a112..dc01b422d9 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 a2883fa25f..3a60b1c36b 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"); |