[file-roller] fixed progress dialog for commands



commit 892a8eb8b06db10e8e8dbc75230abfdd12d79112
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Mon Aug 6 22:59:45 2012 +0200

    fixed progress dialog for commands
    
    use n_files+1 only when calculating the progress fraction or we get
    a wrong text message in the progress dialog.

 src/fr-archive.c     |    4 ++--
 src/fr-command-rar.c |    2 +-
 src/fr-command.c     |   20 +++++---------------
 3 files changed, 8 insertions(+), 18 deletions(-)
---
diff --git a/src/fr-archive.c b/src/fr-archive.c
index 3e7a5b6..154efb9 100644
--- a/src/fr-archive.c
+++ b/src/fr-archive.c
@@ -2040,7 +2040,7 @@ _set_completed_bytes (FrArchive *self,
 
 	self->priv->completed_bytes = completed_bytes;
 	if (self->priv->total_bytes > 0)
-		fraction = (double) self->priv->completed_bytes / (self->priv->total_bytes + 1);
+		fraction = (double) self->priv->completed_bytes / self->priv->total_bytes;
 	else
 		fraction = 0.0;
 	/*g_print ("%" G_GSIZE_FORMAT " / %" G_GSIZE_FORMAT "  : %f\n", self->priv->completed_bytes, self->priv->total_bytes + 1, fraction);*/
@@ -2083,7 +2083,7 @@ fr_archive_progress_get_fraction (FrArchive *self)
 
 	g_mutex_lock (&self->priv->progress_mutex);
 	if ((self->priv->total_bytes > 0) && (self->priv->completed_bytes > 0))
-		fraction = (double) self->priv->completed_bytes / (self->priv->total_bytes + 1);
+		fraction = (double) self->priv->completed_bytes / self->priv->total_bytes;
 	else if ((self->priv->total_files > 0) && (self->priv->completed_files > 0))
 		fraction = (double) self->priv->completed_files / (self->priv->total_files + 1);
 	else
diff --git a/src/fr-command-rar.c b/src/fr-command-rar.c
index a0731c7..7a4fe0d 100644
--- a/src/fr-command-rar.c
+++ b/src/fr-command-rar.c
@@ -258,7 +258,7 @@ parse_progress_line (FrCommand  *comm,
 
 	prefix_len = strlen (prefix);
 	if (strncmp (line, prefix, prefix_len) == 0) {
-		if (fr_archive_progress_get_total_files (archive) > 1) {
+		if (fr_archive_progress_get_total_files (archive) > 0) {
 			fr_archive_progress (archive, fr_archive_progress_inc_completed_files (archive, 1));
 		}
 		else {
diff --git a/src/fr-command.c b/src/fr-command.c
index fa3fe91..570ab2d 100644
--- a/src/fr-command.c
+++ b/src/fr-command.c
@@ -958,16 +958,6 @@ split_in_chunks (GList *file_list)
 }
 
 
-/* this is because the fr_archive_progress_inc_completed_files function is
- * called *before* the file is actually added/removed from the archive, adding
- * 1 to the totale we get for example a 50% (instead of 100%) progress when
- * adding a single file. */
-static int
-get_length_for_progress (int l)
-{
-	return (l > 0) ? l + 1 : 0;
-}
-
 static gboolean
 _fr_command_add (FrCommand      *self,
 		 GList          *file_list,
@@ -1120,7 +1110,7 @@ _fr_command_add (FrCommand      *self,
 	/* add now. */
 
 	new_file_list_length = g_list_length (new_file_list);
-	fr_archive_progress_set_total_files (archive, get_length_for_progress (new_file_list_length));
+	fr_archive_progress_set_total_files (archive, new_file_list_length);
 
 	if (archive->propListFromFile && (new_file_list_length > LIST_LENGTH_TO_USE_FILE)) {
 		char   *list_dir;
@@ -1613,7 +1603,7 @@ delete_from_archive (FrCommand *self,
 		g_list_free (file_list);
 
 	tmp_file_list_length = g_list_length (tmp_file_list);
-	fr_archive_progress_set_total_files (archive, get_length_for_progress (tmp_file_list_length));
+	fr_archive_progress_set_total_files (archive, tmp_file_list_length);
 
 	if (archive->propListFromFile && (tmp_file_list_length > LIST_LENGTH_TO_USE_FILE)) {
 		char *list_dir;
@@ -2166,9 +2156,9 @@ _fr_command_extract (FrCommand  *self,
 	}
 
 	if (extract_all && (file_list == NULL))
-		fr_archive_progress_set_total_files (archive, get_length_for_progress (archive->files->len));
+		fr_archive_progress_set_total_files (archive, archive->files->len);
 	else
-		fr_archive_progress_set_total_files (archive, get_length_for_progress (g_list_length (file_list)));
+		fr_archive_progress_set_total_files (archive, g_list_length (file_list));
 
 	if (all_options_supported) {
 		gboolean created_filtered_list = FALSE;
@@ -2499,7 +2489,7 @@ fr_command_test_integrity (FrArchive           *archive,
 		      "filename", self->priv->local_copy,
 		      "password", password,
 		      NULL);
-	fr_archive_progress_set_total_files (archive, get_length_for_progress (0));
+	fr_archive_progress_set_total_files (archive, 0);
 
 	fr_process_clear (self->process);
 	fr_command_test (self);



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