summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Kunkel <will@wkunkel.com>2013-07-17 13:56:25 -0400
committerCosimo Cecchi <cosimoc@gnome.org>2013-08-31 17:45:02 -0700
commit63f4d5c4af3a245e685c7233af0499980ba0295a (patch)
tree7b1a44652843f2046f107471ee4596f01452ecbb
parent1c1695c28f46ed8e102947c34a1758ebb8bb5476 (diff)
downloadnautilus-63f4d5c4af3a245e685c7233af0499980ba0295a.tar.gz
Bug 698694 - Redundant options presented in operations on single files
https://bugzilla.gnome.org/show_bug.cgi?id=698694
-rw-r--r--libnautilus-private/nautilus-file-operations.c113
1 files changed, 69 insertions, 44 deletions
diff --git a/libnautilus-private/nautilus-file-operations.c b/libnautilus-private/nautilus-file-operations.c
index 05601a821..b59ac53f0 100644
--- a/libnautilus-private/nautilus-file-operations.c
+++ b/libnautilus-private/nautilus-file-operations.c
@@ -1267,6 +1267,37 @@ run_question (CommonJob *job,
return res;
}
+static int
+run_cancel_or_skip_warning (CommonJob *job,
+ char *primary_text,
+ char *secondary_text,
+ const char *details_text,
+ int total_operations,
+ int operations_remaining)
+{
+ int response;
+
+ if (total_operations == 1) {
+ response = run_warning (job,
+ primary_text,
+ secondary_text,
+ details_text,
+ FALSE,
+ CANCEL,
+ NULL);
+ } else {
+ response = run_warning (job,
+ primary_text,
+ secondary_text,
+ details_text,
+ operations_remaining > 1,
+ CANCEL, SKIP_ALL, SKIP,
+ NULL);
+ }
+
+ return response;
+}
+
static void
inhibit_power_manager (CommonJob *job, const char *message)
{
@@ -1598,14 +1629,13 @@ delete_dir (CommonJob *job, GFile *dir,
primary = f (_("Error while deleting."));
secondary = f (_("Could not remove the folder %B."), dir);
details = error->message;
-
- response = run_warning (job,
- primary,
- secondary,
- details,
- (source_info->num_files - transfer_info->num_files) > 1,
- CANCEL, SKIP_ALL, SKIP,
- NULL);
+
+ response = run_cancel_or_skip_warning (job,
+ primary,
+ secondary,
+ details,
+ source_info->num_files,
+ source_info->num_files - transfer_info->num_files);
if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
abort_job (job);
@@ -1676,13 +1706,12 @@ delete_file (CommonJob *job, GFile *file,
secondary = f (_("There was an error deleting %B."), file);
details = error->message;
- response = run_warning (job,
- primary,
- secondary,
- details,
- (source_info->num_files - transfer_info->num_files) > 1,
- CANCEL, SKIP_ALL, SKIP,
- NULL);
+ response = run_cancel_or_skip_warning (job,
+ primary,
+ secondary,
+ details,
+ source_info->num_files,
+ source_info->num_files - transfer_info->num_files);
if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
abort_job (job);
@@ -3660,14 +3689,13 @@ copy_move_directory (CopyMoveJob *copy_job,
secondary = f (_("Could not remove the source folder."));
details = error->message;
- response = run_warning (job,
- primary,
- secondary,
- details,
- (source_info->num_files - transfer_info->num_files) > 1,
- CANCEL, SKIP_ALL, SKIP,
- NULL);
-
+ response = run_cancel_or_skip_warning (job,
+ primary,
+ secondary,
+ details,
+ source_info->num_files,
+ source_info->num_files - transfer_info->num_files);
+
if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
abort_job (job);
} else if (response == 1) { /* skip all */
@@ -4108,13 +4136,12 @@ copy_move_file (CopyMoveJob *copy_job,
: g_strdup (_("You cannot copy a folder into itself."));
secondary = g_strdup (_("The destination folder is inside the source folder."));
- response = run_warning (job,
- primary,
- secondary,
- NULL,
- (source_info->num_files - transfer_info->num_files) > 1,
- CANCEL, SKIP_ALL, SKIP,
- NULL);
+ response = run_cancel_or_skip_warning (job,
+ primary,
+ secondary,
+ NULL,
+ source_info->num_files,
+ source_info->num_files - transfer_info->num_files);
if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
abort_job (job);
@@ -4141,13 +4168,12 @@ copy_move_file (CopyMoveJob *copy_job,
: g_strdup (_("You cannot copy a file over itself."));
secondary = g_strdup (_("The source file would be overwritten by the destination."));
- response = run_warning (job,
- primary,
- secondary,
- NULL,
- (source_info->num_files - transfer_info->num_files) > 1,
- CANCEL, SKIP_ALL, SKIP,
- NULL);
+ response = run_cancel_or_skip_warning (job,
+ primary,
+ secondary,
+ NULL,
+ source_info->num_files,
+ source_info->num_files - transfer_info->num_files);
if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
abort_job (job);
@@ -4426,13 +4452,12 @@ copy_move_file (CopyMoveJob *copy_job,
secondary = f (_("There was an error copying the file into %F."), dest_dir);
details = error->message;
- response = run_warning (job,
- primary,
- secondary,
- details,
- (source_info->num_files - transfer_info->num_files) > 1,
- CANCEL, SKIP_ALL, SKIP,
- NULL);
+ response = run_cancel_or_skip_warning (job,
+ primary,
+ secondary,
+ details,
+ source_info->num_files,
+ source_info->num_files - transfer_info->num_files);
g_error_free (error);