shell: Use g_application_add_main_option_entries

Since GApplication provides this API, we can as well use it, this will
be useful in order to correctly split option handling between the local
instance and the main instance.

https://bugzilla.gnome.org/show_bug.cgi?id=751597
This commit is contained in:
Christophe Fergeau 2015-06-20 14:27:24 +02:00
parent 0db5500232
commit 750bb5158d

View file

@ -123,8 +123,6 @@ cc_application_command_line (GApplication *application,
int argc; int argc;
char **argv; char **argv;
int retval = 0; int retval = 0;
GOptionContext *context;
GError *error = NULL;
verbose = FALSE; verbose = FALSE;
show_overview = FALSE; show_overview = FALSE;
@ -132,26 +130,12 @@ cc_application_command_line (GApplication *application,
argv = g_application_command_line_get_arguments (command_line, &argc); 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));
start_panels = NULL; start_panels = NULL;
search_str = NULL; search_str = NULL;
show_overview = FALSE; show_overview = FALSE;
verbose = FALSE; verbose = FALSE;
list_panels = FALSE; list_panels = FALSE;
if (g_option_context_parse (context, &argc, &argv, &error) == FALSE)
{
g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
error->message, argv[0]);
g_error_free (error);
g_option_context_free (context);
return 1;
}
if (list_panels) if (list_panels)
{ {
GList *panels, *l; GList *panels, *l;
@ -224,7 +208,6 @@ cc_application_command_line (GApplication *application,
show_overview = FALSE; show_overview = FALSE;
g_option_context_free (context);
g_strfreev (argv); g_strfreev (argv);
return retval; return retval;
@ -334,6 +317,8 @@ cc_application_dispose (GObject *object)
static void static void
cc_application_init (CcApplication *self) cc_application_init (CcApplication *self)
{ {
g_application_add_main_option_entries (G_APPLICATION (self), all_options);
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
CC_TYPE_APPLICATION, CC_TYPE_APPLICATION,
CcApplicationPrivate); CcApplicationPrivate);