After the commandline arguments are parsed, the
handle-local-options signal will be emitted. At this
point, the application can inspect the values pointed to by arg_data
in the given GOptionEntrys
Unlike glib.OptionContext, gtk.Application supports giving a NULLarg_data for a non-callback GOptionEntry This results in the
argument in question being packed into a glib.VariantDict which is also
passed to handle-local-options, where it can be
inspected and modified. If G_APPLICATION_HANDLES_COMMAND_LINE is
set, then the resulting dictionary is sent to the primary instance,
where Application.commandLineGetOptionsDict will return it.
This "packing" is done according to the type of the argument --
booleans for normal flags, strings for strings, bytestrings for
filenames, etc. The packing only occurs if the flag is given (ie: we
do not pack a "false" glib.Variant in the case that a flag is missing).
In general, it is recommended that all commandline arguments are
parsed locally. The options dictionary should then be used to
transmit the result of the parsing to the primary instance, where
Variant.dictLookup can be used. For local options, it is
possible to either use arg_data in the usual way, or to consult (and
potentially remove) the option from the options dictionary.
This function is new in GLib 2.40. Before then, the only real choice
was to send all of the commandline arguments (options and all) to the
primary instance for handling. gtk.Application ignored them completely
on the local side. Calling this function "opts in" to the new
behaviour, and in particular, means that unrecognised options will be
treated as errors. Unrecognised options have never been ignored when
G_APPLICATION_HANDLES_COMMAND_LINE is unset.
If handle-local-options needs to see the list of
filenames, then the use of G_OPTION_REMAINING is recommended. If
arg_data is NULL then G_OPTION_REMAINING can be used as a key into
the options dictionary. If you do use G_OPTION_REMAINING then you
need to handle these arguments for yourself because once they are
consumed, they will no longer be visible to the default handling
(which treats them as filenames to be opened).
It is important to use the proper GVariant format when retrieving
the options with Variant.dictLookup:
- for G_OPTION_ARG_NONE, use b
- for G_OPTION_ARG_STRING, use &s
- for G_OPTION_ARG_INT, use i
- for G_OPTION_ARG_INT64, use x
- for G_OPTION_ARG_DOUBLE, use d
- for G_OPTION_ARG_FILENAME, use ^&ay
- for G_OPTION_ARG_STRING_ARRAY, use ^a&s
- for G_OPTION_ARG_FILENAME_ARRAY, use ^a&ay
Adds main option entries to be handled by application.
This function is comparable to OptionContext.addMainEntries.
After the commandline arguments are parsed, the handle-local-options signal will be emitted. At this point, the application can inspect the values pointed to by arg_data in the given GOptionEntrys
Unlike glib.OptionContext, gtk.Application supports giving a NULL arg_data for a non-callback GOptionEntry This results in the argument in question being packed into a glib.VariantDict which is also passed to handle-local-options, where it can be inspected and modified. If G_APPLICATION_HANDLES_COMMAND_LINE is set, then the resulting dictionary is sent to the primary instance, where Application.commandLineGetOptionsDict will return it. This "packing" is done according to the type of the argument -- booleans for normal flags, strings for strings, bytestrings for filenames, etc. The packing only occurs if the flag is given (ie: we do not pack a "false" glib.Variant in the case that a flag is missing).
In general, it is recommended that all commandline arguments are parsed locally. The options dictionary should then be used to transmit the result of the parsing to the primary instance, where Variant.dictLookup can be used. For local options, it is possible to either use arg_data in the usual way, or to consult (and potentially remove) the option from the options dictionary.
This function is new in GLib 2.40. Before then, the only real choice was to send all of the commandline arguments (options and all) to the primary instance for handling. gtk.Application ignored them completely on the local side. Calling this function "opts in" to the new behaviour, and in particular, means that unrecognised options will be treated as errors. Unrecognised options have never been ignored when G_APPLICATION_HANDLES_COMMAND_LINE is unset.
If handle-local-options needs to see the list of filenames, then the use of G_OPTION_REMAINING is recommended. If arg_data is NULL then G_OPTION_REMAINING can be used as a key into the options dictionary. If you do use G_OPTION_REMAINING then you need to handle these arguments for yourself because once they are consumed, they will no longer be visible to the default handling (which treats them as filenames to be opened).
It is important to use the proper GVariant format when retrieving the options with Variant.dictLookup: - for G_OPTION_ARG_NONE, use b - for G_OPTION_ARG_STRING, use &s - for G_OPTION_ARG_INT, use i - for G_OPTION_ARG_INT64, use x - for G_OPTION_ARG_DOUBLE, use d - for G_OPTION_ARG_FILENAME, use ^&ay - for G_OPTION_ARG_STRING_ARRAY, use ^a&s - for G_OPTION_ARG_FILENAME_ARRAY, use ^a&ay