Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.6837
diff -u -r1.6837 ChangeLog
--- ChangeLog	24 Mar 2006 05:41:21 -0000	1.6837
+++ ChangeLog	26 Mar 2006 11:20:08 -0000
@@ -1,3 +1,7 @@
+2006-03-26  Philip Van Hoof  <pvanhoof@gnome.org>
+
+	* src/nautilus-main.c: Replaced popt with GOption API
+
 2006-03-24  Martin Wehner  <martin.wehner@gmail.com>
 
 	* src/nautilus-connect-server-dialog-main.c: (main):
Index: src/nautilus-main.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-main.c,v
retrieving revision 1.153
diff -u -r1.153 nautilus-main.c
--- src/nautilus-main.c	20 Mar 2006 15:47:56 -0000	1.153
+++ src/nautilus-main.c	26 Mar 2006 11:20:11 -0000
@@ -224,46 +224,35 @@
 	gboolean no_desktop;
 	const char *startup_id;
 	char *startup_id_copy;
-	char *geometry;
+	gchar *geometry;
+	const gchar **remaining=NULL;
 	gboolean perform_self_check;
-	poptContext popt_context;
-	const char **args;
+	GOptionContext *context;
 	NautilusApplication *application;
 	char **argv_copy;
 	GnomeProgram *program;
-	GValue context_as_value = { 0 };
-	int i;
-
-	struct poptOption options[] = {
+	
+	const GOptionEntry options[] = {
 #ifndef NAUTILUS_OMIT_SELF_CHECK
-		{ "check", 'c', POPT_ARG_NONE, NULL, 0,
+		{ "check", 'c', 0, G_OPTION_ARG_NONE, &perform_self_check, 
 		  N_("Perform a quick set of self-check tests."), NULL },
 #endif
-		{ "geometry", 'g', POPT_ARG_STRING, NULL, 0,
+		{ "geometry", 'g', 0, G_OPTION_ARG_STRING, &geometry,
 		  N_("Create the initial window with the given geometry."), N_("GEOMETRY") },
-		{ "no-default-window", 'n', POPT_ARG_NONE, NULL, 0,
+		{ "no-default-window", 'n', 0, G_OPTION_ARG_NONE, &no_default_window,
 		  N_("Only create windows for explicitly specified URIs."), NULL },
-		{ "no-desktop", '\0', POPT_ARG_NONE, NULL, 0,
+		{ "no-desktop", '\0', 0, G_OPTION_ARG_NONE, &no_desktop,
 		  N_("Do not manage the desktop (ignore the preference set in the preferences dialog)."), NULL },
-		{ "browser", '\0', POPT_ARG_NONE, NULL, 0,
+		{ "browser", '\0', 0, G_OPTION_ARG_NONE, &browser_window, 
 		  N_("open a browser window."), NULL },
-		{ "quit", 'q', POPT_ARG_NONE, NULL, 0,
+		{ "quit", 'q', 0, G_OPTION_ARG_NONE, &kill_shell, 
 		  N_("Quit Nautilus."), NULL },
-		{ "restart", '\0', POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN, NULL, 0,
+		{ "restart", '\0', POPT_ARGFLAG_DOC_HIDDEN, G_OPTION_ARG_NONE, &restart_shell,
 		  N_("Restart Nautilus."), NULL },
-		{ NULL, '\0', 0, NULL, 0, NULL, NULL }
-	};
+		{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining, NULL,  N_("[URI...]") },
 
-	i = 0;
-#ifndef NAUTILUS_OMIT_SELF_CHECK
-	options[i++].arg = &perform_self_check;
-#endif
-	options[i++].arg = &geometry;
-	options[i++].arg = &no_default_window;
-	options[i++].arg = &no_desktop;
-	options[i++].arg = &browser_window;
-	options[i++].arg = &kill_shell;
-	options[i++].arg = &restart_shell;
+		{ NULL }
+	};
 
 	if (g_getenv ("NAUTILUS_DEBUG") != NULL) {
 		eel_make_warnings_and_criticals_stop_in_debugger ();
@@ -295,11 +284,14 @@
 	browser_window = FALSE;
 
 	g_set_application_name (_("File Manager"));
-	
+	context = g_option_context_new (_("Nautilus"));
+
+	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
+
 	program = gnome_program_init ("nautilus", VERSION,
 				      LIBGNOMEUI_MODULE, argc, argv,
 				      GNOME_PROGRAM_STANDARD_PROPERTIES,
-				      GNOME_PARAM_POPT_TABLE, options,
+				      GNOME_PARAM_GOPTION_CONTEXT, context,
 				      GNOME_PARAM_HUMAN_READABLE_NAME, _("Nautilus"),
 				      NULL);
 
@@ -322,15 +314,8 @@
 	bonobo_activation_set_activation_env_value ("DISPLAY",
 						    gdk_display_get_name (gdk_display_get_default()));
 	
-	g_object_get_property (G_OBJECT (program),
-			       GNOME_PARAM_POPT_CONTEXT,
-			       g_value_init (&context_as_value, G_TYPE_POINTER));
-
-	popt_context = g_value_get_pointer (&context_as_value);
-
-	/* Check for argument consistency. */
-	args = poptGetArgs (popt_context);
-	if (perform_self_check && args != NULL) {
+
+	if (perform_self_check && remaining != NULL) {
 		/* translators: %s is an option (e.g. --check) */
 		fprintf (stderr, _("nautilus: %s cannot be used with URIs.\n"),
 			"--check");
@@ -340,17 +325,17 @@
 		fprintf (stderr, _("nautilus: --check cannot be used with other options.\n"));
 		return EXIT_FAILURE;
 	}
-	if (kill_shell && args != NULL) {
+	if (kill_shell && remaining != NULL) {
 		fprintf (stderr, _("nautilus: %s cannot be used with URIs.\n"),
 			"--quit");
 		return EXIT_FAILURE;
 	}
-	if (restart_shell && args != NULL) {
+	if (restart_shell && remaining != NULL) {
 		fprintf (stderr, _("nautilus: %s cannot be used with URIs.\n"),
 			"--restart");
 		return EXIT_FAILURE;
 	}
-	if (geometry != NULL && args != NULL && args[0] != NULL && args[1] != NULL) {
+	if (geometry != NULL && remaining != NULL && remaining[0] != NULL && remaining[1] != NULL) {
 		fprintf (stderr, _("nautilus: --geometry cannot be used with more than one URI.\n"));
 		return EXIT_FAILURE;
 	}
@@ -399,7 +384,7 @@
 			 browser_window,
 			 startup_id_copy,
 			 geometry,
-			 args);
+			 remaining);
 		g_free (startup_id_copy);
 
 		if (is_event_loop_needed ()) {
@@ -407,7 +392,6 @@
 		}
 	}
 
-	poptFreeContext (popt_context);
 
 	gnome_vfs_shutdown ();
 
@@ -439,6 +423,9 @@
 		
 		execvp (argv[0], argv_copy);
 	}
+
+	/* Shouldn't we do this? Keeping it commented for now
+	g_object_unref (G_OBJECT (program)); */
 
 	return EXIT_SUCCESS;
 }
