Back to Seed Clases

Gio


Classes

Interfaces

Structs

Unions

Enums

GObject.Object
parent-child marker Gio.ApplicationCommandLine

Class Gio.ApplicationCommandLine

Import line: Gio = imports.gi.Gio;
GIR File: Gio-2.0.gir
C documentation: GApplicationCommandLine
Class : ApplicationCommandLine
Extends: GObject.Object
GApplicationCommandLine represents a command-line invocation of
an application. It is created by GApplication and emitted
in the GApplication::command-line signal and virtual function.
The class contains the list of arguments that the program was invoked
with. It is also possible to query if the commandline invocation was
commandline to this process).
The GApplicationCommandLine object can provide the argc and argv
parameters for use with the GOptionContext command-line parsing API,
with the g_application_command_line_get_arguments() function. See
for an example.
The exit status of the originally-invoked process may be set and
messages can be printed to stdout or stderr of that process. The
lifecycle of the originally-invoked process is tied to the lifecycle
dropped).
The main use for GApplicationCommandline (and the
GApplication::command-line signal) is 'Emacs server' like use cases:
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
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.
Handling commandline arguments with GApplication

A simple example where the commandline is completely handled
in the GApplication::command-line handler. The launching instance exits
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.



FIXME: MISSING XINCLUDE CONTENT



Split commandline handling

An example of split commandline handling. Options that start with
--local- are handled locally, all other options are
passed to the GApplication::command-line handler which runs in the primary
instance.



FIXME: MISSING XINCLUDE CONTENT



Deferred commandline handling

An example of deferred commandline handling. Here, the commandline is
not completely handled before the GApplication::command-line handler
returns. Instead, we keep a reference to the GApplicationCommandline
object and handle it later(in this example, in an idle). Note that it
is necessary to hold the application until you are done with the
commandline.


This example also shows how to use GOptionContext for parsing the
commandline arguments.



FIXME: MISSING XINCLUDE CONTENT


Properties
Properties Defined By
Methods / Constructors
Method / Constructor Defined By
Events
None
Used by These Methods / Signals / Properties
Class / Namespace Method / Signal / Properties
Gio.Application
Signal
command_line (Application self, ApplicationCommandLine command_line) : gint32
The ::command-line signal is emitted on the primary instance when
a commandline is not handled locally.
Documentation generated by Introspection Doc Generator Loosely Based on JsDoc Toolkit on Sat Apr 16 2011 17:11:08 GMT+0800 (HKT)