mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-16 20:38:48 +02:00
GApplication: reduce GVariant abuse
Don't use GVariant* as the representation for the argument array.
This commit is contained in:
parent
a327bc51fc
commit
e33deea16c
@ -2692,7 +2692,6 @@ g_application_activate
|
|||||||
g_application_open
|
g_application_open
|
||||||
<SUBSECTION>
|
<SUBSECTION>
|
||||||
g_application_run
|
g_application_run
|
||||||
g_application_run_with_arguments
|
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
G_TYPE_APPLICATION
|
G_TYPE_APPLICATION
|
||||||
G_APPLICATION
|
G_APPLICATION
|
||||||
|
@ -158,7 +158,7 @@ g_application_real_command_line (GApplication *application,
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
g_application_real_local_command_line (GApplication *application,
|
g_application_real_local_command_line (GApplication *application,
|
||||||
GVariant **arguments,
|
gchar ***arguments,
|
||||||
int *exit_status)
|
int *exit_status)
|
||||||
{
|
{
|
||||||
if (application->priv->flags & G_APPLICATION_HANDLES_COMMAND_LINE)
|
if (application->priv->flags & G_APPLICATION_HANDLES_COMMAND_LINE)
|
||||||
@ -177,7 +177,7 @@ g_application_real_local_command_line (GApplication *application,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
n_args = g_variant_n_children (*arguments);
|
n_args = g_strv_length (*arguments);
|
||||||
|
|
||||||
if (application->priv->flags & G_APPLICATION_IS_SERVICE)
|
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);
|
files = g_new (GFile *, n_files);
|
||||||
|
|
||||||
for (i = 0; i < n_files; i++)
|
for (i = 0; i < n_files; i++)
|
||||||
{
|
files[i] = g_file_new_for_commandline_arg ((*arguments)[i + 1]);
|
||||||
const gchar *arg;
|
|
||||||
|
|
||||||
g_variant_get_child (*arguments, i + 1, "^&ay", &arg);
|
|
||||||
files[i] = g_file_new_for_commandline_arg (arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_application_open (application, files, n_files, "");
|
g_application_open (application, files, n_files, "");
|
||||||
|
|
||||||
@ -1014,41 +1009,23 @@ g_application_run (GApplication *application,
|
|||||||
int argc,
|
int argc,
|
||||||
char **argv)
|
char **argv)
|
||||||
{
|
{
|
||||||
|
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_return_val_if_fail (argc == 0 || argv != NULL, 1);
|
||||||
|
|
||||||
return g_application_run_with_arguments (application,
|
arguments = g_new (gchar *, argc + 1);
|
||||||
g_variant_new_bytestring_array ((const gchar **) argv, argc));
|
for (i = 0; i < argc; i++)
|
||||||
}
|
arguments[i] = g_strdup (argv[i]);
|
||||||
|
arguments[i] = NULL;
|
||||||
|
|
||||||
/**
|
if (g_get_prgname () == NULL && argc > 0)
|
||||||
* 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)
|
|
||||||
{
|
{
|
||||||
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;
|
gchar *prgname;
|
||||||
|
|
||||||
g_variant_get_child (arguments, 0, "^&ay", &argv0);
|
prgname = g_path_get_basename (argv[0]);
|
||||||
prgname = g_path_get_basename (argv0);
|
|
||||||
g_set_prgname (prgname);
|
g_set_prgname (prgname);
|
||||||
g_free (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 &&
|
if (application->priv->flags & G_APPLICATION_IS_SERVICE &&
|
||||||
!application->priv->use_count &&
|
!application->priv->use_count &&
|
||||||
|
@ -98,7 +98,7 @@ struct _GApplicationClass
|
|||||||
|
|
||||||
/* vfuncs */
|
/* vfuncs */
|
||||||
gboolean (* local_command_line) (GApplication *application,
|
gboolean (* local_command_line) (GApplication *application,
|
||||||
GVariant **arguments,
|
gchar ***arguments,
|
||||||
int *exit_status);
|
int *exit_status);
|
||||||
|
|
||||||
void (* before_emit) (GApplication *application,
|
void (* before_emit) (GApplication *application,
|
||||||
|
@ -453,7 +453,7 @@ g_application_impl_cmdline_done (GObject *source,
|
|||||||
|
|
||||||
int
|
int
|
||||||
g_application_impl_command_line (GApplicationImpl *impl,
|
g_application_impl_command_line (GApplicationImpl *impl,
|
||||||
GVariant *arguments,
|
gchar **arguments,
|
||||||
GVariant *platform_data)
|
GVariant *platform_data)
|
||||||
{
|
{
|
||||||
const static GDBusInterfaceVTable vtable = {
|
const static GDBusInterfaceVTable vtable = {
|
||||||
@ -481,7 +481,7 @@ g_application_impl_command_line (GApplicationImpl *impl,
|
|||||||
impl->object_path,
|
impl->object_path,
|
||||||
"org.gtk.Application",
|
"org.gtk.Application",
|
||||||
"CommandLine",
|
"CommandLine",
|
||||||
g_variant_new ("(o@aay@a{sv})", object_path,
|
g_variant_new ("(o^aay@a{sv})", object_path,
|
||||||
arguments, platform_data),
|
arguments, platform_data),
|
||||||
G_VARIANT_TYPE ("(i)"), 0, -1, NULL,
|
G_VARIANT_TYPE ("(i)"), 0, -1, NULL,
|
||||||
g_application_impl_cmdline_done, &data);
|
g_application_impl_cmdline_done, &data);
|
||||||
|
@ -26,7 +26,7 @@ void g_application_impl_open (GApplic
|
|||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
int g_application_impl_command_line (GApplicationImpl *impl,
|
int g_application_impl_command_line (GApplicationImpl *impl,
|
||||||
GVariant *arguments,
|
gchar **arguments,
|
||||||
GVariant *platform_data);
|
GVariant *platform_data);
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
|
@ -41,7 +41,6 @@ g_application_open
|
|||||||
g_application_register
|
g_application_register
|
||||||
g_application_release
|
g_application_release
|
||||||
g_application_run
|
g_application_run
|
||||||
g_application_run_with_arguments
|
|
||||||
g_application_set_action_group
|
g_application_set_action_group
|
||||||
g_application_set_application_id
|
g_application_set_application_id
|
||||||
g_application_set_flags
|
g_application_set_flags
|
||||||
@ -51,10 +50,8 @@ g_application_set_inactivity_timeout
|
|||||||
|
|
||||||
#if IN_HEADER(__G_APPLICATION_COMMAND_LINE_H__)
|
#if IN_HEADER(__G_APPLICATION_COMMAND_LINE_H__)
|
||||||
#if IN_FILE(__G_APPLICATION_COMMAND_LINE_C__)
|
#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_arguments
|
||||||
g_application_command_line_get_cwd
|
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_exit_status
|
||||||
g_application_command_line_get_is_remote
|
g_application_command_line_get_is_remote
|
||||||
g_application_command_line_get_platform_data
|
g_application_command_line_get_platform_data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user