Index: main.c
===================================================================
RCS file: /cvs/gnome/file-roller/src/main.c,v
retrieving revision 1.21
diff -u -r1.21 main.c
--- main.c	19 Feb 2004 18:20:30 -0000	1.21
+++ main.c	13 Mar 2004 17:16:54 -0000
@@ -49,9 +49,10 @@
 GList        *command_list = NULL;
 gint          force_directory_creation;
 
+static gint   preview;
 static gchar *add_to = NULL;
 static gint   add;
-static gchar *extract_to = NULL;
+static gchar *extract_to = "."; 	//	extract to current directory by default
 static gint   extract;
 static gchar *default_url = NULL;
 
@@ -64,6 +65,10 @@
 	  N_("Add files asking the name of the archive and quit the program"),
 	  0 },
 
+	{ "preview", 'p', POPT_ARG_NONE, &preview, 0,
+	  N_("Preview contents of the archive"),
+	  0 },
+
 	{ "extract-to", 'e', POPT_ARG_STRING, &extract_to, 0,
           N_("Extract archives to the specified folder and quit the program"),
           N_("FOLDER") },
@@ -351,10 +356,28 @@
 	} 
 
 	default_dir = get_path_from_url (default_url);
-	extract_to_path = get_path_from_url (extract_to);
+	if( !g_path_is_absolute(extract_to) )	{
+		char *full_path;
+		char *current_dir = g_get_current_dir();
+		full_path = g_strconcat( current_dir, "/", extract_to, NULL );
+		g_free(current_dir);
+		extract_to_path = get_path_from_url (full_path);
+		g_free(full_path);
+	}
         add_to_path = get_path_from_url (add_to);
 
-	if ((add_to != NULL) || (add == 1)) { /* Add files to an archive */
+	if(preview)	{	 /* Open each archives in a window */
+		const char *archive;
+		
+		while ((archive = poptGetArg (pctx)) != NULL) {
+			FRWindow *window;
+			
+			window = window_new ();
+			gtk_widget_show (window->app);
+			window_archive_open (window, archive, GTK_WINDOW (window->app));
+		}
+	}
+	else if ((add_to != NULL) || (add == 1)) { /* Add files to an archive */
 		FRWindow    *window;
 		GList       *file_list = NULL;
 		const char  *filename;
@@ -394,23 +417,27 @@
 			window_set_default_dir (window, default_dir);
 		gtk_widget_show (window->app);
 		
-		while ((archive = poptGetArg (pctx)) != NULL) 
-			window_archive__open_extract (window, 
-						      archive, 
-						      extract_to_path);
+		while ((archive = poptGetArg (pctx)) != NULL) 	{
+			char *archive_name, *archive_extract_to_path;
+			archive_name = file_name_from_path(archive);
+			archive_extract_to_path = g_strconcat( extract_to_path,
+														"/", 
+														archive_name,
+														"_extracted", 
+														NULL );
+			if( ensure_dir_exists( archive_extract_to_path, 0700 ) )		//	in case creation fails
+				window_archive__open_extract (window, 
+							      archive, 
+							      archive_extract_to_path);
+			else															//	extract in 'extract_to_path'
+				window_archive__open_extract (window, 
+							      archive, 
+							      extract_to_path);
+			g_free( archive_extract_to_path );
+		}
 		window_archive__quit (window);
 		window_batch_mode_start (window);
 
-	} else { /* Open each archives in a window */
-		const char *archive;
-		
-		while ((archive = poptGetArg (pctx)) != NULL) {
-			FRWindow *window;
-			
-			window = window_new ();
-			gtk_widget_show (window->app);
-			window_archive_open (window, archive, GTK_WINDOW (window->app));
-		}
 	}
 	
 	g_free (default_dir);
