Blob Blame History Raw
--- gnome-volume-manager-1.5.9/src/manager.c.goption	2006-01-18 15:51:23.000000000 -0500
+++ gnome-volume-manager-1.5.9/src/manager.c	2006-01-18 15:48:51.000000000 -0500
@@ -2462,16 +2462,21 @@
 #define POPT_TABLEEND { NULL, '\0', 0, NULL, '\0', NULL, NULL }
 #endif
 
-static const struct poptOption options[] = {
-	{ "version", 'v', POPT_ARG_NONE | POPT_ARGFLAG_ONEDASH, NULL, 'v',
+static gboolean print_version;
+static char *make_daemon;
+static gboolean no_daemon;
+static gboolean secret_mode;
+
+static GOptionEntry options[] = {
+	{ "version", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE, &print_version,
 	  N_("Print version and exit"), NULL },
-	{ "daemon", 'd', POPT_ARG_STRING | POPT_ARGFLAG_ONEDASH, NULL, 'd',
+	{ "daemon", 'd', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_STRING, &make_daemon,
 	  N_("Run as a daemon"), "<yes|no>" },
-	{ "no-daemon", 'n', POPT_ARG_NONE | POPT_ARGFLAG_ONEDASH, NULL, 'n',
+	{ "no-daemon", 'n', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE, &no_daemon,
 	  N_("Don't run as a daemon"), NULL },
-	{ "secret-mode", 's', POPT_ARG_NONE | POPT_ARGFLAG_ONEDASH, NULL, 's',
+	{ "secret-mode", 's', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE, &secret_mode,
 	  N_("Run in secret mode"), NULL },
-	POPT_TABLEEND
+	{ NULL, '\0', 0, 0, NULL, NULL, NULL}
 };
 
 int
@@ -2480,41 +2485,34 @@
 	gboolean daemonize = TRUE;
 	GnomeProgram *program;
 	GnomeClient *client;
-	poptContext ctx;
+	GOptionContext *context;
 	const char *arg;
 	int rc;
 	
 	bindtextdomain (PACKAGE, GNOMELOCALEDIR);
 	bind_textdomain_codeset (PACKAGE, "UTF-8");
 	textdomain (PACKAGE);
+
+	context = g_option_context_new (PACKAGE);
+	g_option_context_add_main_entries (context, options, NULL);
 	
 	program = gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE, argc, argv,
-				      GNOME_PARAM_POPT_FLAGS, POPT_CONTEXT_POSIXMEHARDER,
-				      GNOME_PARAM_POPT_TABLE, options, GNOME_PARAM_NONE);
-	
-	g_object_get ((GObject *) program, GNOME_PARAM_POPT_CONTEXT, &ctx, NULL);
-	
-	poptResetContext (ctx);
-	
-	while ((rc = poptGetNextOpt (ctx)) > 0) {
-		switch (rc) {
-		case 'v':
-			fprintf (stdout, "%s version %s\n", PACKAGE, VERSION);
-			poptFreeContext (ctx);
-			exit (0);
-		case 'd':
-			if (!(arg = poptGetOptArg (ctx)) || (!strcmp (arg, "true") || !strcmp (arg, "yes"))) {
-				daemonize = TRUE;
-				break;
-			}
-		case 'n':
-			daemonize = FALSE;
-			break;
-		case 's':
-			fprintf (stdout, "Managing volumes since the summer of '89\n");
-			break;
-		}
+				      GNOME_PARAM_GOPTION_CONTEXT, context, GNOME_PARAM_NONE);
+
+	if (print_version) {
+		fprintf (stdout, "%s version %s\n", PACKAGE, VERSION);
+		exit (0);
 	}
+
+	daemonize = FALSE;
+	if (make_daemon == NULL || (strcmp (arg, "true") == 0) || (strcmp (arg, "yes") == 0))
+		daemonize = TRUE;
+
+	if (no_daemon)
+		daemonize = FALSE;
+	
+	if (secret_mode)
+		fprintf (stdout, "Managing volumes since the summer of '89\n");
 	
 	if (daemonize && daemon (0, 0) < 0) {
 		warn ("daemonizing failed: %s", g_strerror (errno));
@@ -2562,7 +2560,6 @@
 	gtk_main ();
 	
 	g_object_unref (program);
-	poptFreeContext (ctx);
 	
 	return 0;
 }