[file-roller] progress dialog: show the number of remaining files to complete the operation
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] progress dialog: show the number of remaining files to complete the operation
- Date: Tue, 19 Jun 2012 18:40:33 +0000 (UTC)
commit bf2b5d2352cfcd9d4345dda7976208672838dce1
Author: Paolo Bacchilega <paobac src gnome org>
Date: Mon Jun 18 18:15:08 2012 +0200
progress dialog: show the number of remaining files to complete the operation
...instead of the name of the file added/removed/extracted.
src/fr-command-7z.c | 16 ++--------------
src/fr-command-rar.c | 33 ++-------------------------------
src/fr-command-tar.c | 10 +++++-----
src/fr-command-zip.c | 4 ++--
src/fr-window.c | 28 +++++++++++++++++++++++++---
5 files changed, 36 insertions(+), 55 deletions(-)
---
diff --git a/src/fr-command-7z.c b/src/fr-command-7z.c
index 675651c..afbcb21 100644
--- a/src/fr-command-7z.c
+++ b/src/fr-command-7z.c
@@ -253,10 +253,6 @@ fr_command_7z_list (FrCommand *comm)
}
-static char Progress_Message[4196];
-static char Progress_Filename[4096];
-
-
static void
parse_progress_line (FrCommand *comm,
const char *prefix,
@@ -266,16 +262,8 @@ parse_progress_line (FrCommand *comm,
int prefix_len;
prefix_len = strlen (prefix);
- if (strncmp (line, prefix, prefix_len) == 0) {
- double fraction;
-
- strcpy (Progress_Filename, line + prefix_len);
- 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);
- }
+ if (strncmp (line, prefix, prefix_len) == 0)
+ fr_command_progress (comm, (double) ++comm->n_file / (comm->n_files + 1));
}
diff --git a/src/fr-command-rar.c b/src/fr-command-rar.c
index 36238e4..bc9f154 100644
--- a/src/fr-command-rar.c
+++ b/src/fr-command-rar.c
@@ -253,43 +253,14 @@ fr_command_rar_list (FrCommand *comm)
}
-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;
- char *b_idx;
-
- strcpy (Progress_Filename, line + prefix_len);
-
- /* when a new volume is created a sequence of backspaces is
- * issued, remove the backspaces from the filename */
- b_idx = strchr (Progress_Filename, '\x08');
- if (b_idx != NULL)
- *b_idx = 0;
-
- /* remove the OK at the end of the filename */
- 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);
- }
+ if (strncmp (line, prefix, strlen (prefix)) == 0)
+ fr_command_progress (comm, (double) ++comm->n_file / (comm->n_files + 1));
}
diff --git a/src/fr-command-tar.c b/src/fr-command-tar.c
index a7aeda5..1feb2a3 100644
--- a/src/fr-command-tar.c
+++ b/src/fr-command-tar.c
@@ -280,7 +280,6 @@ process_line__generic (char *line,
char *action_msg)
{
FrCommand *comm = FR_COMMAND (data);
- char *msg;
if (line == NULL)
return;
@@ -288,14 +287,15 @@ process_line__generic (char *line,
if (line[strlen (line) - 1] == '/') /* ignore directories */
return;
- msg = g_strconcat (action_msg, file_name_from_path (line), NULL);
- fr_command_message (comm, msg);
- g_free (msg);
-
if (comm->n_files != 0) {
double fraction = (double) ++comm->n_file / (comm->n_files + 1);
fr_command_progress (comm, fraction);
}
+ else {
+ char *msg = g_strconcat (action_msg, file_name_from_path (line), NULL);
+ fr_command_message (comm, msg);
+ g_free (msg);
+ }
}
diff --git a/src/fr-command-zip.c b/src/fr-command-zip.c
index f58b16c..ded5624 100644
--- a/src/fr-command-zip.c
+++ b/src/fr-command-zip.c
@@ -205,12 +205,12 @@ process_line__common (char *line,
if (line == NULL)
return;
- fr_command_message (comm, line);
-
if (comm->n_files != 0) {
double fraction = (double) ++comm->n_file / (comm->n_files + 1);
fr_command_progress (comm, fraction);
}
+ else
+ fr_command_message (comm, line);
}
diff --git a/src/fr-window.c b/src/fr-window.c
index 205ea60..aa5658c 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -2686,9 +2686,9 @@ open_progress_dialog (FrWindow *window,
static gboolean
-fr_window_progress_cb (FrCommand *command,
- double fraction,
- FrWindow *window)
+fr_window_progress_cb (FrArchive *archive,
+ double fraction,
+ FrWindow *window)
{
window->priv->progress_pulse = (fraction < 0.0);
if (! window->priv->progress_pulse) {
@@ -2697,6 +2697,28 @@ fr_window_progress_cb (FrCommand *command,
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);
+ if ((archive != NULL) && (archive->command->n_files > 0)) {
+ char *message = NULL;
+ int remaining_files;
+
+ remaining_files = archive->command->n_files - archive->command->n_file + 1;
+
+ switch (window->priv->action) {
+ case FR_ACTION_ADDING_FILES:
+ case FR_ACTION_EXTRACTING_FILES:
+ case FR_ACTION_DELETING_FILES:
+ message = g_strdup_printf (ngettext (_("%d file remaining"),
+ _("%'d files remaining"),
+ remaining_files), remaining_files);
+ break;
+ default:
+ break;
+ }
+
+ if (message != NULL)
+ fr_command_message (archive->command, message);
+ }
+
window->priv->pd_last_fraction = fraction;
g_signal_emit (G_OBJECT (window),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]