| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright © 2010 Codethink Limited | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2022-05-18 09:12:45 +01:00
										 |  |  |  * SPDX-License-Identifier: LGPL-2.1-or-later | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2017-05-27 18:21:30 +02:00
										 |  |  |  * This library is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU Lesser General Public | 
					
						
							|  |  |  |  * License as published by the Free Software Foundation; either | 
					
						
							|  |  |  |  * version 2.1 of the License, or (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This library is distributed in the hope that it will be useful, but | 
					
						
							|  |  |  |  * WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
					
						
							|  |  |  |  * Lesser General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU Lesser General Public | 
					
						
							| 
									
										
										
										
											2014-01-23 12:58:29 +01:00
										 |  |  |  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
 | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Authors: Ryan Lortie <desrt@desrt.ca> | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-23 00:40:13 +02:00
										 |  |  | #include "config.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | #include "gapplicationcommandline.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-23 00:40:13 +02:00
										 |  |  | #include "glibintl.h"
 | 
					
						
							| 
									
										
										
										
											2012-11-25 14:25:59 -05:00
										 |  |  | #include "gfile.h"
 | 
					
						
							| 
									
										
										
										
											2010-10-23 00:40:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | #include <string.h>
 | 
					
						
							|  |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-18 14:37:37 -05:00
										 |  |  | #ifdef G_OS_UNIX
 | 
					
						
							|  |  |  | #include "gunixinputstream.h"
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef G_OS_WIN32
 | 
					
						
							|  |  |  | #include <windows.h>
 | 
					
						
							|  |  |  | #undef environ
 | 
					
						
							|  |  |  | #include "gwin32inputstream.h"
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2023-09-25 21:07:47 -04:00
										 |  |  |  * GApplicationCommandLine: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * `GApplicationCommandLine` represents a command-line invocation of | 
					
						
							|  |  |  |  * an application. | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2023-10-23 11:17:24 +01:00
										 |  |  |  * It is created by [class@Gio.Application] and emitted | 
					
						
							|  |  |  |  * in the [signal@Gio.Application::command-line] signal and virtual function. | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The class contains the list of arguments that the program was invoked | 
					
						
							| 
									
										
										
										
											2023-09-25 21:07:47 -04:00
										 |  |  |  * with. It is also possible to query if the commandline invocation was | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |  * local (ie: the current process is running in direct response to the | 
					
						
							|  |  |  |  * invocation) or remote (ie: some other process forwarded the | 
					
						
							|  |  |  |  * commandline to this process). | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2023-09-25 21:07:47 -04:00
										 |  |  |  * The `GApplicationCommandLine` object can provide the @argc and @argv | 
					
						
							| 
									
										
										
										
											2024-01-08 22:35:59 +02:00
										 |  |  |  * parameters for use with the [struct@GLib.OptionContext] command-line parsing API, | 
					
						
							| 
									
										
										
										
											2023-09-25 21:07:47 -04:00
										 |  |  |  * with the [method@Gio.ApplicationCommandLine.get_arguments] function. See | 
					
						
							| 
									
										
										
										
											2025-01-28 21:05:26 +02:00
										 |  |  |  * [gapplication-example-cmdline3.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gapplication-example-cmdline3.c)
 | 
					
						
							| 
									
										
										
										
											2014-02-08 12:26:56 -05:00
										 |  |  |  * for an example. | 
					
						
							| 
									
										
										
										
											2011-03-04 01:36:51 -05:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |  * The exit status of the originally-invoked process may be set and | 
					
						
							| 
									
										
										
										
											2023-11-27 14:15:36 +00:00
										 |  |  |  * messages can be printed to stdout or stderr of that process. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * For remote invocation, the originally-invoked process exits when | 
					
						
							|  |  |  |  * [method@Gio.ApplicationCommandLine.done] method is called. This method is | 
					
						
							|  |  |  |  * also automatically called when the object is disposed. | 
					
						
							| 
									
										
										
										
											2010-10-23 02:27:39 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2023-09-25 21:07:47 -04:00
										 |  |  |  * The main use for `GApplicationCommandLine` (and the | 
					
						
							| 
									
										
										
										
											2023-10-23 11:17:24 +01:00
										 |  |  |  * [signal@Gio.Application::command-line] signal) is 'Emacs server' like use cases: | 
					
						
							| 
									
										
										
										
											2014-02-05 19:32:41 -05:00
										 |  |  |  * You can set the `EDITOR` environment variable to have e.g. git use | 
					
						
							|  |  |  |  * your favourite editor to edit commit messages, and if you already | 
					
						
							|  |  |  |  * have an instance of the editor running, the editing will happen | 
					
						
							| 
									
										
										
										
											2011-03-03 22:40:48 -05:00
										 |  |  |  * in the running instance, instead of opening a new one. An important | 
					
						
							|  |  |  |  * aspect of this use case is that the process that gets started by git | 
					
						
							|  |  |  |  * does not return until the editing is done. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:00 -05:00
										 |  |  |  * Normally, the commandline is completely handled in the | 
					
						
							| 
									
										
										
										
											2023-10-23 11:17:24 +01:00
										 |  |  |  * [signal@Gio.Application::command-line] handler. The launching instance exits | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:00 -05:00
										 |  |  |  * once the signal handler in the primary instance has returned, and | 
					
						
							|  |  |  |  * the return value of the signal handler becomes the exit status | 
					
						
							|  |  |  |  * of the launching instance. | 
					
						
							| 
									
										
										
										
											2023-09-25 21:07:47 -04:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ```c | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:00 -05:00
										 |  |  |  * static int | 
					
						
							|  |  |  |  * command_line (GApplication            *application, | 
					
						
							|  |  |  |  *               GApplicationCommandLine *cmdline) | 
					
						
							|  |  |  |  * { | 
					
						
							|  |  |  |  *   gchar **argv; | 
					
						
							|  |  |  |  *   gint argc; | 
					
						
							|  |  |  |  *   gint i; | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   argv = g_application_command_line_get_arguments (cmdline, &argc); | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   g_application_command_line_print (cmdline, | 
					
						
							|  |  |  |  *                                     "This text is written back\n" | 
					
						
							|  |  |  |  *                                     "to stdout of the caller\n"); | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   for (i = 0; i < argc; i++) | 
					
						
							|  |  |  |  *     g_print ("argument %d: %s\n", i, argv[i]); | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   g_strfreev (argv); | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   return 0; | 
					
						
							|  |  |  |  * } | 
					
						
							| 
									
										
										
										
											2023-09-25 21:07:47 -04:00
										 |  |  |  * ``` | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The complete example can be found here: | 
					
						
							| 
									
										
										
										
											2021-06-07 13:16:50 +01:00
										 |  |  |  * [gapplication-example-cmdline.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gapplication-example-cmdline.c)
 | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:00 -05:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2022-01-31 14:45:44 +00:00
										 |  |  |  * In more complicated cases, the handling of the commandline can be | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:00 -05:00
										 |  |  |  * split between the launcher and the primary instance. | 
					
						
							| 
									
										
										
										
											2023-09-25 21:07:47 -04:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ```c | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:00 -05:00
										 |  |  |  * static gboolean | 
					
						
							|  |  |  |  *  test_local_cmdline (GApplication   *application, | 
					
						
							|  |  |  |  *                      gchar        ***arguments, | 
					
						
							|  |  |  |  *                      gint           *exit_status) | 
					
						
							|  |  |  |  * { | 
					
						
							|  |  |  |  *   gint i, j; | 
					
						
							|  |  |  |  *   gchar **argv; | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   argv = *arguments; | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2022-01-31 14:46:08 +00:00
										 |  |  |  *   if (argv[0] == NULL) | 
					
						
							|  |  |  |  *     { | 
					
						
							|  |  |  |  *       *exit_status = 0; | 
					
						
							|  |  |  |  *       return FALSE; | 
					
						
							|  |  |  |  *     } | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:00 -05:00
										 |  |  |  *   i = 1; | 
					
						
							|  |  |  |  *   while (argv[i]) | 
					
						
							|  |  |  |  *     { | 
					
						
							|  |  |  |  *       if (g_str_has_prefix (argv[i], "--local-")) | 
					
						
							|  |  |  |  *         { | 
					
						
							|  |  |  |  *           g_print ("handling argument %s locally\n", argv[i]); | 
					
						
							|  |  |  |  *           g_free (argv[i]); | 
					
						
							|  |  |  |  *           for (j = i; argv[j]; j++) | 
					
						
							|  |  |  |  *             argv[j] = argv[j + 1]; | 
					
						
							|  |  |  |  *         } | 
					
						
							|  |  |  |  *       else | 
					
						
							|  |  |  |  *         { | 
					
						
							|  |  |  |  *           g_print ("not handling argument %s locally\n", argv[i]); | 
					
						
							|  |  |  |  *           i++; | 
					
						
							|  |  |  |  *         } | 
					
						
							|  |  |  |  *     } | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   *exit_status = 0; | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   return FALSE; | 
					
						
							|  |  |  |  * } | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * static void | 
					
						
							|  |  |  |  * test_application_class_init (TestApplicationClass *class) | 
					
						
							|  |  |  |  * { | 
					
						
							|  |  |  |  *   G_APPLICATION_CLASS (class)->local_command_line = test_local_cmdline; | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   ... | 
					
						
							|  |  |  |  * } | 
					
						
							| 
									
										
										
										
											2023-09-25 21:07:47 -04:00
										 |  |  |  * ``` | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:00 -05:00
										 |  |  |  * In this example of split commandline handling, options that start | 
					
						
							| 
									
										
										
										
											2014-02-06 08:04:52 -05:00
										 |  |  |  * with `--local-` are handled locally, all other options are passed | 
					
						
							| 
									
										
										
										
											2023-10-23 11:17:24 +01:00
										 |  |  |  * to the [signal@Gio.Application::command-line] handler which runs in the primary | 
					
						
							| 
									
										
										
										
											2014-02-06 08:04:52 -05:00
										 |  |  |  * instance. | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:00 -05:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-02-05 21:23:28 -05:00
										 |  |  |  * The complete example can be found here: | 
					
						
							| 
									
										
										
										
											2021-06-07 13:16:50 +01:00
										 |  |  |  * [gapplication-example-cmdline2.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gapplication-example-cmdline2.c)
 | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:00 -05:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2023-09-25 21:07:47 -04:00
										 |  |  |  * If handling the commandline requires a lot of work, it may be better to defer it. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ```c | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:00 -05:00
										 |  |  |  * static gboolean | 
					
						
							|  |  |  |  * my_cmdline_handler (gpointer data) | 
					
						
							|  |  |  |  * { | 
					
						
							|  |  |  |  *   GApplicationCommandLine *cmdline = data; | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-02-14 21:33:36 -05:00
										 |  |  |  *   // do the heavy lifting in an idle
 | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:00 -05:00
										 |  |  |  * | 
					
						
							|  |  |  |  *   g_application_command_line_set_exit_status (cmdline, 0); | 
					
						
							| 
									
										
										
										
											2014-02-14 21:33:36 -05:00
										 |  |  |  *   g_object_unref (cmdline); // this releases the application
 | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:00 -05:00
										 |  |  |  * | 
					
						
							|  |  |  |  *   return G_SOURCE_REMOVE; | 
					
						
							|  |  |  |  * } | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * static int | 
					
						
							|  |  |  |  * command_line (GApplication            *application, | 
					
						
							|  |  |  |  *               GApplicationCommandLine *cmdline) | 
					
						
							|  |  |  |  * { | 
					
						
							| 
									
										
										
										
											2014-02-14 21:33:36 -05:00
										 |  |  |  *   // keep the application running until we are done with this commandline
 | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:00 -05:00
										 |  |  |  *   g_application_hold (application); | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   g_object_set_data_full (G_OBJECT (cmdline), | 
					
						
							|  |  |  |  *                           "application", application, | 
					
						
							|  |  |  |  *                           (GDestroyNotify)g_application_release); | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   g_object_ref (cmdline); | 
					
						
							|  |  |  |  *   g_idle_add (my_cmdline_handler, cmdline); | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   return 0; | 
					
						
							|  |  |  |  * } | 
					
						
							| 
									
										
										
										
											2023-09-25 21:07:47 -04:00
										 |  |  |  * ``` | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:00 -05:00
										 |  |  |  * In this example the commandline is not completely handled before | 
					
						
							| 
									
										
										
										
											2023-10-23 11:17:24 +01:00
										 |  |  |  * the [signal@Gio.Application::command-line] handler returns. Instead, we keep | 
					
						
							| 
									
										
										
										
											2023-09-25 21:07:47 -04:00
										 |  |  |  * a reference to the `GApplicationCommandLine` object and handle it | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:00 -05:00
										 |  |  |  * later (in this example, in an idle). Note that it is necessary to | 
					
						
							|  |  |  |  * hold the application until you are done with the commandline. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-02-05 21:23:28 -05:00
										 |  |  |  * The complete example can be found here: | 
					
						
							| 
									
										
										
										
											2021-06-07 13:16:50 +01:00
										 |  |  |  * [gapplication-example-cmdline3.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gapplication-example-cmdline3.c)
 | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:00 -05:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-10 17:21:53 -05:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * GApplicationCommandLineClass: | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-01-31 00:29:14 -05:00
										 |  |  |  * The #GApplicationCommandLineClass-struct  | 
					
						
							|  |  |  |  * contains private data only. | 
					
						
							| 
									
										
										
										
											2011-12-10 17:21:53 -05:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.28 | 
					
						
							|  |  |  |  **/ | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | enum | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   PROP_NONE, | 
					
						
							|  |  |  |   PROP_ARGUMENTS, | 
					
						
							| 
									
										
										
										
											2014-01-12 18:14:30 -05:00
										 |  |  |   PROP_OPTIONS, | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  |   PROP_PLATFORM_DATA, | 
					
						
							|  |  |  |   PROP_IS_REMOTE | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct _GApplicationCommandLinePrivate | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   GVariant *platform_data; | 
					
						
							|  |  |  |   GVariant *arguments; | 
					
						
							| 
									
										
										
										
											2014-01-12 18:14:30 -05:00
										 |  |  |   GVariant *options; | 
					
						
							|  |  |  |   GVariantDict *options_dict; | 
					
						
							| 
									
										
										
										
											2016-06-15 11:01:26 -04:00
										 |  |  |   gchar *cwd;  /* in GLib filename encoding, not UTF-8 */ | 
					
						
							| 
									
										
										
										
											2010-10-28 22:49:12 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-08 17:13:34 +01:00
										 |  |  |   gchar **environ; | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  |   gint exit_status; | 
					
						
							| 
									
										
										
										
											2023-11-27 14:15:36 +00:00
										 |  |  |   gboolean done; | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-11 00:29:58 +01:00
										 |  |  | G_DEFINE_TYPE_WITH_PRIVATE (GApplicationCommandLine, g_application_command_line, G_TYPE_OBJECT) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  | /* All subclasses represent remote invocations of some kind. */ | 
					
						
							|  |  |  | #define IS_REMOTE(cmdline) (G_TYPE_FROM_INSTANCE (cmdline) != \
 | 
					
						
							|  |  |  |                             G_TYPE_APPLICATION_COMMAND_LINE) | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  | static void | 
					
						
							|  |  |  | grok_platform_data (GApplicationCommandLine *cmdline) | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |   GVariantIter iter; | 
					
						
							|  |  |  |   const gchar *key; | 
					
						
							|  |  |  |   GVariant *value; | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |   g_variant_iter_init (&iter, cmdline->priv->platform_data); | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |   while (g_variant_iter_loop (&iter, "{&sv}", &key, &value)) | 
					
						
							| 
									
										
										
										
											2022-11-10 23:12:49 +00:00
										 |  |  |     if (strcmp (key, "cwd") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BYTESTRING)) | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |       { | 
					
						
							|  |  |  |         if (!cmdline->priv->cwd) | 
					
						
							| 
									
										
										
										
											2012-02-08 17:13:34 +01:00
										 |  |  |           cmdline->priv->cwd = g_variant_dup_bytestring (value, NULL); | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2010-10-28 22:49:12 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-10 23:12:49 +00:00
										 |  |  |     else if (strcmp (key, "environ") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BYTESTRING_ARRAY)) | 
					
						
							| 
									
										
										
										
											2010-10-28 22:49:12 -04:00
										 |  |  |       { | 
					
						
							|  |  |  |         if (!cmdline->priv->environ) | 
					
						
							| 
									
										
										
										
											2010-10-29 16:33:47 -04:00
										 |  |  |           cmdline->priv->environ = | 
					
						
							| 
									
										
										
										
											2012-02-08 17:13:34 +01:00
										 |  |  |             g_variant_dup_bytestring_array (value, NULL); | 
					
						
							| 
									
										
										
										
											2010-10-28 22:49:12 -04:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2014-01-12 18:14:30 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-10 23:12:49 +00:00
										 |  |  |     else if (strcmp (key, "options") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_VARDICT)) | 
					
						
							| 
									
										
										
										
											2014-01-12 18:14:30 -05:00
										 |  |  |       { | 
					
						
							|  |  |  |         if (!cmdline->priv->options) | 
					
						
							|  |  |  |           cmdline->priv->options = g_variant_ref (value); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | g_application_command_line_real_print_literal (GApplicationCommandLine *cmdline, | 
					
						
							|  |  |  |                                                const gchar             *message) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-07-23 11:04:45 -04:00
										 |  |  |   g_print ("%s", message); | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | g_application_command_line_real_printerr_literal (GApplicationCommandLine *cmdline, | 
					
						
							|  |  |  |                                                   const gchar             *message) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-07-23 11:04:45 -04:00
										 |  |  |   g_printerr ("%s", message); | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-18 14:37:37 -05:00
										 |  |  | static GInputStream * | 
					
						
							|  |  |  | g_application_command_line_real_get_stdin (GApplicationCommandLine *cmdline) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | #ifdef G_OS_UNIX
 | 
					
						
							|  |  |  |   return g_unix_input_stream_new (0, FALSE); | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  |   return g_win32_input_stream_new (GetStdHandle (STD_INPUT_HANDLE), FALSE); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-27 14:15:36 +00:00
										 |  |  | static void | 
					
						
							|  |  |  | g_application_command_line_real_done (GApplicationCommandLine *cmdline) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | static void | 
					
						
							| 
									
										
										
										
											2010-10-23 00:40:13 +02:00
										 |  |  | g_application_command_line_get_property (GObject    *object, | 
					
						
							|  |  |  |                                          guint       prop_id, | 
					
						
							|  |  |  |                                          GValue     *value, | 
					
						
							|  |  |  |                                          GParamSpec *pspec) | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | { | 
					
						
							|  |  |  |   GApplicationCommandLine *cmdline = G_APPLICATION_COMMAND_LINE (object); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   switch (prop_id) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     case PROP_ARGUMENTS: | 
					
						
							|  |  |  |       g_value_set_variant (value, cmdline->priv->arguments); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     case PROP_PLATFORM_DATA: | 
					
						
							|  |  |  |       g_value_set_variant (value, cmdline->priv->platform_data); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     case PROP_IS_REMOTE: | 
					
						
							|  |  |  |       g_value_set_boolean (value, IS_REMOTE (cmdline)); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |       g_assert_not_reached (); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  | g_application_command_line_set_property (GObject      *object, | 
					
						
							|  |  |  |                                          guint         prop_id, | 
					
						
							|  |  |  |                                          const GValue *value, | 
					
						
							|  |  |  |                                          GParamSpec   *pspec) | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | { | 
					
						
							|  |  |  |   GApplicationCommandLine *cmdline = G_APPLICATION_COMMAND_LINE (object); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   switch (prop_id) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     case PROP_ARGUMENTS: | 
					
						
							|  |  |  |       g_assert (cmdline->priv->arguments == NULL); | 
					
						
							|  |  |  |       cmdline->priv->arguments = g_value_dup_variant (value); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-12 18:14:30 -05:00
										 |  |  |     case PROP_OPTIONS: | 
					
						
							|  |  |  |       g_assert (cmdline->priv->options == NULL); | 
					
						
							|  |  |  |       cmdline->priv->options = g_value_dup_variant (value); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  |     case PROP_PLATFORM_DATA: | 
					
						
							|  |  |  |       g_assert (cmdline->priv->platform_data == NULL); | 
					
						
							|  |  |  |       cmdline->priv->platform_data = g_value_dup_variant (value); | 
					
						
							|  |  |  |       if (cmdline->priv->platform_data != NULL) | 
					
						
							|  |  |  |         grok_platform_data (cmdline); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |       g_assert_not_reached (); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-27 14:15:36 +00:00
										 |  |  | static void | 
					
						
							|  |  |  | g_application_command_line_dispose (GObject *object) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   GApplicationCommandLine *cmdline = G_APPLICATION_COMMAND_LINE (object); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   g_application_command_line_done (cmdline); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   G_OBJECT_CLASS (g_application_command_line_parent_class)->dispose (object); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | static void | 
					
						
							|  |  |  | g_application_command_line_finalize (GObject *object) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   GApplicationCommandLine *cmdline = G_APPLICATION_COMMAND_LINE (object); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-12 18:14:30 -05:00
										 |  |  |   if (cmdline->priv->options_dict) | 
					
						
							|  |  |  |     g_variant_dict_unref (cmdline->priv->options_dict); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (cmdline->priv->options) | 
					
						
							|  |  |  |       g_variant_unref (cmdline->priv->options); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  |   if (cmdline->priv->platform_data) | 
					
						
							|  |  |  |     g_variant_unref (cmdline->priv->platform_data); | 
					
						
							|  |  |  |   if (cmdline->priv->arguments) | 
					
						
							|  |  |  |     g_variant_unref (cmdline->priv->arguments); | 
					
						
							| 
									
										
										
										
											2012-02-08 17:13:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   g_free (cmdline->priv->cwd); | 
					
						
							|  |  |  |   g_strfreev (cmdline->priv->environ); | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   G_OBJECT_CLASS (g_application_command_line_parent_class) | 
					
						
							|  |  |  |     ->finalize (object); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | g_application_command_line_init (GApplicationCommandLine *cmdline) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-06-24 15:43:04 +01:00
										 |  |  |   cmdline->priv = g_application_command_line_get_instance_private (cmdline); | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-08 17:13:34 +01:00
										 |  |  | static void | 
					
						
							|  |  |  | g_application_command_line_constructed (GObject *object) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   GApplicationCommandLine *cmdline = G_APPLICATION_COMMAND_LINE (object); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (IS_REMOTE (cmdline)) | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /* In the local case, set cmd and environ */ | 
					
						
							|  |  |  |   if (!cmdline->priv->cwd) | 
					
						
							|  |  |  |     cmdline->priv->cwd = g_get_current_dir (); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!cmdline->priv->environ) | 
					
						
							|  |  |  |     cmdline->priv->environ = g_get_environ (); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | static void | 
					
						
							|  |  |  | g_application_command_line_class_init (GApplicationCommandLineClass *class) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   GObjectClass *object_class = G_OBJECT_CLASS (class); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   object_class->get_property = g_application_command_line_get_property; | 
					
						
							|  |  |  |   object_class->set_property = g_application_command_line_set_property; | 
					
						
							|  |  |  |   object_class->finalize = g_application_command_line_finalize; | 
					
						
							| 
									
										
										
										
											2023-11-27 14:15:36 +00:00
										 |  |  |   object_class->dispose = g_application_command_line_dispose; | 
					
						
							| 
									
										
										
										
											2012-02-08 17:13:34 +01:00
										 |  |  |   object_class->constructed = g_application_command_line_constructed; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  |   class->printerr_literal = g_application_command_line_real_printerr_literal; | 
					
						
							|  |  |  |   class->print_literal = g_application_command_line_real_print_literal; | 
					
						
							| 
									
										
										
										
											2012-01-18 14:37:37 -05:00
										 |  |  |   class->get_stdin = g_application_command_line_real_get_stdin; | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-27 14:15:36 +00:00
										 |  |  |   class->done = g_application_command_line_real_done; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-29 13:23:09 +00:00
										 |  |  |   /**
 | 
					
						
							|  |  |  |    * GApplicationCommandLine:arguments: | 
					
						
							|  |  |  |    * | 
					
						
							|  |  |  |    * The commandline that caused this [signal@Gio.Application::command-line] | 
					
						
							|  |  |  |    * signal emission. | 
					
						
							|  |  |  |    * | 
					
						
							|  |  |  |    * Since: 2.28 | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  |   g_object_class_install_property (object_class, PROP_ARGUMENTS, | 
					
						
							| 
									
										
										
										
											2023-04-28 01:59:26 +02:00
										 |  |  |     g_param_spec_variant ("arguments", NULL, NULL, | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  |                           G_VARIANT_TYPE_BYTESTRING_ARRAY, NULL, | 
					
						
							|  |  |  |                           G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | | 
					
						
							|  |  |  |                           G_PARAM_STATIC_STRINGS)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-29 13:23:09 +00:00
										 |  |  |   /**
 | 
					
						
							|  |  |  |    * GApplicationCommandLine:options: | 
					
						
							|  |  |  |    * | 
					
						
							|  |  |  |    * The options sent along with the commandline. | 
					
						
							|  |  |  |    * | 
					
						
							|  |  |  |    * Since: 2.28 | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2014-01-12 18:14:30 -05:00
										 |  |  |   g_object_class_install_property (object_class, PROP_OPTIONS, | 
					
						
							| 
									
										
										
										
											2023-04-28 01:59:26 +02:00
										 |  |  |     g_param_spec_variant ("options", NULL, NULL, | 
					
						
							| 
									
										
										
										
											2014-01-12 18:14:30 -05:00
										 |  |  |                           G_VARIANT_TYPE_VARDICT, NULL, G_PARAM_WRITABLE | | 
					
						
							|  |  |  |                           G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-29 13:23:09 +00:00
										 |  |  |   /**
 | 
					
						
							|  |  |  |    * GApplicationCommandLine:platform-data: | 
					
						
							|  |  |  |    * | 
					
						
							|  |  |  |    * Platform-specific data for the commandline. | 
					
						
							|  |  |  |    * | 
					
						
							|  |  |  |    * Since: 2.28 | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  |   g_object_class_install_property (object_class, PROP_PLATFORM_DATA, | 
					
						
							| 
									
										
										
										
											2023-04-28 01:59:26 +02:00
										 |  |  |     g_param_spec_variant ("platform-data", NULL, NULL, | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  |                           G_VARIANT_TYPE ("a{sv}"), NULL, | 
					
						
							|  |  |  |                           G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | | 
					
						
							|  |  |  |                           G_PARAM_STATIC_STRINGS)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-29 13:23:09 +00:00
										 |  |  |   /**
 | 
					
						
							|  |  |  |    * GApplicationCommandLine:is-remote: | 
					
						
							|  |  |  |    * | 
					
						
							|  |  |  |    * Whether this is a remote commandline. | 
					
						
							|  |  |  |    * | 
					
						
							|  |  |  |    * Since: 2.28 | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  |   g_object_class_install_property (object_class, PROP_IS_REMOTE, | 
					
						
							| 
									
										
										
										
											2023-04-28 01:59:26 +02:00
										 |  |  |     g_param_spec_boolean ("is-remote", NULL, NULL, | 
					
						
							| 
									
										
										
										
											2010-10-23 00:40:13 +02:00
										 |  |  |                           FALSE, | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  |                           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_application_command_line_get_arguments: | 
					
						
							|  |  |  |  * @cmdline: a #GApplicationCommandLine | 
					
						
							| 
									
										
										
										
											2016-10-28 18:29:02 -07:00
										 |  |  |  * @argc: (out) (optional): the length of the arguments array, or %NULL | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Gets the list of arguments that was passed on the command line. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-01-12 12:31:38 -05:00
										 |  |  |  * The strings in the array may contain non-UTF-8 data on UNIX (such as | 
					
						
							|  |  |  |  * filenames or arguments given in the system locale) but are always in | 
					
						
							|  |  |  |  * UTF-8 on Windows. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * If you wish to use the return value with #GOptionContext, you must | 
					
						
							|  |  |  |  * use g_option_context_parse_strv(). | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The return value is %NULL-terminated and should be freed using | 
					
						
							|  |  |  |  * g_strfreev(). | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2017-10-11 18:49:11 +02:00
										 |  |  |  * Returns: (array length=argc) (element-type filename) (transfer full) | 
					
						
							|  |  |  |  *      the string array containing the arguments (the argv) | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.28 | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | gchar ** | 
					
						
							| 
									
										
										
										
											2010-10-23 00:40:13 +02:00
										 |  |  | g_application_command_line_get_arguments (GApplicationCommandLine *cmdline, | 
					
						
							|  |  |  |                                           int                     *argc) | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  | { | 
					
						
							|  |  |  |   gchar **argv; | 
					
						
							|  |  |  |   gsize len; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_APPLICATION_COMMAND_LINE (cmdline), NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   argv = g_variant_dup_bytestring_array (cmdline->priv->arguments, &len); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (argc) | 
					
						
							|  |  |  |     *argc = len; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return argv; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-12 18:14:30 -05:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * g_application_command_line_get_options_dict: | 
					
						
							|  |  |  |  * @cmdline: a #GApplicationCommandLine | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2022-11-15 19:35:34 +00:00
										 |  |  |  * Gets the options that were passed to g_application_command_line(). | 
					
						
							| 
									
										
										
										
											2014-01-12 18:14:30 -05:00
										 |  |  |  * | 
					
						
							|  |  |  |  * If you did not override local_command_line() then these are the same | 
					
						
							|  |  |  |  * options that were parsed according to the #GOptionEntrys added to the | 
					
						
							|  |  |  |  * application with g_application_add_main_option_entries() and possibly | 
					
						
							|  |  |  |  * modified from your GApplication::handle-local-options handler. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * If no options were sent then an empty dictionary is returned so that | 
					
						
							|  |  |  |  * you don't need to check for %NULL. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2022-11-10 23:11:03 +00:00
										 |  |  |  * The data has been passed via an untrusted external process, so the types of | 
					
						
							|  |  |  |  * all values must be checked before being used. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-01-12 18:14:30 -05:00
										 |  |  |  * Returns: (transfer none): a #GVariantDict with the options | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.40 | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | GVariantDict * | 
					
						
							|  |  |  | g_application_command_line_get_options_dict (GApplicationCommandLine *cmdline) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_APPLICATION_COMMAND_LINE (cmdline), NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!cmdline->priv->options_dict) | 
					
						
							|  |  |  |     cmdline->priv->options_dict = g_variant_dict_new (cmdline->priv->options); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return cmdline->priv->options_dict; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-18 14:37:37 -05:00
										 |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2013-02-03 13:50:36 -05:00
										 |  |  |  * g_application_command_line_get_stdin: | 
					
						
							| 
									
										
										
										
											2012-01-18 14:37:37 -05:00
										 |  |  |  * @cmdline: a #GApplicationCommandLine | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Gets the stdin of the invoking process. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The #GInputStream can be used to read data passed to the standard | 
					
						
							|  |  |  |  * input of the invoking process. | 
					
						
							|  |  |  |  * This doesn't work on all platforms.  Presently, it is only available | 
					
						
							| 
									
										
										
										
											2020-10-26 14:28:15 +00:00
										 |  |  |  * on UNIX when using a D-Bus daemon capable of passing file descriptors. | 
					
						
							| 
									
										
										
										
											2012-01-18 14:37:37 -05:00
										 |  |  |  * If stdin is not available then %NULL will be returned.  In the | 
					
						
							|  |  |  |  * future, support may be expanded to other platforms. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You must only call this function once per commandline invocation. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2020-10-18 11:15:54 +03:00
										 |  |  |  * Returns: (nullable) (transfer full): a #GInputStream for stdin | 
					
						
							| 
									
										
										
										
											2012-01-18 14:37:37 -05:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.34 | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | GInputStream * | 
					
						
							|  |  |  | g_application_command_line_get_stdin (GApplicationCommandLine *cmdline) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return G_APPLICATION_COMMAND_LINE_GET_CLASS (cmdline)->get_stdin (cmdline); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * g_application_command_line_get_cwd: | 
					
						
							|  |  |  |  * @cmdline: a #GApplicationCommandLine | 
					
						
							| 
									
										
										
										
											2010-10-23 00:40:13 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2011-03-04 01:53:56 -05:00
										 |  |  |  * Gets the working directory of the command line invocation. | 
					
						
							|  |  |  |  * The string may contain non-utf8 data. | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * It is possible that the remote application did not send a working | 
					
						
							|  |  |  |  * directory, so this may be %NULL. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The return value should not be modified or freed and is valid for as | 
					
						
							|  |  |  |  * long as @cmdline exists. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2016-06-15 11:01:26 -04:00
										 |  |  |  * Returns: (nullable) (type filename): the current directory, or %NULL | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.28 | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | const gchar * | 
					
						
							|  |  |  | g_application_command_line_get_cwd (GApplicationCommandLine *cmdline) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-02-08 17:13:34 +01:00
										 |  |  |   return cmdline->priv->cwd; | 
					
						
							| 
									
										
										
										
											2010-10-28 22:49:12 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_application_command_line_get_environ: | 
					
						
							|  |  |  |  * @cmdline: a #GApplicationCommandLine | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Gets the contents of the 'environ' variable of the command line | 
					
						
							| 
									
										
										
										
											2011-03-04 01:53:56 -05:00
										 |  |  |  * invocation, as would be returned by g_get_environ(), ie as a | 
					
						
							|  |  |  |  * %NULL-terminated list of strings in the form 'NAME=VALUE'. | 
					
						
							|  |  |  |  * The strings may contain non-utf8 data. | 
					
						
							| 
									
										
										
										
											2010-10-28 22:49:12 -04:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The remote application usually does not send an environment.  Use | 
					
						
							|  |  |  |  * %G_APPLICATION_SEND_ENVIRONMENT to affect that.  Even with this flag | 
					
						
							|  |  |  |  * set it is possible that the environment is still not available (due | 
					
						
							|  |  |  |  * to invocation messages from other applications). | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The return value should not be modified or freed and is valid for as | 
					
						
							|  |  |  |  * long as @cmdline exists. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2011-03-04 01:53:56 -05:00
										 |  |  |  * See g_application_command_line_getenv() if you are only interested | 
					
						
							|  |  |  |  * in the value of a single environment variable. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2017-10-11 18:49:11 +02:00
										 |  |  |  * Returns: (array zero-terminated=1) (element-type filename) (transfer none): | 
					
						
							|  |  |  |  *     the environment strings, or %NULL if they were not sent | 
					
						
							| 
									
										
										
										
											2011-05-18 17:56:50 -04:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2010-10-28 22:49:12 -04:00
										 |  |  |  * Since: 2.28 | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | const gchar * const * | 
					
						
							|  |  |  | g_application_command_line_get_environ (GApplicationCommandLine *cmdline) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-02-08 17:13:34 +01:00
										 |  |  |   return (const gchar **)cmdline->priv->environ; | 
					
						
							| 
									
										
										
										
											2010-10-28 22:49:12 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_application_command_line_getenv: | 
					
						
							|  |  |  |  * @cmdline: a #GApplicationCommandLine | 
					
						
							| 
									
										
										
										
											2017-10-11 18:49:11 +02:00
										 |  |  |  * @name: (type filename): the environment variable to get | 
					
						
							| 
									
										
										
										
											2010-10-28 22:49:12 -04:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Gets the value of a particular environment variable of the command | 
					
						
							|  |  |  |  * line invocation, as would be returned by g_getenv().  The strings may | 
					
						
							|  |  |  |  * contain non-utf8 data. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The remote application usually does not send an environment.  Use | 
					
						
							|  |  |  |  * %G_APPLICATION_SEND_ENVIRONMENT to affect that.  Even with this flag | 
					
						
							|  |  |  |  * set it is possible that the environment is still not available (due | 
					
						
							|  |  |  |  * to invocation messages from other applications). | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The return value should not be modified or freed and is valid for as | 
					
						
							|  |  |  |  * long as @cmdline exists. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2020-10-18 11:15:54 +03:00
										 |  |  |  * Returns: (nullable): the value of the variable, or %NULL if unset or unsent | 
					
						
							| 
									
										
										
										
											2011-05-18 17:56:50 -04:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2010-10-28 22:49:12 -04:00
										 |  |  |  * Since: 2.28 | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | const gchar * | 
					
						
							|  |  |  | g_application_command_line_getenv (GApplicationCommandLine *cmdline, | 
					
						
							|  |  |  |                                    const gchar             *name) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2024-04-25 00:37:47 +01:00
										 |  |  |   size_t length = strlen (name); | 
					
						
							|  |  |  |   size_t i; | 
					
						
							| 
									
										
										
										
											2010-10-28 22:49:12 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   /* TODO: expand on windows */ | 
					
						
							|  |  |  |   if (cmdline->priv->environ) | 
					
						
							|  |  |  |     for (i = 0; cmdline->priv->environ[i]; i++) | 
					
						
							|  |  |  |       if (strncmp (cmdline->priv->environ[i], name, length) == 0 && | 
					
						
							|  |  |  |           cmdline->priv->environ[i][length] == '=') | 
					
						
							|  |  |  |         return cmdline->priv->environ[i] + length + 1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return NULL; | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_application_command_line_get_is_remote: | 
					
						
							|  |  |  |  * @cmdline: a #GApplicationCommandLine | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Determines if @cmdline represents a remote invocation. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Returns: %TRUE if the invocation was remote | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.28 | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | gboolean | 
					
						
							|  |  |  | g_application_command_line_get_is_remote (GApplicationCommandLine *cmdline) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return IS_REMOTE (cmdline); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-18 00:50:11 +03:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * g_application_command_line_print_literal: | 
					
						
							|  |  |  |  * @cmdline: a #GApplicationCommandLine | 
					
						
							|  |  |  |  * @message: the message | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Prints a message using the stdout print handler in the invoking process. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Unlike g_application_command_line_print(), @message is not a `printf()`-style | 
					
						
							|  |  |  |  * format string. Use this function if @message contains text you don't have | 
					
						
							|  |  |  |  * control over, that could include `printf()` escape sequences. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.80 | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | void | 
					
						
							|  |  |  | g_application_command_line_print_literal (GApplicationCommandLine *cmdline, | 
					
						
							|  |  |  |                                           const gchar             *message) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_if_fail (G_IS_APPLICATION_COMMAND_LINE (cmdline)); | 
					
						
							|  |  |  |   g_return_if_fail (message != NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   G_APPLICATION_COMMAND_LINE_GET_CLASS (cmdline) | 
					
						
							|  |  |  |     ->print_literal (cmdline, message); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_application_command_line_printerr_literal: | 
					
						
							|  |  |  |  * @cmdline: a #GApplicationCommandLine | 
					
						
							|  |  |  |  * @message: the message | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Prints a message using the stderr print handler in the invoking process. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Unlike g_application_command_line_printerr(), @message is not | 
					
						
							|  |  |  |  * a `printf()`-style format string. Use this function if @message contains text | 
					
						
							|  |  |  |  * you don't have control over, that could include `printf()` escape sequences. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.80 | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | void | 
					
						
							|  |  |  | g_application_command_line_printerr_literal (GApplicationCommandLine *cmdline, | 
					
						
							|  |  |  |                                              const gchar             *message) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_if_fail (G_IS_APPLICATION_COMMAND_LINE (cmdline)); | 
					
						
							|  |  |  |   g_return_if_fail (message != NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   G_APPLICATION_COMMAND_LINE_GET_CLASS (cmdline) | 
					
						
							|  |  |  |     ->printerr_literal (cmdline, message); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * g_application_command_line_print: | 
					
						
							|  |  |  |  * @cmdline: a #GApplicationCommandLine | 
					
						
							|  |  |  |  * @format: a printf-style format string | 
					
						
							|  |  |  |  * @...: arguments, as per @format | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Formats a message and prints it using the stdout print handler in the | 
					
						
							|  |  |  |  * invoking process. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * If @cmdline is a local invocation then this is exactly equivalent to | 
					
						
							|  |  |  |  * g_print().  If @cmdline is remote then this is equivalent to calling | 
					
						
							|  |  |  |  * g_print() in the invoking process. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.28 | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | void | 
					
						
							|  |  |  | g_application_command_line_print (GApplicationCommandLine *cmdline, | 
					
						
							|  |  |  |                                   const gchar             *format, | 
					
						
							|  |  |  |                                   ...) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   gchar *message; | 
					
						
							|  |  |  |   va_list ap; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   g_return_if_fail (G_IS_APPLICATION_COMMAND_LINE (cmdline)); | 
					
						
							|  |  |  |   g_return_if_fail (format != NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   va_start (ap, format); | 
					
						
							|  |  |  |   message = g_strdup_vprintf (format, ap); | 
					
						
							|  |  |  |   va_end (ap); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   G_APPLICATION_COMMAND_LINE_GET_CLASS (cmdline) | 
					
						
							|  |  |  |     ->print_literal (cmdline, message); | 
					
						
							|  |  |  |   g_free (message); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_application_command_line_printerr: | 
					
						
							|  |  |  |  * @cmdline: a #GApplicationCommandLine | 
					
						
							|  |  |  |  * @format: a printf-style format string | 
					
						
							|  |  |  |  * @...: arguments, as per @format | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Formats a message and prints it using the stderr print handler in the | 
					
						
							|  |  |  |  * invoking process. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * If @cmdline is a local invocation then this is exactly equivalent to | 
					
						
							|  |  |  |  * g_printerr().  If @cmdline is remote then this is equivalent to | 
					
						
							|  |  |  |  * calling g_printerr() in the invoking process. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.28 | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | void | 
					
						
							|  |  |  | g_application_command_line_printerr (GApplicationCommandLine *cmdline, | 
					
						
							|  |  |  |                                      const gchar             *format, | 
					
						
							|  |  |  |                                      ...) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   gchar *message; | 
					
						
							|  |  |  |   va_list ap; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   g_return_if_fail (G_IS_APPLICATION_COMMAND_LINE (cmdline)); | 
					
						
							|  |  |  |   g_return_if_fail (format != NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   va_start (ap, format); | 
					
						
							|  |  |  |   message = g_strdup_vprintf (format, ap); | 
					
						
							|  |  |  |   va_end (ap); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   G_APPLICATION_COMMAND_LINE_GET_CLASS (cmdline) | 
					
						
							|  |  |  |     ->printerr_literal (cmdline, message); | 
					
						
							|  |  |  |   g_free (message); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_application_command_line_set_exit_status: | 
					
						
							|  |  |  |  * @cmdline: a #GApplicationCommandLine | 
					
						
							|  |  |  |  * @exit_status: the exit status | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Sets the exit status that will be used when the invoking process | 
					
						
							|  |  |  |  * exits. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2010-10-23 00:40:13 +02:00
										 |  |  |  * The return value of the #GApplication::command-line signal is | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |  * passed to this function when the handler returns.  This is the usual | 
					
						
							|  |  |  |  * way of setting the exit status. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * In the event that you want the remote invocation to continue running | 
					
						
							|  |  |  |  * and want to decide on the exit status in the future, you can use this | 
					
						
							|  |  |  |  * call.  For the case of a remote invocation, the remote process will | 
					
						
							|  |  |  |  * typically exit when the last reference is dropped on @cmdline.  The | 
					
						
							|  |  |  |  * exit status of the remote process will be equal to the last value | 
					
						
							|  |  |  |  * that was set with this function. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * In the case that the commandline invocation is local, the situation | 
					
						
							|  |  |  |  * is slightly more complicated.  If the commandline invocation results | 
					
						
							|  |  |  |  * in the mainloop running (ie: because the use-count of the application | 
					
						
							|  |  |  |  * increased to a non-zero value) then the application is considered to | 
					
						
							|  |  |  |  * have been 'successful' in a certain sense, and the exit status is | 
					
						
							|  |  |  |  * always zero.  If the application use count is zero, though, the exit | 
					
						
							|  |  |  |  * status of the local #GApplicationCommandLine is used. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2023-11-27 14:15:36 +00:00
										 |  |  |  * This method is a no-op if g_application_command_line_done() has | 
					
						
							|  |  |  |  * been called. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |  * Since: 2.28 | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | void | 
					
						
							|  |  |  | g_application_command_line_set_exit_status (GApplicationCommandLine *cmdline, | 
					
						
							|  |  |  |                                             int                      exit_status) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_if_fail (G_IS_APPLICATION_COMMAND_LINE (cmdline)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-27 14:15:36 +00:00
										 |  |  |   if (cmdline->priv->done) | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |   cmdline->priv->exit_status = exit_status; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_application_command_line_get_exit_status: | 
					
						
							|  |  |  |  * @cmdline: a #GApplicationCommandLine | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Gets the exit status of @cmdline.  See | 
					
						
							|  |  |  |  * g_application_command_line_set_exit_status() for more information. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Returns: the exit status | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.28 | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | int | 
					
						
							|  |  |  | g_application_command_line_get_exit_status (GApplicationCommandLine *cmdline) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_APPLICATION_COMMAND_LINE (cmdline), -1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return cmdline->priv->exit_status; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_application_command_line_get_platform_data: | 
					
						
							|  |  |  |  * @cmdline: #GApplicationCommandLine | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Gets the platform data associated with the invocation of @cmdline. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This is a #GVariant dictionary containing information about the | 
					
						
							| 
									
										
										
										
											2011-08-29 14:49:32 -04:00
										 |  |  |  * context in which the invocation occurred.  It typically contains | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |  * information like the current working directory and the startup | 
					
						
							|  |  |  |  * notification ID. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2022-11-10 23:12:49 +00:00
										 |  |  |  * It comes from an untrusted external process and hence the types of all | 
					
						
							|  |  |  |  * values must be validated before being used. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |  * For local invocation, it will be %NULL. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2022-11-11 00:49:35 +00:00
										 |  |  |  * Returns: (nullable) (transfer full): the platform data, or %NULL | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.28 | 
					
						
							|  |  |  |  **/ | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | GVariant * | 
					
						
							|  |  |  | g_application_command_line_get_platform_data (GApplicationCommandLine *cmdline) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_APPLICATION_COMMAND_LINE (cmdline), NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-19 18:18:13 +02:00
										 |  |  |   if (cmdline->priv->platform_data) | 
					
						
							|  |  |  |     return g_variant_ref (cmdline->priv->platform_data); | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |       return NULL; | 
					
						
							| 
									
										
										
										
											2010-10-09 17:24:09 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2012-11-25 14:25:59 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_application_command_line_create_file_for_arg: | 
					
						
							|  |  |  |  * @cmdline: a #GApplicationCommandLine | 
					
						
							| 
									
										
										
										
											2017-10-11 18:49:11 +02:00
										 |  |  |  * @arg: (type filename): an argument from @cmdline | 
					
						
							| 
									
										
										
										
											2012-11-25 14:25:59 -05:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Creates a #GFile corresponding to a filename that was given as part | 
					
						
							|  |  |  |  * of the invocation of @cmdline. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This differs from g_file_new_for_commandline_arg() in that it | 
					
						
							|  |  |  |  * resolves relative pathnames using the current working directory of | 
					
						
							|  |  |  |  * the invoking process rather than the local process. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Returns: (transfer full): a new #GFile | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.36 | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | GFile * | 
					
						
							|  |  |  | g_application_command_line_create_file_for_arg (GApplicationCommandLine *cmdline, | 
					
						
							|  |  |  |                                                 const gchar             *arg) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_val_if_fail (arg != NULL, NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (cmdline->priv->cwd) | 
					
						
							|  |  |  |     return g_file_new_for_commandline_arg_and_cwd (arg, cmdline->priv->cwd); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   g_warning ("Requested creation of GFile for commandline invocation that did not send cwd. " | 
					
						
							|  |  |  |              "Using cwd of local process to resolve relative path names."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return g_file_new_for_commandline_arg (arg); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-11-27 14:15:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_application_command_line_done: | 
					
						
							|  |  |  |  * @cmdline: a #GApplicationCommandLine | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Signals that command line processing is completed. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * For remote invocation, it causes the invoking process to terminate. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * For local invocation, it does nothing. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This method should be called in the [signal@Gio.Application::command-line] | 
					
						
							|  |  |  |  * handler, after the exit status is set and all messages are printed. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * After this call, g_application_command_line_set_exit_status() has no effect. | 
					
						
							|  |  |  |  * Subsequent calls to this method are no-ops. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This method is automatically called when the #GApplicationCommandLine | 
					
						
							|  |  |  |  * object is disposed — so you can omit the call in non-garbage collected | 
					
						
							|  |  |  |  * languages. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.80 | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | void | 
					
						
							|  |  |  | g_application_command_line_done (GApplicationCommandLine *cmdline) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_if_fail (G_IS_APPLICATION_COMMAND_LINE (cmdline)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (cmdline->priv->done) | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   G_APPLICATION_COMMAND_LINE_GET_CLASS (cmdline)->done (cmdline); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   cmdline->priv->done = TRUE; | 
					
						
							|  |  |  | } |