[glib] GApplication: reduce GVariant abuse
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GApplication: reduce GVariant abuse
- Date: Tue, 19 Oct 2010 17:38:28 +0000 (UTC)
commit e33deea16ce3af7b91386d5debffd284a0109dfc
Author: Ryan Lortie <desrt desrt ca>
Date: Tue Oct 19 19:38:00 2010 +0200
GApplication: reduce GVariant abuse
Don't use GVariant* as the representation for the argument array.
docs/reference/gio/gio-sections.txt | 1 -
gio/gapplication.c | 53 ++++++++++-------------------------
gio/gapplication.h | 40 +++++++++++++-------------
gio/gapplicationimpl-dbus.c | 8 ++--
gio/gapplicationimpl.h | 2 +-
gio/gio.symbols | 3 --
6 files changed, 40 insertions(+), 67 deletions(-)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index 408c8b0..aac6be4 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -2692,7 +2692,6 @@ g_application_activate
g_application_open
<SUBSECTION>
g_application_run
-g_application_run_with_arguments
<SUBSECTION Standard>
G_TYPE_APPLICATION
G_APPLICATION
diff --git a/gio/gapplication.c b/gio/gapplication.c
index 8210db3..63f9a3f 100644
--- a/gio/gapplication.c
+++ b/gio/gapplication.c
@@ -157,9 +157,9 @@ g_application_real_command_line (GApplication *application,
}
static gboolean
-g_application_real_local_command_line (GApplication *application,
- GVariant **arguments,
- int *exit_status)
+g_application_real_local_command_line (GApplication *application,
+ gchar ***arguments,
+ int *exit_status)
{
if (application->priv->flags & G_APPLICATION_HANDLES_COMMAND_LINE)
return FALSE;
@@ -177,7 +177,7 @@ g_application_real_local_command_line (GApplication *application,
return TRUE;
}
- n_args = g_variant_n_children (*arguments);
+ n_args = g_strv_length (*arguments);
if (application->priv->flags & G_APPLICATION_IS_SERVICE)
{
@@ -213,12 +213,7 @@ g_application_real_local_command_line (GApplication *application,
files = g_new (GFile *, n_files);
for (i = 0; i < n_files; i++)
- {
- const gchar *arg;
-
- g_variant_get_child (*arguments, i + 1, "^&ay", &arg);
- files[i] = g_file_new_for_commandline_arg (arg);
- }
+ files[i] = g_file_new_for_commandline_arg ((*arguments)[i + 1]);
g_application_open (application, files, n_files, "");
@@ -1014,41 +1009,23 @@ 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));
-}
-
-/**
- * g_application_run_with_arguments:
- * @application: a #GApplication
- * @arguments: a bytestring array #GVariant
- * @returns: the exit status
- *
- * This is a bindings-friendly version of g_application_run().
- *
- * This function will consume @arguments if it is floating.
- **/
-int
-g_application_run_with_arguments (GApplication *application,
- GVariant *arguments)
-{
+ gchar **arguments;
int status;
+ gint i;
g_return_val_if_fail (G_IS_APPLICATION (application), 1);
- g_return_val_if_fail (G_IS_APPLICATION (application), 1);
+ g_return_val_if_fail (argc == 0 || argv != NULL, 1);
- g_variant_ref_sink (arguments);
+ arguments = g_new (gchar *, argc + 1);
+ for (i = 0; i < argc; i++)
+ arguments[i] = g_strdup (argv[i]);
+ arguments[i] = NULL;
- if (g_get_prgname () == NULL && g_variant_n_children (arguments))
+ if (g_get_prgname () == NULL && argc > 0)
{
- const gchar *argv0;
gchar *prgname;
- g_variant_get_child (arguments, 0, "^&ay", &argv0);
- prgname = g_path_get_basename (argv0);
+ prgname = g_path_get_basename (argv[0]);
g_set_prgname (prgname);
g_free (prgname);
}
@@ -1086,7 +1063,7 @@ g_application_run_with_arguments (GApplication *application,
}
}
- g_variant_unref (arguments);
+ g_strfreev (arguments);
if (application->priv->flags & G_APPLICATION_IS_SERVICE &&
!application->priv->use_count &&
diff --git a/gio/gapplication.h b/gio/gapplication.h
index baa86a9..0974019 100644
--- a/gio/gapplication.h
+++ b/gio/gapplication.h
@@ -84,31 +84,31 @@ struct _GApplicationClass
/*< public >*/
/* signals */
- void (* startup) (GApplication *application);
+ void (* startup) (GApplication *application);
- void (* activate) (GApplication *application);
+ void (* activate) (GApplication *application);
- void (* open) (GApplication *application,
- GFile **files,
- gint n_files,
- const gchar *hint);
+ void (* open) (GApplication *application,
+ GFile **files,
+ gint n_files,
+ const gchar *hint);
- int (* command_line) (GApplication *application,
- GApplicationCommandLine *command_line);
+ int (* command_line) (GApplication *application,
+ GApplicationCommandLine *command_line);
/* vfuncs */
- gboolean (* local_command_line) (GApplication *application,
- GVariant **arguments,
- int *exit_status);
-
- void (* before_emit) (GApplication *application,
- GVariant *platform_data);
- void (* after_emit) (GApplication *application,
- GVariant *platform_data);
- void (* add_platform_data) (GApplication *application,
- GVariantBuilder *builder);
- void (* quit_mainloop) (GApplication *application);
- void (* run_mainloop) (GApplication *application);
+ gboolean (* local_command_line) (GApplication *application,
+ gchar ***arguments,
+ int *exit_status);
+
+ void (* before_emit) (GApplication *application,
+ GVariant *platform_data);
+ void (* after_emit) (GApplication *application,
+ GVariant *platform_data);
+ void (* add_platform_data) (GApplication *application,
+ GVariantBuilder *builder);
+ void (* quit_mainloop) (GApplication *application);
+ void (* run_mainloop) (GApplication *application);
/*< private >*/
gpointer padding[12];
diff --git a/gio/gapplicationimpl-dbus.c b/gio/gapplicationimpl-dbus.c
index 7a65595..e41f01e 100644
--- a/gio/gapplicationimpl-dbus.c
+++ b/gio/gapplicationimpl-dbus.c
@@ -452,9 +452,9 @@ g_application_impl_cmdline_done (GObject *source,
}
int
-g_application_impl_command_line (GApplicationImpl *impl,
- GVariant *arguments,
- GVariant *platform_data)
+g_application_impl_command_line (GApplicationImpl *impl,
+ gchar **arguments,
+ GVariant *platform_data)
{
const static GDBusInterfaceVTable vtable = {
g_application_impl_cmdline_method_call
@@ -481,7 +481,7 @@ g_application_impl_command_line (GApplicationImpl *impl,
impl->object_path,
"org.gtk.Application",
"CommandLine",
- g_variant_new ("(o aay@a{sv})", object_path,
+ g_variant_new ("(o^aay a{sv})", object_path,
arguments, platform_data),
G_VARIANT_TYPE ("(i)"), 0, -1, NULL,
g_application_impl_cmdline_done, &data);
diff --git a/gio/gapplicationimpl.h b/gio/gapplicationimpl.h
index 06a5320..35a34b9 100644
--- a/gio/gapplicationimpl.h
+++ b/gio/gapplicationimpl.h
@@ -26,7 +26,7 @@ void g_application_impl_open (GApplic
G_GNUC_INTERNAL
int g_application_impl_command_line (GApplicationImpl *impl,
- GVariant *arguments,
+ gchar **arguments,
GVariant *platform_data);
G_GNUC_INTERNAL
diff --git a/gio/gio.symbols b/gio/gio.symbols
index 0ca7e5f..af837f8 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -41,7 +41,6 @@ g_application_open
g_application_register
g_application_release
g_application_run
-g_application_run_with_arguments
g_application_set_action_group
g_application_set_application_id
g_application_set_flags
@@ -51,10 +50,8 @@ g_application_set_inactivity_timeout
#if IN_HEADER(__G_APPLICATION_COMMAND_LINE_H__)
#if IN_FILE(__G_APPLICATION_COMMAND_LINE_C__)
-g_application_command_line_get_argc_argv
g_application_command_line_get_arguments
g_application_command_line_get_cwd
-g_application_command_line_get_cwd_variant
g_application_command_line_get_exit_status
g_application_command_line_get_is_remote
g_application_command_line_get_platform_data
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]