forked from AuroraMiddleware/gtk
[GtkApplication] Update for GApplication API changes
Move appid parameter first to match GApplication.
This commit is contained in:
parent
c5a4bd0578
commit
bdaefd7efe
@ -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 ();
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user