Use GOptionGroup to parse parameters.
authorJose Dapena Paz <jdapena@igalia.com>
Wed, 29 Apr 2009 10:07:44 +0000 (12:07 +0200)
committerJose Dapena Paz <jdapena@igalia.com>
Wed, 29 Apr 2009 10:07:44 +0000 (12:07 +0200)
src/modest-main.c

index f84edf3..1d6bde6 100644 (file)
 #include "modest-platform.h"
 #include "modest-ui-actions.h"
 
 #include "modest-platform.h"
 #include "modest-ui-actions.h"
 
+static gboolean show_ui = FALSE;
+static GOptionEntry option_entries [] =
+{
+       { "show-ui", 's', 0, G_OPTION_ARG_NONE, &show_ui, "Show UI immediately, so no wait for DBUS activation", NULL },
+       { NULL }
+};
+
 typedef struct {
        gulong queue_handler;
        gulong window_list_handler;
 typedef struct {
        gulong queue_handler;
        gulong window_list_handler;
@@ -117,11 +124,20 @@ main (int argc, char *argv[])
        int retval  = 0;
        MainSignalHandlers *handlers;
 
        int retval  = 0;
        MainSignalHandlers *handlers;
 
-       if (argc >= 2) {
-               if (strcmp (argv[1], "showui") == 0)
-                       show_ui_without_top_application_method = TRUE;
+       GError *error;
+       GOptionContext *context;
+
+       context = g_option_context_new ("- Modest email client");
+       g_option_context_add_main_entries (context, option_entries, GETTEXT_PACKAGE);
+       g_option_context_add_group (context, gtk_get_option_group (TRUE));
+       if (!g_option_context_parse (context, &argc, &argv, &error)) {
+               g_print ("option parsing failed: %s\n", error->message);
+               exit (1);
        }
 
        }
 
+
+       show_ui_without_top_application_method = show_ui;
+
        if (!show_ui_without_top_application_method) {
                g_print ("modest: use 'modest showui' to start from cmdline  with UI\n");
        }
        if (!show_ui_without_top_application_method) {
                g_print ("modest: use 'modest showui' to start from cmdline  with UI\n");
        }