GApplication: parse command line options

Add support for parsing command line options with GApplication.

You can add GOptionGroup and GOptionEntry using two new APIs:
g_application_add_option_group() and
g_application_add_main_option_entries().

Also add a "handle-local-options" signal that allows handling of
commandline arguments in the local process without having to override
local_command_line.

As a special feature, you can have a %NULL @arg_data in a GOptionEntry
which will cause the argument to be stored in a GVariantDict.  This
dictionary is available for inspection and modification by the
"handle-local-options" signal and can be forwarded to the primary
instance in cases of command line invocation (where it can be fetched
using g_application_command_line_get_options()).

https://bugzilla.gnome.org/show_bug.cgi?id=721977
This commit is contained in:
Ryan Lortie
2014-01-12 18:14:30 -05:00
parent 7f36233042
commit 0e671286fc
7 changed files with 658 additions and 154 deletions

View File

@@ -76,6 +76,9 @@ GLIB_AVAILABLE_IN_ALL
gchar ** g_application_command_line_get_arguments (GApplicationCommandLine *cmdline,
int *argc);
GLIB_AVAILABLE_IN_2_40
GVariantDict * g_application_command_line_get_options_dict (GApplicationCommandLine *cmdline);
GLIB_AVAILABLE_IN_2_36
GInputStream * g_application_command_line_get_stdin (GApplicationCommandLine *cmdline);