file-roller r2367 - in trunk: . src



Author: paobac
Date: Fri Jul 18 17:14:12 2008
New Revision: 2367
URL: http://svn.gnome.org/viewvc/file-roller?rev=2367&view=rev

Log:
2008-07-18  Paolo Bacchilega  <paobac svn gnome org>

	* TODO: updated
	
	* src/typedefs.h: 	
	* src/fr-command-rar.c: 
	
	Added support for the progress dialog during add, extract and delete.
	Related to bug #153281 â Progress bar should be exact.
	
	Do not ask for password when a part of a multi-volume archive is 
	missing.	
	Fixes bug #504584 â Incorrect comportment when extracting multi part 
	rar files.
	
	* src/fr-window.c: 	
	* src/fr-command.h: 
	* src/fr-command.c: 
	* src/fr-archive.h: 
	* src/fr-archive.c: 
	* src/dlg-prop.c: 
	
	Compute the number of regular files in the archive, and use that value
	for the progress dialog and the property dialog.
	Allow to change the name of the current archive in the progress dialog,
	used when the archive is multi-volume.
	Don't use the fake load anymore, in order to allow an exact progress
	dialog when adding or extracting files in batch mode, see bug #153281.
	
	* src/dlg-add-folder.c (file_sel_response_cb): the destination 
	directory is not a uri. 
	
	* src/gtk-utils.c: use an expander instead of a button to show/hide
	the command line output.


Modified:
   trunk/ChangeLog
   trunk/TODO
   trunk/src/dlg-add-folder.c
   trunk/src/dlg-prop.c
   trunk/src/fr-archive.c
   trunk/src/fr-archive.h
   trunk/src/fr-command-rar.c
   trunk/src/fr-command.c
   trunk/src/fr-command.h
   trunk/src/fr-window.c
   trunk/src/gtk-utils.c
   trunk/src/typedefs.h

Modified: trunk/TODO
==============================================================================
--- trunk/TODO	(original)
+++ trunk/TODO	Fri Jul 18 17:14:12 2008
@@ -14,6 +14,12 @@
 
 [ ] #153281 â Progress bar should be exact
 
+[ ] #504584 â Incorrect comportment when extracting multi part rar files
+
+[ ] LP:#186921 â Asking for password with missing archive volume
+
+[ ] #543225 â File-Roller is unable to open gzip-compressed files like pci.ids if they are missing an .gz extension
+
 == Done ==
 
 [x] #521324 â ALZ archive support

Modified: trunk/src/dlg-add-folder.c
==============================================================================
--- trunk/src/dlg-add-folder.c	(original)
+++ trunk/src/dlg-add-folder.c	Fri Jul 18 17:14:12 2008
@@ -117,7 +117,8 @@
 	/* check folder permissions. */
 
 	if (uri_is_dir (current_folder)
-	    && ! check_permissions (current_folder, R_OK | X_OK)) {
+	    && ! check_permissions (current_folder, R_OK | X_OK))
+	{
 		GtkWidget *d;
 		char      *utf8_path;
 
@@ -127,7 +128,7 @@
 					   GTK_DIALOG_MODAL,
 					   NULL,
 					   _("Could not add the files to the archive"),
-					   _("You don't have the right permissions to read files from folder \"%s\""), 
+					   _("You don't have the right permissions to read files from folder \"%s\""),
 					   utf8_path);
 		gtk_dialog_run (GTK_DIALOG (d));
 		gtk_widget_destroy (GTK_WIDGET (d));
@@ -155,7 +156,6 @@
 		const char *include_files;
 		const char *exclude_files;
 		const char *exclude_folders;
-		char       *dest_uri;
 		char       *dest_dir;
 
 		include_files = gtk_entry_get_text (GTK_ENTRY (data->include_files_entry));
@@ -169,10 +169,9 @@
 		if (utf8_only_spaces (exclude_folders))
 			exclude_folders = NULL;
 
-		dest_uri = build_uri (fr_window_get_current_location (window),
+		dest_dir = build_uri (fr_window_get_current_location (window),
 				      file_name_from_path (folder),
 				      NULL);
-		dest_dir = g_filename_from_uri (dest_uri, NULL, NULL);
 
 		fr_window_archive_add_with_wildcard (window,
 						     include_files,
@@ -184,7 +183,6 @@
 						     follow_links);
 
 		g_free (dest_dir);
-		g_free (dest_uri);
 	}
 
 	g_list_free (item_list);
@@ -218,7 +216,7 @@
 					   GTK_DIALOG_MODAL,
 					   NULL,
 					   _("Could not add the files to the archive"),
-					   _("You don't have the right permissions to read files from folder \"%s\""), 
+					   _("You don't have the right permissions to read files from folder \"%s\""),
 					   display_name);
 		gtk_dialog_run (GTK_DIALOG (d));
 		gtk_widget_destroy (GTK_WIDGET (d));
@@ -288,19 +286,19 @@
 	data->include_files_label = gtk_label_new_with_mnemonic (_("Include _files:"));
 	gtk_misc_set_alignment (GTK_MISC (data->include_files_label), 0.0, 0.5);
 	gtk_label_set_mnemonic_widget (GTK_LABEL (data->include_files_label), data->include_files_entry);
-	
+
 	data->exclude_files_entry = gtk_entry_new ();
 	gtk_widget_set_tooltip_text (data->exclude_files_entry, _("example: *.o; *.bak"));
 	data->exclude_files_label = gtk_label_new_with_mnemonic (_("E_xclude files:"));
 	gtk_misc_set_alignment (GTK_MISC (data->exclude_files_label), 0.0, 0.5);
 	gtk_label_set_mnemonic_widget (GTK_LABEL (data->exclude_files_label), data->exclude_files_entry);
-	
+
 	data->exclude_folders_entry = gtk_entry_new ();
 	gtk_widget_set_tooltip_text (data->exclude_folders_entry, _("example: *.o; *.bak"));
 	data->exclude_folders_label = gtk_label_new_with_mnemonic (_("_Exclude folders:"));
 	gtk_misc_set_alignment (GTK_MISC (data->exclude_folders_label), 0.0, 0.5);
 	gtk_label_set_mnemonic_widget (GTK_LABEL (data->exclude_folders_label), data->exclude_folders_entry);
-	
+
 	data->load_button = gtk_button_new_with_mnemonic (_("_Load Options"));
 	data->save_button = gtk_button_new_with_mnemonic (_("Sa_ve Options"));
 	data->clear_button = gtk_button_new_with_mnemonic (_("_Reset Options"));
@@ -315,7 +313,7 @@
 
 	gtk_box_pack_start (GTK_BOX (vbox), data->include_subfold_checkbutton,
 			    TRUE, TRUE, 0);
-			    
+
 	align = gtk_alignment_new (0, 0, 0, 0);
 	gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, 12, 0);
 	gtk_container_add (GTK_CONTAINER (align), data->exclude_symlinks);
@@ -337,7 +335,7 @@
 			  GTK_FILL, 0,
 			  0, 0);
 	gtk_table_attach (GTK_TABLE (table),
-			  data->include_files_entry, 
+			  data->include_files_entry,
 			  1, 4,
 			  0, 1,
 			  GTK_FILL|GTK_EXPAND, 0,
@@ -349,7 +347,7 @@
 			  GTK_FILL, 0,
 			  0, 0);
 	gtk_table_attach (GTK_TABLE (table),
-			  data->exclude_files_entry, 
+			  data->exclude_files_entry,
 			  1, 2,
 			  1, 2,
 			  GTK_FILL|GTK_EXPAND, 0,
@@ -361,7 +359,7 @@
 			  GTK_FILL, 0,
 			  0, 0);
 	gtk_table_attach (GTK_TABLE (table),
-			  data->exclude_folders_entry, 
+			  data->exclude_folders_entry,
 			  3, 4,
 			  1, 2,
 			  GTK_FILL|GTK_EXPAND, 0,
@@ -383,13 +381,13 @@
 	gtk_widget_show_all (main_box);
 
 	/* set data */
-	
+
 	dlg_add_folder_load_last_options (data);
 
 	/* signals */
 
 	g_signal_connect (G_OBJECT (file_sel),
-			  "destroy", 
+			  "destroy",
 			  G_CALLBACK (open_file_destroy_cb),
 			  data);
 	g_signal_connect (G_OBJECT (file_sel),
@@ -401,20 +399,20 @@
 			  G_CALLBACK (selection_changed_cb),
 			  data);
 	g_signal_connect (G_OBJECT (data->include_subfold_checkbutton),
-			  "toggled", 
+			  "toggled",
 			  G_CALLBACK (include_subfold_toggled_cb),
 			  data);
 	g_signal_connect (G_OBJECT (data->load_button),
 			  "clicked",
-			  G_CALLBACK (load_options_cb), 
+			  G_CALLBACK (load_options_cb),
 			  data);
 	g_signal_connect (G_OBJECT (data->save_button),
 			  "clicked",
-			  G_CALLBACK (save_options_cb), 
+			  G_CALLBACK (save_options_cb),
 			  data);
 	g_signal_connect (G_OBJECT (data->clear_button),
 			  "clicked",
-			  G_CALLBACK (clear_options_cb), 
+			  G_CALLBACK (clear_options_cb),
 			  data);
 
 	gtk_window_set_modal (GTK_WINDOW (file_sel),TRUE);
@@ -445,9 +443,9 @@
 			   gboolean    recursive,
 			   gboolean    no_symlinks)
 {
-	if ((base_dir == NULL) || (strcmp (base_dir, "") == 0)) 
+	if ((base_dir == NULL) || (strcmp (base_dir, "") == 0))
 		base_dir = fr_window_get_add_default_dir (data->window);
-	
+
 	if ((filename != NULL) && (strcmp (filename, base_dir) != 0))
 		gtk_file_chooser_select_uri (GTK_FILE_CHOOSER (data->dialog), filename);
 	else
@@ -483,7 +481,7 @@
 
 static gboolean
 dlg_add_folder_load_options (DialogData *data,
-			     const char *name) 
+			     const char *name)
 {
 	GFile     *options_dir;
 	GFile     *options_file;
@@ -498,9 +496,9 @@
 	gboolean   update;
 	gboolean   recursive;
 	gboolean   no_symlinks;
-	
+
 	options_dir = get_home_relative_file (RC_OPTIONS_DIR);
-	options_file = g_file_get_child (options_dir, name);	
+	options_file = g_file_get_child (options_dir, name);
 	file_path = g_file_get_path (options_file);
 	key_file = g_key_file_new ();
 	if (! g_key_file_load_from_file (key_file, file_path, G_KEY_FILE_KEEP_COMMENTS, &error)) {
@@ -512,7 +510,7 @@
 		g_key_file_free (key_file);
 		return FALSE;
 	}
-	
+
 	base_dir = g_key_file_get_string (key_file, "Options", "base_dir", NULL);
 	filename = g_key_file_get_string (key_file, "Options", "filename", NULL);
 	include_files = g_key_file_get_string (key_file, "Options", "include_files", NULL);
@@ -531,9 +529,9 @@
 			   	   update,
 			   	   recursive,
 			   	   no_symlinks);
-	
+
 	dlg_add_folder_save_last_used_options (data, file_path);
-	
+
 	g_free (base_dir);
 	g_free (filename);
 	g_free (include_files);
@@ -543,13 +541,13 @@
 	g_free (file_path);
 	g_object_unref (options_file);
 	g_object_unref (options_dir);
-	
+
 	return TRUE;
 }
 
 
 static void
-dlg_add_folder_load_last_options (DialogData *data) 
+dlg_add_folder_load_last_options (DialogData *data)
 {
 	char     *base_dir = NULL;
 	char     *filename = NULL;
@@ -559,7 +557,7 @@
 	gboolean  update;
 	gboolean  recursive;
 	gboolean  no_symlinks;
-	
+
 	base_dir = eel_gconf_get_string (PREF_ADD_CURRENT_FOLDER, "");
 	filename = eel_gconf_get_string (PREF_ADD_FILENAME, "");
 	include_files = eel_gconf_get_string (PREF_ADD_INCLUDE_FILES, "");
@@ -578,7 +576,7 @@
 			   	   update,
 			   	   recursive,
 			   	   no_symlinks);
-	
+
 	g_free (base_dir);
 	g_free (filename);
 	g_free (include_files);
@@ -611,7 +609,7 @@
 	*exclude_files = gtk_entry_get_text (GTK_ENTRY (data->exclude_files_entry));
 	if (utf8_only_spaces (*exclude_files))
 		*exclude_files = "";
-		
+
 	*exclude_folders = gtk_entry_get_text (GTK_ENTRY (data->exclude_folders_entry));
 	if (utf8_only_spaces (*exclude_folders))
 		*exclude_folders = "";
@@ -620,7 +618,7 @@
 
 static void
 dlg_add_folder_save_current_options (DialogData *data,
-				     GFile      *options_file) 
+				     GFile      *options_file)
 {
 	char       *base_dir;
 	char       *filename;
@@ -631,7 +629,7 @@
 	gboolean    recursive;
 	gboolean    no_symlinks;
 	GKeyFile   *key_file;
-	
+
 	get_options_from_widgets (data,
 				  &base_dir,
 				  &filename,
@@ -643,7 +641,7 @@
 				  &no_symlinks);
 
 	fr_window_set_add_default_dir (data->window, base_dir);
-	
+
 	key_file = g_key_file_new ();
 	g_key_file_set_string (key_file, "Options", "base_dir", base_dir);
 	g_key_file_set_string (key_file, "Options", "filename", filename);
@@ -653,17 +651,17 @@
 	g_key_file_set_boolean (key_file, "Options", "update", update);
 	g_key_file_set_boolean (key_file, "Options", "recursive", recursive);
 	g_key_file_set_boolean (key_file, "Options", "no_symlinks", no_symlinks);
-	
+
 	g_key_file_save (key_file, options_file);
 
 	g_key_file_free (key_file);
 	g_free (base_dir);
-	g_free (filename);	
+	g_free (filename);
 }
 
 
 static void
-dlg_add_folder_save_last_options (DialogData *data) 
+dlg_add_folder_save_last_options (DialogData *data)
 {
 	char       *base_dir;
 	char       *filename;
@@ -683,7 +681,7 @@
 				  &update,
 				  &recursive,
 				  &no_symlinks);
-	
+
 	eel_gconf_set_string (PREF_ADD_CURRENT_FOLDER, base_dir);
 	eel_gconf_set_string (PREF_ADD_FILENAME, filename);
 	eel_gconf_set_string (PREF_ADD_INCLUDE_FILES, include_files);
@@ -692,7 +690,7 @@
 	eel_gconf_set_boolean (PREF_ADD_UPDATE, update);
 	eel_gconf_set_boolean (PREF_ADD_RECURSIVE, recursive);
 	eel_gconf_set_boolean (PREF_ADD_NO_SYMLINKS, no_symlinks);
-			  
+
 	g_free (base_dir);
 	g_free (filename);
 }
@@ -756,10 +754,10 @@
 	GFile           *options_dir;
 	GFileEnumerator *file_enum;
 	GFileInfo       *info;
-	GError          *err = NULL;	
+	GError          *err = NULL;
 
 	gtk_list_store_clear (list_store);
-	
+
 	options_dir = get_home_relative_file (RC_OPTIONS_DIR);
 	make_directory_tree (options_dir, 0700, NULL);
 
@@ -782,9 +780,9 @@
 			continue;
 		}
 
-		name = g_file_info_get_name (info);	
+		name = g_file_info_get_name (info);
 		display_name = g_filename_display_name (name);
-		
+
 		gtk_list_store_append (GTK_LIST_STORE (aod_data->aod_model), &iter);
 		gtk_list_store_set (GTK_LIST_STORE (aod_data->aod_model), &iter,
 				    0, name,
@@ -814,21 +812,21 @@
 	GFile            *options_dir;
 	GFile            *options_file;
 	GError           *error = NULL;
-	
+
 	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (aod_data->aod_treeview));
 	if (! gtk_tree_selection_get_selected (selection, NULL, &iter))
 		return;
 
 	gtk_tree_model_get (aod_data->aod_model, &iter, 1, &filename, -1);
 	gtk_list_store_remove (GTK_LIST_STORE (aod_data->aod_model), &iter);
-		
+
 	options_dir = get_home_relative_file (RC_OPTIONS_DIR);
 	options_file = g_file_get_child (options_dir, filename);
 	if (! g_file_delete (options_file, NULL, &error)) {
 		g_warning ("could not delete the options: %s", error->message);
 		g_clear_error (&error);
 	}
-	
+
 	g_object_unref (options_file);
 	g_object_unref (options_dir);
 	g_free (filename);
@@ -948,8 +946,8 @@
 	options_file = g_file_get_child_for_display_name (options_dir, opt_filename, NULL);
 	dlg_add_folder_save_current_options (data, options_file);
 	dlg_add_folder_save_last_used_options (data, opt_filename);
-	
+
 	g_free (opt_filename);
 	g_object_unref (options_file);
-	g_object_unref (options_dir);	
+	g_object_unref (options_dir);
 }

Modified: trunk/src/dlg-prop.c
==============================================================================
--- trunk/src/dlg-prop.c	(original)
+++ trunk/src/dlg-prop.c	Fri Jul 18 17:14:12 2008
@@ -160,7 +160,7 @@
 	uncompressed_size = 0;
 	if (fr_window_archive_is_present (window)) {
 		int i;
-		
+
 		for (i = 0; i < window->archive->command->files->len; i++) {
 			FileData *fd = g_ptr_array_index (window->archive->command->files, i);
 			uncompressed_size += fd->size;
@@ -193,7 +193,7 @@
 	set_label (label_label, _("Number of files:"));
 
 	label = glade_xml_get_widget (data->gui, "p_files_label");
-	s = g_strdup_printf ("%d", window->archive->command->files->len);
+	s = g_strdup_printf ("%d", window->archive->command->n_regular_files);
 	gtk_label_set_text (GTK_LABEL (label), s);
 	g_free (s);
 

Modified: trunk/src/fr-archive.c
==============================================================================
--- trunk/src/fr-archive.c	(original)
+++ trunk/src/fr-archive.c	Fri Jul 18 17:14:12 2008
@@ -169,6 +169,7 @@
 	PROGRESS,
 	MESSAGE,
 	STOPPABLE,
+	WORKING_ARCHIVE,
 	LAST_SIGNAL
 };
 
@@ -261,12 +262,22 @@
 			      fr_marshal_VOID__BOOL,
 			      G_TYPE_NONE,
 			      1, G_TYPE_BOOLEAN);
+	fr_archive_signals[WORKING_ARCHIVE] =
+			g_signal_new ("working_archive",
+				      G_TYPE_FROM_CLASS (class),
+				      G_SIGNAL_RUN_LAST,
+				      G_STRUCT_OFFSET (FrArchiveClass, working_archive),
+				      NULL, NULL,
+				      fr_marshal_VOID__STRING,
+				      G_TYPE_NONE, 1,
+				      G_TYPE_STRING);
 
 	gobject_class->finalize = fr_archive_finalize;
 	class->start = NULL;
 	class->done = NULL;
 	class->progress = NULL;
 	class->message = NULL;
+	class->working_archive = NULL;
 }
 
 
@@ -511,9 +522,9 @@
 		const char *first_bytes;
 		int         offset;
 		int         len;
-	} sniffer_data [] = {	
-		/* Magic numbers taken from magic/Magdir/archive from the 
-		 * file-4.21 tarball. */	
+	} sniffer_data [] = {
+		/* Magic numbers taken from magic/Magdir/archive from the
+		 * file-4.21 tarball. */
 		{ "application/x-ace", "**ACE**", 7, 7 },
 		{ "application/x-arj", "\x60\xea", 0, 2 },
 		{ "application/x-rar", "Rar!", 0, 4 },
@@ -530,15 +541,15 @@
 	istream = g_file_read (file, NULL, NULL);
 	if (istream == NULL)
 		return NULL;
-	
+
 	n = g_input_stream_read (G_INPUT_STREAM (istream), buffer, sizeof (buffer), NULL, NULL);
 	g_object_unref (istream);
-	if (n < 0)		
+	if (n < 0)
 		return NULL;
-	
-	for (i = 0; sniffer_data[i].mime_type != NULL; i++) 
-		if (memcmp (sniffer_data[i].first_bytes, 
-			    buffer + sniffer_data[i].offset, 
+
+	for (i = 0; sniffer_data[i].mime_type != NULL; i++)
+		if (memcmp (sniffer_data[i].first_bytes,
+			    buffer + sniffer_data[i].offset,
 			    sniffer_data[i].len) == 0)
 		{
 			return sniffer_data[i].mime_type;
@@ -938,6 +949,45 @@
 }
 
 
+static gboolean
+archive_working_archive_cb  (FrCommand  *command,
+			     const char *archive_filename,
+			     FrArchive  *archive)
+{
+	g_signal_emit (G_OBJECT (archive),
+		       fr_archive_signals[WORKING_ARCHIVE],
+		       0,
+		       archive_filename);
+	return TRUE;
+}
+
+
+static void
+fr_archive_connect_to_command (FrArchive *archive)
+{
+	g_signal_connect (G_OBJECT (archive->command),
+			  "start",
+			  G_CALLBACK (action_started),
+			  archive);
+	g_signal_connect (G_OBJECT (archive->command),
+			  "done",
+			  G_CALLBACK (action_performed),
+			  archive);
+	g_signal_connect (G_OBJECT (archive->command),
+			  "progress",
+			  G_CALLBACK (archive_progress_cb),
+			  archive);
+	g_signal_connect (G_OBJECT (archive->command),
+			  "message",
+			  G_CALLBACK (archive_message_cb),
+			  archive);
+	g_signal_connect (G_OBJECT (archive->command),
+			  "working_archive",
+			  G_CALLBACK (archive_working_archive_cb),
+			  archive);
+}
+
+
 gboolean
 fr_archive_create (FrArchive  *archive,
 		   const char *uri)
@@ -963,25 +1013,9 @@
 		g_object_unref (G_OBJECT (tmp_command));
 	}
 
+	fr_archive_connect_to_command (archive);
 	archive->read_only = FALSE;
 
-	g_signal_connect (G_OBJECT (archive->command),
-			  "start",
-			  G_CALLBACK (action_started),
-			  archive);
-	g_signal_connect (G_OBJECT (archive->command),
-			  "done",
-			  G_CALLBACK (action_performed),
-			  archive);
-	g_signal_connect (G_OBJECT (archive->command),
-			  "progress",
-			  G_CALLBACK (archive_progress_cb),
-			  archive);
-	g_signal_connect (G_OBJECT (archive->command),
-			  "message",
-			  G_CALLBACK (archive_message_cb),
-			  archive);
-
 	return TRUE;
 }
 
@@ -1043,28 +1077,10 @@
 		g_object_unref (tmp_command);
 	}
 
+	fr_archive_connect_to_command (archive);
 	archive->content_type = mime_type;
-
 	if (! fr_command_is_capable_of (archive->command, FR_COMMAND_CAN_WRITE))
 		archive->read_only = TRUE;
-
-	g_signal_connect (G_OBJECT (archive->command),
-			  "start",
-			  G_CALLBACK (action_started),
-			  archive);
-	g_signal_connect (G_OBJECT (archive->command),
-			  "done",
-			  G_CALLBACK (action_performed),
-			  archive);
-	g_signal_connect (G_OBJECT (archive->command),
-			  "progress",
-			  G_CALLBACK (archive_progress_cb),
-			  archive);
-	g_signal_connect (G_OBJECT (archive->command),
-			  "message",
-			  G_CALLBACK (archive_message_cb),
-			  archive);
-
 	fr_archive_stoppable (archive, TRUE);
 	archive->command->fake_load = fr_archive_fake_load (archive);
 
@@ -1472,6 +1488,7 @@
 	}
 
 	/* add now. */
+
 	fr_command_set_n_files (archive->command, g_list_length (new_file_list));
 
 	for (scan = new_file_list; scan != NULL; ) {
@@ -1761,7 +1778,7 @@
 				     FR_PROC_ERROR_NONE,
 				     NULL);
 
-	if (file_list != NULL) {
+	if (file_list != NULL)
 		fr_archive_add_files (aww_data->archive,
 				      file_list,
 				      aww_data->source_dir,
@@ -1770,9 +1787,9 @@
 				      aww_data->password,
 				      aww_data->encrypt_header,
 				      aww_data->compression);
-		path_list_free (file_list);
-	}
 
+	path_list_free (file_list);
+	path_list_free (dirs_list);
 	add_with_wildcard_data_free (aww_data);
 }
 
@@ -2612,7 +2629,7 @@
 	}
 
 	if (extract_all && (file_list == NULL))
-		fr_command_set_n_files (archive->command, archive->command->files->len);
+		fr_command_set_n_files (archive->command, archive->command->n_regular_files);
 	else
 		fr_command_set_n_files (archive->command, g_list_length (file_list));
 

Modified: trunk/src/fr-archive.h
==============================================================================
--- trunk/src/fr-archive.h	(original)
+++ trunk/src/fr-archive.h	Fri Jul 18 17:14:12 2008
@@ -73,17 +73,19 @@
 
 	/* -- Signals -- */
 
-	void (*start)     (FrArchive   *archive,
-			   FrAction     action);
-	void (*done)      (FrArchive   *archive,
-			   FrAction     action,
-			   FrProcError *error);
-	void (*progress)  (FrArchive   *archive,
-			   double       fraction);
-	void (*message)   (FrArchive   *archive,
-			   const char  *msg);
-	void (*stoppable) (FrArchive   *archive,
-			   gboolean     value);
+	void (*start)            (FrArchive   *archive,
+			          FrAction     action);
+	void (*done)             (FrArchive   *archive,
+			          FrAction     action,
+			          FrProcError *error);
+	void (*progress)         (FrArchive   *archive,
+			          double       fraction);
+	void (*message)          (FrArchive   *archive,
+			          const char  *msg);
+	void (*stoppable)        (FrArchive   *archive,
+			          gboolean     value);
+	void (*working_archive)  (FrCommand   *comm,
+			          const char  *filename);
 };
 
 GType       fr_archive_get_type                  (void);

Modified: trunk/src/fr-command-rar.c
==============================================================================
--- trunk/src/fr-command-rar.c	(original)
+++ trunk/src/fr-command-rar.c	Fri Jul 18 17:14:12 2008
@@ -20,17 +20,20 @@
  *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
  */
 
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
 
 #include <glib.h>
+#include <glib/gi18n.h>
 
 #include "file-data.h"
 #include "file-utils.h"
 #include "glib-utils.h"
 #include "fr-command.h"
 #include "fr-command-rar.h"
+#include "fr-error.h"
 
 static void fr_command_rar_class_init  (FrCommandRarClass *class);
 static void fr_command_rar_init        (FrCommand         *afile);
@@ -205,6 +208,7 @@
 		fr_process_begin_command (comm->process, "unrar");
 	fr_process_add_arg (comm->process, "v");
 	fr_process_add_arg (comm->process, "-c-");
+	fr_process_add_arg (comm->process, "-v");
 
 	add_password_arg (comm, password, TRUE);
 
@@ -217,6 +221,57 @@
 }
 
 
+static char Progress_Message[4196];
+static char Progress_Filename[4096];
+
+
+static void
+parse_progress_line (FrCommand  *comm,
+		     const char *prefix,
+		     const char *message_prefix,
+		     const char *line)
+{
+	int prefix_len;
+
+	prefix_len = strlen (prefix);
+	if (strncmp (line, prefix, prefix_len) == 0) {
+		double fraction;
+		int    len;
+
+		strcpy (Progress_Filename, line + prefix_len);
+		len = strlen (Progress_Filename);
+		if ((len > 5) && (strncmp (Progress_Filename + len - 5, "  OK ", 5) == 0))
+			Progress_Filename[len - 5] = 0;
+		sprintf (Progress_Message, "%s%s", message_prefix, file_name_from_path (Progress_Filename));
+		fr_command_message (comm, Progress_Message);
+
+		fraction= (double) ++comm->n_file / (comm->n_files + 1);
+		fr_command_progress (comm, fraction);
+	}
+}
+
+
+static void
+process_line__add (char     *line,
+		   gpointer  data)
+{
+	FrCommand *comm = FR_COMMAND (data);
+
+	if (strncmp (line, "Creating archive ", 17) == 0) {
+		char *uri;
+
+		uri = g_filename_to_uri (line + 17, NULL, NULL);
+		fr_command_working_archive (comm, uri);
+		g_free (uri);
+
+		return;
+	}
+
+	if (comm->n_files != 0)
+		parse_progress_line (comm, "Adding    ", _("Adding file: "), line);
+}
+
+
 static void
 fr_command_rar_add (FrCommand     *comm,
 		    GList         *file_list,
@@ -228,6 +283,11 @@
 {
 	GList *scan;
 
+	fr_process_use_standard_locale (comm->process, TRUE);
+	fr_process_set_out_line_func (comm->process,
+				      process_line__add,
+				      comm);
+
 	fr_process_begin_command (comm->process, "rar");
 
 	if (base_dir != NULL)
@@ -267,11 +327,37 @@
 
 
 static void
+process_line__delete (char     *line,
+		      gpointer  data)
+{
+	FrCommand *comm = FR_COMMAND (data);
+
+	if (strncmp (line, "Deleting from ", 14) == 0) {
+		char *uri;
+
+		uri = g_filename_to_uri (line + 14, NULL, NULL);
+		fr_command_working_archive (comm, uri);
+		g_free (uri);
+
+		return;
+	}
+
+	if (comm->n_files != 0)
+		parse_progress_line (comm, "Deleting ", _("Removing file: "), line);
+}
+
+
+static void
 fr_command_rar_delete (FrCommand *comm,
 		       GList     *file_list)
 {
 	GList *scan;
 
+	fr_process_use_standard_locale (comm->process, TRUE);
+	fr_process_set_out_line_func (comm->process,
+				      process_line__delete,
+				      comm);
+
 	fr_process_begin_command (comm->process, "rar");
 	fr_process_add_arg (comm->process, "d");
 
@@ -287,6 +373,27 @@
 
 
 static void
+process_line__extract (char     *line,
+		       gpointer  data)
+{
+	FrCommand *comm = FR_COMMAND (data);
+
+	if (strncmp (line, "Extracting from ", 16) == 0) {
+		char *uri;
+
+		uri = g_filename_to_uri (line + 16, NULL, NULL);
+		fr_command_working_archive (comm, uri);
+		g_free (uri);
+
+		return;
+	}
+
+	if (comm->n_files != 0)
+		parse_progress_line (comm, "Extracting  ", _("Extracting file: "), line);
+}
+
+
+static void
 fr_command_rar_extract (FrCommand  *comm,
 			GList      *file_list,
 			const char *dest_dir,
@@ -297,6 +404,11 @@
 {
 	GList *scan;
 
+	fr_process_use_standard_locale (comm->process, TRUE);
+	fr_process_set_out_line_func (comm->process,
+				      process_line__extract,
+				      comm);
+
 	if (have_rar ())
 		fr_process_begin_command (comm->process, "rar");
 	else
@@ -363,25 +475,43 @@
 fr_command_rar_handle_error (FrCommand   *comm,
 			     FrProcError *error)
 {
+	GList *scan;
+
+#if 0
+	{
+		GList *scan;
+
+		for (scan = g_list_last (comm->process->err.raw); scan; scan = scan->prev)
+			g_print ("%s\n", (char*)scan->data);
+	}
+#endif
+
 	if (error->type != FR_PROC_ERROR_COMMAND_ERROR)
 		return;
 
-	if (error->status == 3) {
+	if (error->status == 3)
 		error->type = FR_PROC_ERROR_ASK_PASSWORD;
-	}
-	else {
-		GList *scan;
+	else if (error->status <= 1)
+		error->type = FR_PROC_ERROR_NONE;
+
+	for (scan = g_list_last (comm->process->err.raw); scan; scan = scan->prev) {
+		char *line = scan->data;
+
+		if (strstr (line, "password incorrect") != NULL) {
+			error->type = FR_PROC_ERROR_ASK_PASSWORD;
+			break;
+		}
 
-		if (error->status <= 1)
-			error->type = FR_PROC_ERROR_NONE;
+		if (strncmp (line, "Cannot find volume", 18) == 0) {
+			char *volume_filename;
 
-		for (scan = g_list_last (comm->process->err.raw); scan; scan = scan->prev) {
-			char *line = scan->data;
+			g_clear_error (&error->gerror);
 
-			if (strstr (line, "password incorrect") != NULL) {
-				error->type = FR_PROC_ERROR_ASK_PASSWORD;
-				break;
-			}
+			error->type = FR_PROC_ERROR_MISSING_VOLUME;
+			volume_filename = g_path_get_basename (line + strlen ("Cannot find volume "));
+			error->gerror = g_error_new (FR_ERROR, error->status, _("Could not find the volume: %s"), volume_filename);
+			g_free (volume_filename);
+			break;
 		}
 	}
 }

Modified: trunk/src/fr-command.c
==============================================================================
--- trunk/src/fr-command.c	(original)
+++ trunk/src/fr-command.c	Fri Jul 18 17:14:12 2008
@@ -39,6 +39,7 @@
 	DONE,
 	PROGRESS,
 	MESSAGE,
+	WORKING_ARCHIVE,
 	LAST_SIGNAL
 };
 
@@ -379,6 +380,15 @@
 			      fr_marshal_VOID__STRING,
 			      G_TYPE_NONE, 1,
 			      G_TYPE_STRING);
+	fr_command_signals[WORKING_ARCHIVE] =
+			g_signal_new ("working_archive",
+				      G_TYPE_FROM_CLASS (class),
+				      G_SIGNAL_RUN_LAST,
+				      G_STRUCT_OFFSET (FrCommandClass, working_archive),
+				      NULL, NULL,
+				      fr_marshal_VOID__STRING,
+				      G_TYPE_NONE, 1,
+				      G_TYPE_STRING);
 
 	/* properties */
 
@@ -469,26 +479,27 @@
 		comm->e_filename = NULL;
 	}
 
-	if (filename == NULL)
-		return;
+	if (filename != NULL) {
+		if (! g_path_is_absolute (filename)) {
+			char *current_dir;
+
+			current_dir = g_get_current_dir ();
+			comm->filename = g_strconcat (current_dir,
+						      "/",
+						      filename,
+						      NULL);
+			g_free (current_dir);
+		}
+		else
+			comm->filename = g_strdup (filename);
 
-	if (! g_path_is_absolute (filename)) {
-		char *current_dir;
+		comm->e_filename = g_shell_quote (comm->filename);
 
-		current_dir = g_get_current_dir ();
-		comm->filename = g_strconcat (current_dir,
-					      "/",
-					      filename,
-					      NULL);
-		g_free (current_dir);
+		debug (DEBUG_INFO, "filename : %s\n", comm->filename);
+		debug (DEBUG_INFO, "e_filename : %s\n", comm->e_filename);
 	}
-	else
-		comm->filename = g_strdup (filename);
-
-	comm->e_filename = g_shell_quote (comm->filename);
 
-	debug (DEBUG_INFO, "filename : %s\n", comm->filename);
-	debug (DEBUG_INFO, "e_filename : %s\n", comm->e_filename);
+	fr_command_working_archive (comm, comm->filename);
 }
 
 
@@ -664,6 +675,17 @@
 
 
 void
+fr_command_working_archive (FrCommand  *comm,
+		            const char *archive_name)
+{
+	g_signal_emit (G_OBJECT (comm),
+		       fr_command_signals[WORKING_ARCHIVE],
+		       0,
+		       archive_name);
+}
+
+
+void
 fr_command_set_n_files (FrCommand *comm,
 			int        n_files)
 {
@@ -678,6 +700,8 @@
 {
 	file_data_update_content_type (fdata);
 	g_ptr_array_add (comm->files, fdata);
+	if (! fdata->dir)
+		comm->n_regular_files++;
 }
 
 

Modified: trunk/src/fr-command.h
==============================================================================
--- trunk/src/fr-command.h	(original)
+++ trunk/src/fr-command.h	Fri Jul 18 17:14:12 2008
@@ -66,6 +66,7 @@
 	GObject  __parent;
 
 	GPtrArray  *files;           /* Array of FileData* */
+	int         n_regular_files;
 
 	/*<protected>*/
 
@@ -154,6 +155,8 @@
 				           double       fraction);
 	void          (*message)          (FrCommand   *comm,
 				           const char  *msg);
+	void          (*working_archive)  (FrCommand   *comm,
+					   const char  *filename);
 };
 
 GType          fr_command_get_type           (void);
@@ -199,6 +202,8 @@
 					      double         fraction);
 void           fr_command_message            (FrCommand     *comm,
 					      const char    *msg);
+void           fr_command_working_archive    (FrCommand     *comm,
+		                              const char    *archive_name);
 void           fr_command_set_n_files        (FrCommand     *comm,
 					      int            n_files);
 void           fr_command_add_file           (FrCommand     *comm,

Modified: trunk/src/fr-window.c
==============================================================================
--- trunk/src/fr-window.c	(original)
+++ trunk/src/fr-window.c	Fri Jul 18 17:14:12 2008
@@ -368,6 +368,7 @@
 	guint             hide_progress_timeout;  /* Timeout to hide the progress dialog. */
 	FrAction          pd_last_action;
 	char             *pd_last_archive;
+	char             *working_archive;
 
 	/* update dialog data */
 
@@ -2311,13 +2312,64 @@
 }
 
 
+static void
+pd_update_archive_name (FrWindow *window)
+{
+	char *current_archive;
+
+	if (window->priv->convert_data.converting)
+		current_archive = window->priv->convert_data.new_file;
+	else if (window->priv->working_archive != NULL)
+		current_archive = window->priv->working_archive;
+	else
+		current_archive = window->priv->archive_uri;
+
+	if (strcmp_null_tolerant (window->priv->pd_last_archive, current_archive) != 0) {
+		g_free (window->priv->pd_last_archive);
+		if (current_archive == NULL) {
+			window->priv->pd_last_archive = NULL;
+			gtk_label_set_text (GTK_LABEL (window->priv->pd_archive), "");
+#ifdef LOG_PROGRESS
+			g_print ("archive name > (none)\n");
+#endif
+		}
+		else {
+			char *name;
+
+			window->priv->pd_last_archive = g_strdup (current_archive);
+
+			name = g_uri_display_basename (window->priv->pd_last_archive);
+			gtk_label_set_text (GTK_LABEL (window->priv->pd_archive), name);
+#ifdef LOG_PROGRESS
+			g_print ("archive name > %s\n", name);
+#endif
+			g_free (name);
+		}
+	}
+
+}
+
+
+static gboolean
+fr_window_working_archive_cb (FrCommand  *command,
+		              const char *archive_filename,
+		              FrWindow   *window)
+{
+	g_free (window->priv->working_archive);
+	window->priv->working_archive = NULL;
+	if (archive_filename != NULL)
+		window->priv->working_archive = g_strdup (archive_filename);
+	pd_update_archive_name (window);
+
+	return TRUE;
+}
+
+
 static gboolean
 fr_window_message_cb (FrCommand  *command,
 		      const char *msg,
 		      FrWindow   *window)
 {
-	char *current_archive;
-
 	if (window->priv->progress_dialog == NULL)
 		return TRUE;
 
@@ -2343,6 +2395,9 @@
 
 		if (g_utf8_validate (utf8_msg, -1, NULL))
 			gtk_label_set_text (GTK_LABEL (window->priv->pd_message), utf8_msg);
+#ifdef LOG_PROGRESS
+		g_print ("message > %s\n", utf8_msg);
+#endif
 		g_free (utf8_msg);
 	}
 
@@ -2353,27 +2408,7 @@
 	else if (window->priv->pd_last_action != window->priv->action)
 		progress_dialog__set_last_action (window, window->priv->action);
 
-	if (window->priv->convert_data.converting)
-		current_archive = window->priv->convert_data.new_file;
-	else
-		current_archive = window->priv->archive_uri;
-
-	if (strcmp_null_tolerant (window->priv->pd_last_archive, current_archive) != 0) {
-		g_free (window->priv->pd_last_archive);
-		if (current_archive == NULL) {
-			window->priv->pd_last_archive = NULL;
-			gtk_label_set_text (GTK_LABEL (window->priv->pd_archive), "");
-		}
-		else {
-			char *name;
-
-			window->priv->pd_last_archive = g_strdup (current_archive);
-
-			name = g_uri_display_basename (window->priv->pd_last_archive);
-			gtk_label_set_text (GTK_LABEL (window->priv->pd_archive), name);
-			g_free (name);
-		}
-	}
+	pd_update_archive_name (window);
 
 	return TRUE;
 }
@@ -2585,6 +2620,9 @@
 		if (window->priv->progress_dialog != NULL)
 			gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (window->priv->pd_progress_bar), fraction);
 		gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (window->priv->progress_bar), fraction);
+#ifdef LOG_PROGRESS
+		g_print ("progress > %2.2f\n", fraction);
+#endif
 	}
 	return TRUE;
 }
@@ -4906,6 +4944,11 @@
 fr_window_fake_load (FrArchive *archive,
 		     gpointer   data)
 {
+	/* fake loads are disabled to allow exact progress dialogs (#153281) */
+
+	return FALSE;
+
+#if 0
 	FrWindow *window = data;
 	gboolean  add_after_opening = FALSE;
 	gboolean  extract_after_opening = FALSE;
@@ -4929,7 +4972,8 @@
 		}
 		if ((action->type == FR_BATCH_ACTION_EXTRACT)
 		    || (action->type == FR_BATCH_ACTION_EXTRACT_HERE)
-		    || (action->type == FR_BATCH_ACTION_EXTRACT_INTERACT)) {
+		    || (action->type == FR_BATCH_ACTION_EXTRACT_INTERACT))
+		{
 			extract_after_opening = TRUE;
 			break;
 		}
@@ -4942,6 +4986,7 @@
 		&& ! (add_after_opening && window->priv->update_dropped_files && ! archive->command->propAddCanUpdate)
 		&& ! (add_after_opening && ! window->priv->update_dropped_files && ! archive->command->propAddCanReplace)
 		&& ! (extract_after_opening && !archive->command->propCanExtractAll));
+#endif
 }
 
 
@@ -5302,6 +5347,10 @@
 			  "stoppable",
 			  G_CALLBACK (fr_window_stoppable_cb),
 			  window);
+	g_signal_connect (G_OBJECT (window->archive),
+			  "working_archive",
+			  G_CALLBACK (fr_window_working_archive_cb),
+			  window);
 
 	fr_archive_set_fake_load_func (window->archive,
 				       fr_window_fake_load,

Modified: trunk/src/gtk-utils.c
==============================================================================
--- trunk/src/gtk-utils.c	(original)
+++ trunk/src/gtk-utils.c	Fri Jul 18 17:14:12 2008
@@ -386,7 +386,7 @@
 	GtkWidget     *vbox;
 	GtkWidget     *text_view;
 	GtkWidget     *scrolled = NULL;
-	GtkWidget     *button;
+	GtkWidget     *expander;
 	GtkTextBuffer *text_buf;
 	GtkTextIter    iter;
 	char          *stock_id;
@@ -431,7 +431,7 @@
 		va_end (args);
 		escaped_secondary_message = g_markup_escape_text (secondary_message, -1);
 
-		markup_text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
+		markup_text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s\n",
 					       escaped_message,
 					       escaped_secondary_message);
 
@@ -445,9 +445,9 @@
 	g_free (escaped_message);
 
 	if (view_output) {
-		/* Button */
+		/* Expander */
 
-		button = gtk_toggle_button_new_with_mnemonic (_("Command _Line Output"));
+		expander = gtk_expander_new_with_mnemonic (_("Command _Line Output"));
 
 		/* Add text */
 
@@ -487,40 +487,22 @@
 	vbox = gtk_vbox_new (FALSE, 6);
 	gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
 
-	hbox = gtk_hbox_new (FALSE, 6);
-	gtk_box_pack_start (GTK_BOX (hbox), image,
-			    FALSE, FALSE, 0);
-	gtk_box_pack_start (GTK_BOX (hbox), label,
-			    FALSE, FALSE, 0);
-	gtk_box_pack_start (GTK_BOX (vbox), hbox,
-			    TRUE, TRUE, 0);
+	hbox = gtk_hbox_new (FALSE, 12);
+	gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
+	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+	gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
 
 	if (view_output) {
-		hbox = gtk_hbox_new (FALSE, 6);
-		gtk_box_pack_start (GTK_BOX (hbox), button,
-			    FALSE, FALSE, 0);
-		gtk_box_pack_start (GTK_BOX (vbox), hbox,
-				    TRUE, TRUE, 0);
-
 		gtk_container_add (GTK_CONTAINER (scrolled), text_view);
-		gtk_box_pack_start (GTK_BOX (vbox), scrolled,
-				    FALSE, FALSE, 0);
-
-		g_signal_connect_swapped (G_OBJECT (button),
-					  "clicked",
-					  G_CALLBACK (toggle_visibility),
-					  scrolled);
+		gtk_container_add (GTK_CONTAINER (expander), scrolled);
+		gtk_box_pack_start (GTK_BOX (vbox), expander, TRUE, TRUE, 0);
 	}
 
 	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
 			    vbox,
 			    FALSE, FALSE, 0);
-
 	gtk_widget_show_all (vbox);
 
-	if (scrolled != NULL)
-		gtk_widget_hide (scrolled);
-
 	return dialog;
 }
 

Modified: trunk/src/typedefs.h
==============================================================================
--- trunk/src/typedefs.h	(original)
+++ trunk/src/typedefs.h	Fri Jul 18 17:14:12 2008
@@ -60,7 +60,8 @@
 	FR_PROC_ERROR_EXITED_ABNORMALLY,
 	FR_PROC_ERROR_SPAWN,
 	FR_PROC_ERROR_STOPPED,
-	FR_PROC_ERROR_ASK_PASSWORD
+	FR_PROC_ERROR_ASK_PASSWORD,
+	FR_PROC_ERROR_MISSING_VOLUME
 } FrProcErrorType;
 
 typedef struct {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]