[file-roller] progress dialog: show the filename when processing a single file
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] progress dialog: show the filename when processing a single file
- Date: Tue, 19 Jun 2012 18:41:38 +0000 (UTC)
commit 83ff7276b112199fc1e9a2c46a189c75f18f93cd
Author: Paolo Bacchilega <paobac src gnome org>
Date: Mon Jun 18 21:52:01 2012 +0200
progress dialog: show the filename when processing a single file
src/fr-command-7z.c | 23 ++++++++++++++++++-----
src/fr-command-rar.c | 42 ++++++++++++++++++++++++++++++++++++------
src/fr-command-tar.c | 18 +++++++++---------
src/fr-command-zip.c | 2 +-
src/fr-window.c | 2 +-
5 files changed, 65 insertions(+), 22 deletions(-)
---
diff --git a/src/fr-command-7z.c b/src/fr-command-7z.c
index 5bd75d6..dd3e62d 100644
--- a/src/fr-command-7z.c
+++ b/src/fr-command-7z.c
@@ -257,14 +257,27 @@ fr_command_7z_list (FrCommand *comm)
static void
parse_progress_line (FrCommand *comm,
const char *prefix,
- const char *message_prefix,
+ const char *message_format,
const char *line)
{
int prefix_len;
prefix_len = strlen (prefix);
- if (strncmp (line, prefix, prefix_len) == 0)
- fr_command_progress (comm, (double) ++comm->n_file / (comm->n_files + 1));
+ if (strncmp (line, prefix, prefix_len) == 0) {
+ if (comm->n_files > 1) {
+ fr_command_progress (comm, (double) ++comm->n_file / (comm->n_files + 1));
+ }
+ else {
+ char filename[4196];
+ char *msg;
+
+ strcpy (filename, line + prefix_len);
+ msg = g_strdup_printf (message_format, filename, NULL);
+ fr_command_message (comm, msg);
+
+ g_free (msg);
+ }
+ }
}
@@ -287,7 +300,7 @@ process_line__add (char *line,
}
if (comm->n_files != 0)
- parse_progress_line (comm, "Compressing ", _("Adding file: "), line);
+ parse_progress_line (comm, "Compressing ", _("Adding \"%s\""), line);
}
@@ -408,7 +421,7 @@ process_line__extract (char *line,
FrCommand *comm = FR_COMMAND (data);
if (comm->n_files != 0)
- parse_progress_line (comm, "Extracting ", _("Extracting file: "), line);
+ parse_progress_line (comm, "Extracting ", _("Extracting \"%s\""), line);
}
diff --git a/src/fr-command-rar.c b/src/fr-command-rar.c
index bd76141..ed878ab 100644
--- a/src/fr-command-rar.c
+++ b/src/fr-command-rar.c
@@ -257,11 +257,41 @@ fr_command_rar_list (FrCommand *comm)
static void
parse_progress_line (FrCommand *comm,
const char *prefix,
- const char *message_prefix,
+ const char *message_format,
const char *line)
{
- if (strncmp (line, prefix, strlen (prefix)) == 0)
- fr_command_progress (comm, (double) ++comm->n_file / (comm->n_files + 1));
+ int prefix_len;
+
+ prefix_len = strlen (prefix);
+ if (strncmp (line, prefix, prefix_len) == 0) {
+ if (comm->n_files > 1) {
+ fr_command_progress (comm, (double) ++comm->n_file / (comm->n_files + 1));
+ }
+ else {
+ char filename[4096];
+ char *b_idx;
+ int len;
+ char *msg;
+
+ strcpy (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 (filename, '\x08');
+ if (b_idx != NULL)
+ *b_idx = 0;
+
+ /* remove the OK at the end of the filename */
+ len = strlen (filename);
+ if ((len > 5) && (strncmp (filename + len - 5, " OK ", 5) == 0))
+ filename[len - 5] = 0;
+
+ msg = g_strdup_printf (message_format, file_name_from_path (filename), NULL);
+ fr_command_message (comm, msg);
+
+ g_free (msg);
+ }
+ }
}
@@ -297,7 +327,7 @@ process_line__add (char *line,
}
if (comm->n_files != 0)
- parse_progress_line (comm, "Adding ", _("Adding file: "), line);
+ parse_progress_line (comm, "Adding ", _("Adding \"%s\""), line);
}
@@ -375,7 +405,7 @@ process_line__delete (char *line,
}
if (comm->n_files != 0)
- parse_progress_line (comm, "Deleting ", _("Removing file: "), line);
+ parse_progress_line (comm, "Deleting ", _("Removing \"%s\""), line);
}
@@ -424,7 +454,7 @@ process_line__extract (char *line,
}
if (comm->n_files != 0)
- parse_progress_line (comm, "Extracting ", _("Extracting file: "), line);
+ parse_progress_line (comm, "Extracting ", _("Extracting \"%s\""), line);
}
diff --git a/src/fr-command-tar.c b/src/fr-command-tar.c
index 1feb2a3..84f8067 100644
--- a/src/fr-command-tar.c
+++ b/src/fr-command-tar.c
@@ -277,7 +277,7 @@ can_create_a_compressed_archive (FrCommand *comm)
static void
process_line__generic (char *line,
gpointer data,
- char *action_msg)
+ char *message_format)
{
FrCommand *comm = FR_COMMAND (data);
@@ -287,12 +287,12 @@ process_line__generic (char *line,
if (line[strlen (line) - 1] == '/') /* ignore directories */
return;
- if (comm->n_files != 0) {
+ if (comm->n_files > 1) {
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);
+ char *msg = g_strdup_printf (message_format, file_name_from_path (line), NULL);
fr_command_message (comm, msg);
g_free (msg);
}
@@ -303,8 +303,8 @@ static void
process_line__add (char *line,
gpointer data)
{
- /* Translators: after the colon there is a filename. */
- process_line__generic (line, data, _("Adding file: "));
+ /* Translators: %s is a filename. */
+ process_line__generic (line, data, _("Adding \"%s\""));
}
@@ -368,8 +368,8 @@ static void
process_line__delete (char *line,
gpointer data)
{
- /* Translators: after the colon there is a filename. */
- process_line__generic (line, data, _("Removing file: "));
+ /* Translators: %s is a filename. */
+ process_line__generic (line, data, _("Removing \"%s\""));
}
@@ -422,8 +422,8 @@ static void
process_line__extract (char *line,
gpointer data)
{
- /* Translators: after the colon there is a filename. */
- process_line__generic (line, data, _("Extracting file: "));
+ /* Translators: %s is a filename. */
+ process_line__generic (line, data, _("Extracting \"%s\""));
}
diff --git a/src/fr-command-zip.c b/src/fr-command-zip.c
index ded5624..650f8bf 100644
--- a/src/fr-command-zip.c
+++ b/src/fr-command-zip.c
@@ -205,7 +205,7 @@ process_line__common (char *line,
if (line == NULL)
return;
- if (comm->n_files != 0) {
+ if (comm->n_files > 1) {
double fraction = (double) ++comm->n_file / (comm->n_files + 1);
fr_command_progress (comm, fraction);
}
diff --git a/src/fr-window.c b/src/fr-window.c
index 215b92e..f74f290 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -2655,7 +2655,7 @@ fr_window_progress_cb (FrArchive *archive,
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)) {
+ if ((archive != NULL) && (archive->command->n_files > 1)) {
char *message = NULL;
int remaining_files;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]