shell: Let panels have their own commandline flags

Add a class method to CcPanel to get a GOptionGroup which will be added
to the main commandline parser. This gives panels the chance to have
commandline "--flags" in addition to the already available parameters.

This changes changes the way parameters are passed to panels: the first
entry in the GVariant array is always the a{sv} dictionary of
commandline flags, followed by the remaining free-form arguments.

https://bugzilla.gnome.org/show_bug.cgi?id=696054
This commit is contained in:
Emanuele Aina 2013-03-15 17:34:43 +01:00
parent 9977bb200e
commit 31a8a99440
9 changed files with 55 additions and 10 deletions

View file

@ -105,18 +105,22 @@ cc_application_command_line (GApplication *application,
int retval = 0;
GOptionContext *context;
GError *error = NULL;
GVariantBuilder *flags_builder;
verbose = FALSE;
show_overview = FALSE;
show_help = FALSE;
start_panels = NULL;
flags_builder = g_variant_builder_new (G_VARIANT_TYPE_VARDICT);
argv = g_application_command_line_get_arguments (command_line, &argc);
context = g_option_context_new (N_("- Settings"));
g_option_context_add_main_entries (context, all_options, GETTEXT_PACKAGE);
g_option_context_set_translation_domain(context, GETTEXT_PACKAGE);
g_option_context_add_group (context, gtk_get_option_group (TRUE));
cc_panel_loader_add_option_groups (context, flags_builder);
g_option_context_set_help_enabled (context, FALSE);
if (g_option_context_parse (context, &argc, &argv, &error) == FALSE)
@ -192,6 +196,8 @@ cc_application_command_line (GApplication *application,
g_debug ("No extra argument");
builder = g_variant_builder_new (G_VARIANT_TYPE ("av"));
g_variant_builder_add (builder, "v", g_variant_builder_end (flags_builder));
for (i = 1; start_panels[i] != NULL; i++)
g_variant_builder_add (builder, "v", g_variant_new_string (start_panels[i]));
parameters = g_variant_builder_end (builder);