Blame docs/reference/gio/html/GApplicationCommandLine.html

Packit ae235b
Packit ae235b
<html>
Packit ae235b
<head>
Packit ae235b
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Packit ae235b
<title>GApplicationCommandLine: GIO Reference Manual</title>
Packit ae235b
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
Packit ae235b
<link rel="home" href="index.html" title="GIO Reference Manual">
Packit ae235b
<link rel="up" href="application.html" title="Application support">
Packit ae235b
<link rel="prev" href="GApplication.html" title="GApplication">
Packit ae235b
<link rel="next" href="GActionGroup.html" title="GActionGroup">
Packit ae235b
<meta name="generator" content="GTK-Doc V1.27 (XML mode)">
Packit ae235b
<link rel="stylesheet" href="style.css" type="text/css">
Packit ae235b
</head>
Packit ae235b
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
Packit ae235b
Packit ae235b
Packit ae235b
Top  | 
Packit ae235b
                  Description  | 
Packit ae235b
                  Object Hierarchy  | 
Packit ae235b
                  Properties
Packit ae235b
Packit ae235b
Home
Packit ae235b
Up
Packit ae235b
Prev
Packit ae235b
Next
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

GApplicationCommandLine

Packit ae235b

GApplicationCommandLine — A command-line invocation of an application

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Functions

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gchar **
Packit ae235b
Packit ae235b
Packit ae235b
g_application_command_line_get_arguments ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
const gchar *
Packit ae235b
Packit ae235b
Packit ae235b
g_application_command_line_get_cwd ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
const gchar * const *
Packit ae235b
Packit ae235b
Packit ae235b
g_application_command_line_get_environ ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GVariantDict *
Packit ae235b
Packit ae235b
Packit ae235b
g_application_command_line_get_options_dict ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GInputStream *
Packit ae235b
Packit ae235b
Packit ae235b
g_application_command_line_get_stdin ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GFile *
Packit ae235b
Packit ae235b
Packit ae235b
g_application_command_line_create_file_for_arg ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
const gchar *
Packit ae235b
Packit ae235b
Packit ae235b
g_application_command_line_getenv ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gboolean
Packit ae235b
Packit ae235b
Packit ae235b
g_application_command_line_get_is_remote ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GVariant *
Packit ae235b
Packit ae235b
Packit ae235b
g_application_command_line_get_platform_data ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_application_command_line_set_exit_status ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
int
Packit ae235b
Packit ae235b
Packit ae235b
g_application_command_line_get_exit_status ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_application_command_line_print ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_application_command_line_printerr ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Properties

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GVariant *
Packit ae235b
arguments
Packit ae235b
Write / Construct Only
Packit ae235b
Packit ae235b
Packit ae235b
gboolean
Packit ae235b
is-remote
Packit ae235b
Read
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GVariant *
Packit ae235b
options
Packit ae235b
Write / Construct Only
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GVariant *
Packit ae235b
platform-data
Packit ae235b
Write / Construct Only
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Types and Values

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
 
Packit ae235b
GApplicationCommandLine
Packit ae235b
Packit ae235b
Packit ae235b
struct
Packit ae235b
GApplicationCommandLineClass
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Object Hierarchy

Packit ae235b
    GObject
Packit ae235b
    ╰── GApplicationCommandLine
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Includes

Packit ae235b
#include <gio/gio.h>
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Description

Packit ae235b

GApplicationCommandLine represents a command-line invocation of

Packit ae235b
an application.  It is created by GApplication and emitted
Packit ae235b
in the “command-line” signal and virtual function.

Packit ae235b

The class contains the list of arguments that the program was invoked

Packit ae235b
with.  It is also possible to query if the commandline invocation was
Packit ae235b
local (ie: the current process is running in direct response to the
Packit ae235b
invocation) or remote (ie: some other process forwarded the
Packit ae235b
commandline to this process).

Packit ae235b

The GApplicationCommandLine object can provide the argc

Packit ae235b
 and argv
Packit ae235b
Packit ae235b
parameters for use with the GOptionContext command-line parsing API,
Packit ae235b
with the g_application_command_line_get_arguments() function. See
Packit ae235b
gapplication-example-cmdline3.c
Packit ae235b
for an example.

Packit ae235b

The exit status of the originally-invoked process may be set and

Packit ae235b
messages can be printed to stdout or stderr of that process.  The
Packit ae235b
lifecycle of the originally-invoked process is tied to the lifecycle
Packit ae235b
of this object (ie: the process exits when the last reference is
Packit ae235b
dropped).

Packit ae235b

The main use for GApplicationCommandLine (and the

Packit ae235b
“command-line” signal) is 'Emacs server' like use cases:
Packit ae235b
You can set the EDITOR environment variable to have e.g. git use
Packit ae235b
your favourite editor to edit commit messages, and if you already
Packit ae235b
have an instance of the editor running, the editing will happen
Packit ae235b
in the running instance, instead of opening a new one. An important
Packit ae235b
aspect of this use case is that the process that gets started by git
Packit ae235b
does not return until the editing is done.

Packit ae235b

Normally, the commandline is completely handled in the

Packit ae235b
“command-line” handler. The launching instance exits
Packit ae235b
once the signal handler in the primary instance has returned, and
Packit ae235b
the return value of the signal handler becomes the exit status
Packit ae235b
of the launching instance.

Packit ae235b
Packit ae235b
  
Packit ae235b
    
Packit ae235b
      
Packit ae235b
        
1
Packit ae235b
2
Packit ae235b
3
Packit ae235b
4
Packit ae235b
5
Packit ae235b
6
Packit ae235b
7
Packit ae235b
8
Packit ae235b
9
Packit ae235b
10
Packit ae235b
11
Packit ae235b
12
Packit ae235b
13
Packit ae235b
14
Packit ae235b
15
Packit ae235b
16
Packit ae235b
17
Packit ae235b
18
Packit ae235b
19
Packit ae235b
20
Packit ae235b
21
Packit ae235b
        
static int
Packit ae235b
command_line (GApplication            *application,
Packit ae235b
              GApplicationCommandLine *cmdline)
Packit ae235b
{
Packit ae235b
  gchar **argv;
Packit ae235b
  gint argc;
Packit ae235b
  gint i;
Packit ae235b
Packit ae235b
  argv = g_application_command_line_get_arguments (cmdline, &argc);
Packit ae235b
Packit ae235b
  g_application_command_line_print (cmdline,
Packit ae235b
                                    "This text is written back\n"
Packit ae235b
                                    "to stdout of the caller\n");
Packit ae235b
Packit ae235b
  for (i = 0; i < argc; i++)
Packit ae235b
    g_print ("argument %d: %s\n", i, argv[i]);
Packit ae235b
Packit ae235b
  g_strfreev (argv);
Packit ae235b
Packit ae235b
  return 0;
Packit ae235b
}
Packit ae235b
      
Packit ae235b
    
Packit ae235b
  
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
The complete example can be found here: 
Packit ae235b
gapplication-example-cmdline.c

Packit ae235b

In more complicated cases, the handling of the comandline can be

Packit ae235b
split between the launcher and the primary instance.

Packit ae235b
Packit ae235b
  
Packit ae235b
    
Packit ae235b
      
Packit ae235b
        
1
Packit ae235b
2
Packit ae235b
3
Packit ae235b
4
Packit ae235b
5
Packit ae235b
6
Packit ae235b
7
Packit ae235b
8
Packit ae235b
9
Packit ae235b
10
Packit ae235b
11
Packit ae235b
12
Packit ae235b
13
Packit ae235b
14
Packit ae235b
15
Packit ae235b
16
Packit ae235b
17
Packit ae235b
18
Packit ae235b
19
Packit ae235b
20
Packit ae235b
21
Packit ae235b
22
Packit ae235b
23
Packit ae235b
24
Packit ae235b
25
Packit ae235b
26
Packit ae235b
27
Packit ae235b
28
Packit ae235b
29
Packit ae235b
30
Packit ae235b
31
Packit ae235b
32
Packit ae235b
33
Packit ae235b
34
Packit ae235b
35
Packit ae235b
36
Packit ae235b
37
Packit ae235b
38
Packit ae235b
39
Packit ae235b
        
static gboolean
Packit ae235b
 test_local_cmdline (GApplication   *application,
Packit ae235b
                     gchar        ***arguments,
Packit ae235b
                     gint           *exit_status)
Packit ae235b
{
Packit ae235b
  gint i, j;
Packit ae235b
  gchar **argv;
Packit ae235b
Packit ae235b
  argv = *arguments;
Packit ae235b
Packit ae235b
  i = 1;
Packit ae235b
  while (argv[i])
Packit ae235b
    {
Packit ae235b
      if (g_str_has_prefix (argv[i], "--local-"))
Packit ae235b
        {
Packit ae235b
          g_print ("handling argument %s locally\n", argv[i]);
Packit ae235b
          g_free (argv[i]);
Packit ae235b
          for (j = i; argv[j]; j++)
Packit ae235b
            argv[j] = argv[j + 1];
Packit ae235b
        }
Packit ae235b
      else
Packit ae235b
        {
Packit ae235b
          g_print ("not handling argument %s locally\n", argv[i]);
Packit ae235b
          i++;
Packit ae235b
        }
Packit ae235b
    }
Packit ae235b
Packit ae235b
  *exit_status = 0;
Packit ae235b
Packit ae235b
  return FALSE;
Packit ae235b
}
Packit ae235b
Packit ae235b
static void
Packit ae235b
test_application_class_init (TestApplicationClass *class)
Packit ae235b
{
Packit ae235b
  G_APPLICATION_CLASS (class)->local_command_line = test_local_cmdline;
Packit ae235b
Packit ae235b
  ...
Packit ae235b
}
Packit ae235b
      
Packit ae235b
    
Packit ae235b
  
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
In this example of split commandline handling, options that start
Packit ae235b
with --local- are handled locally, all other options are passed
Packit ae235b
to the “command-line” handler which runs in the primary
Packit ae235b
instance.

Packit ae235b

The complete example can be found here:

Packit ae235b
gapplication-example-cmdline2.c

Packit ae235b

If handling the commandline requires a lot of work, it may

Packit ae235b
be better to defer it.

Packit ae235b
Packit ae235b
  
Packit ae235b
    
Packit ae235b
      
Packit ae235b
        
1
Packit ae235b
2
Packit ae235b
3
Packit ae235b
4
Packit ae235b
5
Packit ae235b
6
Packit ae235b
7
Packit ae235b
8
Packit ae235b
9
Packit ae235b
10
Packit ae235b
11
Packit ae235b
12
Packit ae235b
13
Packit ae235b
14
Packit ae235b
15
Packit ae235b
16
Packit ae235b
17
Packit ae235b
18
Packit ae235b
19
Packit ae235b
20
Packit ae235b
21
Packit ae235b
22
Packit ae235b
23
Packit ae235b
24
Packit ae235b
25
Packit ae235b
26
Packit ae235b
27
Packit ae235b
28
Packit ae235b
29
Packit ae235b
        
static gboolean
Packit ae235b
my_cmdline_handler (gpointer data)
Packit ae235b
{
Packit ae235b
  GApplicationCommandLine *cmdline = data;
Packit ae235b
Packit ae235b
  // do the heavy lifting in an idle
Packit ae235b
Packit ae235b
  g_application_command_line_set_exit_status (cmdline, 0);
Packit ae235b
  g_object_unref (cmdline); // this releases the application
Packit ae235b
Packit ae235b
  return G_SOURCE_REMOVE;
Packit ae235b
}
Packit ae235b
Packit ae235b
static int
Packit ae235b
command_line (GApplication            *application,
Packit ae235b
              GApplicationCommandLine *cmdline)
Packit ae235b
{
Packit ae235b
  // keep the application running until we are done with this commandline
Packit ae235b
  g_application_hold (application);
Packit ae235b
Packit ae235b
  g_object_set_data_full (G_OBJECT (cmdline),
Packit ae235b
                          "application", application,
Packit ae235b
                          (GDestroyNotify)g_application_release);
Packit ae235b
Packit ae235b
  g_object_ref (cmdline);
Packit ae235b
  g_idle_add (my_cmdline_handler, cmdline);
Packit ae235b
Packit ae235b
  return 0;
Packit ae235b
}
Packit ae235b
      
Packit ae235b
    
Packit ae235b
  
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
In this example the commandline is not completely handled before
Packit ae235b
the “command-line” handler returns. Instead, we keep
Packit ae235b
a reference to the GApplicationCommandLine object and handle it
Packit ae235b
later (in this example, in an idle). Note that it is necessary to
Packit ae235b
hold the application until you are done with the commandline.

Packit ae235b

The complete example can be found here:

Packit ae235b
gapplication-example-cmdline3.c

Packit ae235b
Packit ae235b
Packit ae235b

Functions

Packit ae235b
Packit ae235b

g_application_command_line_get_arguments ()

Packit ae235b
gchar **
Packit ae235b
g_application_command_line_get_arguments
Packit ae235b
                               (GApplicationCommandLine *cmdline,
Packit ae235b
                                int *argc);
Packit ae235b

Gets the list of arguments that was passed on the command line.

Packit ae235b

The strings in the array may contain non-UTF-8 data on UNIX (such as

Packit ae235b
filenames or arguments given in the system locale) but are always in
Packit ae235b
UTF-8 on Windows.

Packit ae235b

If you wish to use the return value with GOptionContext, you must

Packit ae235b
use g_option_context_parse_strv().

Packit ae235b

The return value is NULL-terminated and should be freed using

Packit ae235b
g_strfreev().

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmdline

Packit ae235b

a GApplicationCommandLine

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

argc

Packit ae235b

the length of the arguments array, or NULL.

Packit ae235b
[out][optional]
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

(array length=argc) (element-type filename) (transfer full)

Packit ae235b
the string array containing the arguments (the argv)

Packit ae235b
Packit ae235b

Since: 2.28

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_application_command_line_get_cwd ()

Packit ae235b
const gchar *
Packit ae235b
g_application_command_line_get_cwd (GApplicationCommandLine *cmdline);
Packit ae235b

Gets the working directory of the command line invocation.

Packit ae235b
The string may contain non-utf8 data.

Packit ae235b

It is possible that the remote application did not send a working

Packit ae235b
directory, so this may be NULL.

Packit ae235b

The return value should not be modified or freed and is valid for as

Packit ae235b
long as cmdline
Packit ae235b
 exists.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmdline

Packit ae235b

a GApplicationCommandLine

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the current directory, or NULL.

Packit ae235b

[nullable][type filename]

Packit ae235b
Packit ae235b

Since: 2.28

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_application_command_line_get_environ ()

Packit ae235b
const gchar * const *
Packit ae235b
g_application_command_line_get_environ
Packit ae235b
                               (GApplicationCommandLine *cmdline);
Packit ae235b

Gets the contents of the 'environ' variable of the command line

Packit ae235b
invocation, as would be returned by g_get_environ(), ie as a
Packit ae235b
NULL-terminated list of strings in the form 'NAME=VALUE'.
Packit ae235b
The strings may contain non-utf8 data.

Packit ae235b

The remote application usually does not send an environment. Use

Packit ae235b
G_APPLICATION_SEND_ENVIRONMENT to affect that.  Even with this flag
Packit ae235b
set it is possible that the environment is still not available (due
Packit ae235b
to invocation messages from other applications).

Packit ae235b

The return value should not be modified or freed and is valid for as

Packit ae235b
long as cmdline
Packit ae235b
 exists.

Packit ae235b

See g_application_command_line_getenv() if you are only interested

Packit ae235b
in the value of a single environment variable.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmdline

Packit ae235b

a GApplicationCommandLine

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the environment strings, or NULL if they were not sent.

Packit ae235b

[array zero-terminated=1][element-type filename][transfer none]

Packit ae235b
Packit ae235b

Since: 2.28

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_application_command_line_get_options_dict ()

Packit ae235b
GVariantDict *
Packit ae235b
g_application_command_line_get_options_dict
Packit ae235b
                               (GApplicationCommandLine *cmdline);
Packit ae235b

Gets the options there were passed to g_application_command_line().

Packit ae235b

If you did not override local_command_line() then these are the same

Packit ae235b
options that were parsed according to the GOptionEntrys added to the
Packit ae235b
application with g_application_add_main_option_entries() and possibly
Packit ae235b
modified from your GApplication::handle-local-options handler.

Packit ae235b

If no options were sent then an empty dictionary is returned so that

Packit ae235b
you don't need to check for NULL.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmdline

Packit ae235b

a GApplicationCommandLine

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

a GVariantDict with the options.

Packit ae235b

[transfer none]

Packit ae235b
Packit ae235b

Since: 2.40

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_application_command_line_get_stdin ()

Packit ae235b
GInputStream *
Packit ae235b
g_application_command_line_get_stdin (GApplicationCommandLine *cmdline);
Packit ae235b

Gets the stdin of the invoking process.

Packit ae235b

The GInputStream can be used to read data passed to the standard

Packit ae235b
input of the invoking process.
Packit ae235b
This doesn't work on all platforms.  Presently, it is only available
Packit ae235b
on UNIX when using a DBus daemon capable of passing file descriptors.
Packit ae235b
If stdin is not available then NULL will be returned.  In the
Packit ae235b
future, support may be expanded to other platforms.

Packit ae235b

You must only call this function once per commandline invocation.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmdline

Packit ae235b

a GApplicationCommandLine

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

a GInputStream for stdin.

Packit ae235b

[transfer full]

Packit ae235b
Packit ae235b

Since: 2.34

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_application_command_line_create_file_for_arg ()

Packit ae235b
GFile *
Packit ae235b
g_application_command_line_create_file_for_arg
Packit ae235b
                               (GApplicationCommandLine *cmdline,
Packit ae235b
                                const gchar *arg);
Packit ae235b

Creates a GFile corresponding to a filename that was given as part

Packit ae235b
of the invocation of cmdline
Packit ae235b
.

Packit ae235b

This differs from g_file_new_for_commandline_arg() in that it

Packit ae235b
resolves relative pathnames using the current working directory of
Packit ae235b
the invoking process rather than the local process.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmdline

Packit ae235b

a GApplicationCommandLine

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

arg

Packit ae235b

an argument from cmdline

Packit ae235b
. 

Packit ae235b
[type filename]
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

a new GFile.

Packit ae235b

[transfer full]

Packit ae235b
Packit ae235b

Since: 2.36

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_application_command_line_getenv ()

Packit ae235b
const gchar *
Packit ae235b
g_application_command_line_getenv (GApplicationCommandLine *cmdline,
Packit ae235b
                                   const gchar *name);
Packit ae235b

Gets the value of a particular environment variable of the command

Packit ae235b
line invocation, as would be returned by g_getenv().  The strings may
Packit ae235b
contain non-utf8 data.

Packit ae235b

The remote application usually does not send an environment. Use

Packit ae235b
G_APPLICATION_SEND_ENVIRONMENT to affect that.  Even with this flag
Packit ae235b
set it is possible that the environment is still not available (due
Packit ae235b
to invocation messages from other applications).

Packit ae235b

The return value should not be modified or freed and is valid for as

Packit ae235b
long as cmdline
Packit ae235b
 exists.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmdline

Packit ae235b

a GApplicationCommandLine

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

name

Packit ae235b

the environment variable to get.

Packit ae235b
[type filename]
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the value of the variable, or NULL if unset or unsent

Packit ae235b
Packit ae235b

Since: 2.28

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_application_command_line_get_is_remote ()

Packit ae235b
gboolean
Packit ae235b
g_application_command_line_get_is_remote
Packit ae235b
                               (GApplicationCommandLine *cmdline);
Packit ae235b

Determines if cmdline

Packit ae235b
 represents a remote invocation.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmdline

Packit ae235b

a GApplicationCommandLine

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

TRUE if the invocation was remote

Packit ae235b
Packit ae235b

Since: 2.28

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_application_command_line_get_platform_data ()

Packit ae235b
GVariant *
Packit ae235b
g_application_command_line_get_platform_data
Packit ae235b
                               (GApplicationCommandLine *cmdline);
Packit ae235b

Gets the platform data associated with the invocation of cmdline

Packit ae235b
.

Packit ae235b

This is a GVariant dictionary containing information about the

Packit ae235b
context in which the invocation occurred.  It typically contains
Packit ae235b
information like the current working directory and the startup
Packit ae235b
notification ID.

Packit ae235b

For local invocation, it will be NULL.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmdline

Packit ae235b

GApplicationCommandLine

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the platform data, or NULL.

Packit ae235b

[nullable]

Packit ae235b
Packit ae235b

Since: 2.28

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_application_command_line_set_exit_status ()

Packit ae235b
void
Packit ae235b
g_application_command_line_set_exit_status
Packit ae235b
                               (GApplicationCommandLine *cmdline,
Packit ae235b
                                int exit_status);
Packit ae235b

Sets the exit status that will be used when the invoking process

Packit ae235b
exits.

Packit ae235b

The return value of the “command-line” signal is

Packit ae235b
passed to this function when the handler returns.  This is the usual
Packit ae235b
way of setting the exit status.

Packit ae235b

In the event that you want the remote invocation to continue running

Packit ae235b
and want to decide on the exit status in the future, you can use this
Packit ae235b
call.  For the case of a remote invocation, the remote process will
Packit ae235b
typically exit when the last reference is dropped on cmdline
Packit ae235b
.  The
Packit ae235b
exit status of the remote process will be equal to the last value
Packit ae235b
that was set with this function.

Packit ae235b

In the case that the commandline invocation is local, the situation

Packit ae235b
is slightly more complicated.  If the commandline invocation results
Packit ae235b
in the mainloop running (ie: because the use-count of the application
Packit ae235b
increased to a non-zero value) then the application is considered to
Packit ae235b
have been 'successful' in a certain sense, and the exit status is
Packit ae235b
always zero.  If the application use count is zero, though, the exit
Packit ae235b
status of the local GApplicationCommandLine is used.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmdline

Packit ae235b

a GApplicationCommandLine

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

exit_status

Packit ae235b

the exit status

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Since: 2.28

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_application_command_line_get_exit_status ()

Packit ae235b
int
Packit ae235b
g_application_command_line_get_exit_status
Packit ae235b
                               (GApplicationCommandLine *cmdline);
Packit ae235b

Gets the exit status of cmdline

Packit ae235b
.  See
Packit ae235b
g_application_command_line_set_exit_status() for more information.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmdline

Packit ae235b

a GApplicationCommandLine

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the exit status

Packit ae235b
Packit ae235b

Since: 2.28

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_application_command_line_print ()

Packit ae235b
void
Packit ae235b
g_application_command_line_print (GApplicationCommandLine *cmdline,
Packit ae235b
                                  const gchar *format,
Packit ae235b
                                  ...);
Packit ae235b

Formats a message and prints it using the stdout print handler in the

Packit ae235b
invoking process.

Packit ae235b

If cmdline

Packit ae235b
 is a local invocation then this is exactly equivalent to
Packit ae235b
g_print().  If cmdline
Packit ae235b
 is remote then this is equivalent to calling
Packit ae235b
g_print() in the invoking process.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmdline

Packit ae235b

a GApplicationCommandLine

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

format

Packit ae235b

a printf-style format string

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

...

Packit ae235b

arguments, as per format

Packit ae235b

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Since: 2.28

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_application_command_line_printerr ()

Packit ae235b
void
Packit ae235b
g_application_command_line_printerr (GApplicationCommandLine *cmdline,
Packit ae235b
                                     const gchar *format,
Packit ae235b
                                     ...);
Packit ae235b

Formats a message and prints it using the stderr print handler in the

Packit ae235b
invoking process.

Packit ae235b

If cmdline

Packit ae235b
 is a local invocation then this is exactly equivalent to
Packit ae235b
g_printerr().  If cmdline
Packit ae235b
 is remote then this is equivalent to
Packit ae235b
calling g_printerr() in the invoking process.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmdline

Packit ae235b

a GApplicationCommandLine

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

format

Packit ae235b

a printf-style format string

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

...

Packit ae235b

arguments, as per format

Packit ae235b

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Since: 2.28

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Types and Values

Packit ae235b
Packit ae235b

GApplicationCommandLine

Packit ae235b
typedef struct _GApplicationCommandLine GApplicationCommandLine;
Packit ae235b

GApplicationCommandLine is an opaque data structure and can only be accessed

Packit ae235b
using the following functions.

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

struct GApplicationCommandLineClass

Packit ae235b
struct GApplicationCommandLineClass {
Packit ae235b
};
Packit ae235b
Packit ae235b

The GApplicationCommandLineClass

Packit ae235b
contains private data only.

Packit ae235b

Since: 2.28

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Property Details

Packit ae235b
Packit ae235b

The “arguments” property

Packit ae235b
  “arguments”                GVariant *
Packit ae235b

The commandline that caused this ::command-line signal emission.

Packit ae235b

Flags: Write / Construct Only

Packit ae235b

Allowed values: GVariant<aay>

Packit ae235b

Default value: NULL

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

The “is-remote” property

Packit ae235b
  “is-remote”                gboolean
Packit ae235b

TRUE if this is a remote commandline.

Packit ae235b

Flags: Read

Packit ae235b

Default value: FALSE

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

The “options” property

Packit ae235b
  “options”                  GVariant *
Packit ae235b

The options sent along with the commandline.

Packit ae235b

Flags: Write / Construct Only

Packit ae235b

Allowed values: GVariant<a{sv}>

Packit ae235b

Default value: NULL

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

The “platform-data” property

Packit ae235b
  “platform-data”            GVariant *
Packit ae235b

Platform-specific data for the commandline.

Packit ae235b

Flags: Write / Construct Only

Packit ae235b

Allowed values: GVariant<a{sv}>

Packit ae235b

Default value: NULL

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

See Also

Packit ae235b

GApplication

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Generated by GTK-Doc V1.27
Packit ae235b
</body>
Packit ae235b
</html>