nautilus-file-operations.c 72.1 KB
Newer Older
Ettore Perazzoli's avatar
Ettore Perazzoli committed
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2

3
/* nautilus-file-operations.c - Nautilus file operations.
Ettore Perazzoli's avatar
Ettore Perazzoli committed
4

Elliot Lee's avatar
Elliot Lee committed
5
   Copyright (C) 1999, 2000 Free Software Foundation
6
   Copyright (C) 2000, 2001 Eazel, Inc.
Ettore Perazzoli's avatar
Ettore Perazzoli committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.
   
   You should have received a copy of the GNU General Public
   License along with this program; if not, write to the
   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
   
23 24
   Authors: Ettore Perazzoli <ettore@gnu.org> 
            Pavel Cisler <pavel@eazel.com> 
25
 */
Ettore Perazzoli's avatar
Ettore Perazzoli committed
26 27

#include <config.h>
28
#include "nautilus-file-operations.h"
Ettore Perazzoli's avatar
Ettore Perazzoli committed
29

30 31
#include "nautilus-file-operations-progress.h"
#include "nautilus-lib-self-check-functions.h"
Ramiro Estrugo's avatar
Ramiro Estrugo committed
32 33 34 35

#include <eel/eel-glib-extensions.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-stock-dialogs.h>
36 37
#include <eel/eel-vfs-extensions.h>

Ettore Perazzoli's avatar
Ettore Perazzoli committed
38
#include <gnome.h>
39
#include <gtk/gtklabel.h>
40
#include <libgnomevfs/gnome-vfs-async-ops.h>
41
#include <libgnomevfs/gnome-vfs-find-directory.h>
42 43
#include <libgnomevfs/gnome-vfs-ops.h>
#include <libgnomevfs/gnome-vfs-result.h>
Pavel Cisler's avatar
Pavel Cisler committed
44
#include <libgnomevfs/gnome-vfs-uri.h>
45
#include <libgnomevfs/gnome-vfs-utils.h>
46
#include "nautilus-file-changes-queue.h"
47 48 49
#include "nautilus-global-preferences.h"
#include "nautilus-link.h"
#include "nautilus-trash-monitor.h"
Ettore Perazzoli's avatar
Ettore Perazzoli committed
50

51
typedef enum {
52 53 54 55 56 57 58 59
	TRANSFER_MOVE,
	TRANSFER_COPY,
	TRANSFER_DUPLICATE,
	TRANSFER_MOVE_TO_TRASH,
	TRANSFER_EMPTY_TRASH,
	TRANSFER_DELETE,
	TRANSFER_LINK
} TransferKind;
60

61 62
/* Copy engine callback state */
typedef struct {
Ettore Perazzoli's avatar
Ettore Perazzoli committed
63
	GnomeVFSAsyncHandle *handle;
64
	NautilusFileOperationsProgress *progress_dialog;
Pavel Cisler's avatar
Pavel Cisler committed
65
	const char *operation_title;	/* "Copying files" */
66
	const char *action_label;	/* "Files copied:" */
Pavel Cisler's avatar
Pavel Cisler committed
67 68 69
	const char *progress_verb;	/* "Copying" */
	const char *preparation_name;	/* "Preparing To Copy..." */
	const char *cleanup_name;	/* "Finishing Move..." */
Ettore Perazzoli's avatar
Ettore Perazzoli committed
70 71
	GnomeVFSXferErrorMode error_mode;
	GnomeVFSXferOverwriteMode overwrite_mode;
72
	GtkWidget *parent_view;
73
	TransferKind kind;
74
	gboolean show_progress_dialog;
75
	void (* done_callback) (GHashTable *debuting_uris, gpointer data);
76
	gpointer done_callback_data;
77 78
	GHashTable *debuting_uris;
	gboolean cancelled;	
79
} TransferInfo;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
80

81 82 83 84 85 86 87 88
static TransferInfo *
transfer_info_new (GtkWidget *parent_view)
{
	TransferInfo *result;
	
	result = g_new0 (TransferInfo, 1);
	result->parent_view = parent_view;
	
Ramiro Estrugo's avatar
Ramiro Estrugo committed
89
	eel_nullify_when_destroyed (&result->parent_view);
90 91 92 93 94 95 96
	
	return result;
}

static void
transfer_info_destroy (TransferInfo *transfer_info)
{
Ramiro Estrugo's avatar
Ramiro Estrugo committed
97
	eel_nullify_cancel (&transfer_info->parent_view);
98 99
	
	if (transfer_info->progress_dialog != NULL) {
100
		nautilus_file_operations_progress_done (transfer_info->progress_dialog);
101 102 103
	}
	
	if (transfer_info->debuting_uris != NULL) {
104
		g_hash_table_destroy (transfer_info->debuting_uris);
105 106 107 108 109
	}
	
	g_free (transfer_info);
}

110 111 112 113 114 115 116 117 118 119 120 121
/* Struct used to control applying icon positions to 
 * top level items during a copy, drag, new folder creation and
 * link creation
 */
typedef struct {
	GdkPoint *icon_positions;
	int last_icon_position_index;
	GList *uris;
	const GList *last_uri;
} IconPositionIterator;

static IconPositionIterator *
122
icon_position_iterator_new (GArray *icon_positions, const GList *uris)
123 124
{
	IconPositionIterator *result;
125
	guint index;
126

127
	g_assert (icon_positions->len == g_list_length ((GList *)uris));
128 129
	result = g_new (IconPositionIterator, 1);
	
130
	/* make our own copy of the icon locations */
131
	result->icon_positions = g_new (GdkPoint, icon_positions->len);
132 133 134
	for (index = 0; index < icon_positions->len; index++) {
		result->icon_positions[index] = g_array_index (icon_positions, GdkPoint, index);
	}
135 136
	result->last_icon_position_index = 0;

Ramiro Estrugo's avatar
Ramiro Estrugo committed
137
	result->uris = eel_g_str_list_copy ((GList *)uris);
138 139 140 141 142 143 144 145 146 147 148 149 150
	result->last_uri = result->uris;

	return result;
}

static void
icon_position_iterator_free (IconPositionIterator *position_iterator)
{
	if (position_iterator == NULL) {
		return;
	}
	
	g_free (position_iterator->icon_positions);
Ramiro Estrugo's avatar
Ramiro Estrugo committed
151
	eel_g_list_free_deep (position_iterator->uris);
152 153 154
	g_free (position_iterator);
}

155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
static gboolean
icon_position_iterator_get_next (IconPositionIterator *position_iterator,
				 const char *next_uri,
				 GdkPoint *point)
{
	if (position_iterator == NULL) {
		return FALSE;
	}
		
	for (;;) {
		if (position_iterator->last_uri == NULL) {
			/* we are done, no more points left */
			return FALSE;
		}

		/* Scan for the next point that matches the source_name
		 * uri.
		 */
		if (strcmp ((const char *) position_iterator->last_uri->data, 
			    next_uri) == 0) {
			break;
		}
		
		/* Didn't match -- a uri must have been skipped by the copy 
		 * engine because of a name conflict. All we need to do is 
		 * skip ahead too.
		 */
		position_iterator->last_uri = position_iterator->last_uri->next;
		position_iterator->last_icon_position_index++; 
	}

	/* apply the location to the target file */
	*point = position_iterator->icon_positions
		[position_iterator->last_icon_position_index];

	/* advance to the next point for next time */
	position_iterator->last_uri = position_iterator->last_uri->next;
	position_iterator->last_icon_position_index++; 

	return TRUE;
}

197 198
#if GNOME2_CONVERSION_COMPLETE

199 200
static GdkFont *
get_label_font (void)
201
{
202 203
	GtkWidget *label;
	GtkStyle *style;
204 205 206 207 208 209
	GdkFont *font;

	/* FIXME: Does this really pick up the correct font if the rc
	 * file has a special case for the particular dialog we are
	 * preparing?
	 */
210 211 212

	label = gtk_label_new ("");
	style = gtk_widget_get_style (label);
213 214 215
	font = style->font;
	gdk_font_ref (font);
	gtk_object_sink (GTK_OBJECT (label));
216

217
	return font;
218 219
}

220 221
#endif

222
static char *
223
ellipsize_string_for_dialog (const char *str)
224
{
225 226
	char *result;
#ifdef GNOME2_CONVERSION_COMPLETE
227
	GdkFont *font;
228
	int maximum_width;
229

230
	/* get a nice length to ellipsize to, based on the font */
231
	font = get_label_font ();
232
	maximum_width = gdk_string_width (font, "MMMMMMMMMMMMMMMMMMMMMM");
233 234

	result = eel_string_ellipsize (str, font, maximum_width, EEL_ELLIPSIZE_MIDDLE);
235
	gdk_font_unref (font);
236 237 238
#else
	result = g_strdup (str);
#endif
239

240 241
	return result;
}
242

243 244 245 246
static char *
format_and_ellipsize_uri_for_dialog (const char *uri)
{
	char *unescaped, *result;
247

248
	unescaped = eel_format_uri_for_display (uri);
249
	result = ellipsize_string_for_dialog (unescaped);
250
	g_free (unescaped);
251

252 253 254 255
	return result;
}

static char *
256
extract_and_ellipsize_file_name_for_dialog (const char *uri)
257
{
258 259
	const char *last_part;
	char *unescaped, *result;
260
	
261
	last_part = g_basename (uri);
262
	g_return_val_if_fail (last_part != NULL, NULL);
263 264 265 266

	unescaped = gnome_vfs_unescape_string_for_display (last_part);
	result = ellipsize_string_for_dialog (unescaped);
	g_free (unescaped);
267

268 269 270
	return result;
}

271
static GtkWidget *
272
parent_for_error_dialog (TransferInfo *transfer_info)
273
{
274
	if (transfer_info->progress_dialog != NULL) {
275
		return GTK_WIDGET (transfer_info->progress_dialog);
276 277
	}

278
	return transfer_info->parent_view;
279 280
}

281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
static void
fit_rect_on_screen (GdkRectangle *rect)
{
	if (rect->x + rect->width > gdk_screen_width ()) {
		rect->x = gdk_screen_width () - rect->width;
	}

	if (rect->y + rect->height > gdk_screen_height ()) {
		rect->y = gdk_screen_height () - rect->height;
	}

	if (rect->x < 0) {
		rect->x = 0;
	}

	if (rect->y < 0) {
		rect->y = 0;
	}
}

static void
center_dialog_over_rect (GtkWindow *window, GdkRectangle rect)
{
	g_return_if_fail (GTK_WINDOW (window) != NULL);

	fit_rect_on_screen (&rect);

	gtk_widget_set_uposition (GTK_WIDGET (window), 
		rect.x + rect.width / 2 
			- GTK_WIDGET (window)->allocation.width / 2,
		rect.y + rect.height / 2
			- GTK_WIDGET (window)->allocation.height / 2);
}

static void
center_dialog_over_window (GtkWindow *window, GtkWindow *over)
{
	GdkRectangle rect;
	int x, y, w, h;

	g_return_if_fail (GTK_WINDOW (window) != NULL);
	g_return_if_fail (GTK_WINDOW (over) != NULL);

	gdk_window_get_root_origin (GTK_WIDGET (over)->window, &x, &y);
	gdk_window_get_size (GTK_WIDGET (over)->window, &w, &h);
	rect.x = x;
	rect.y = y;
	rect.width = w;
	rect.height = h;

	center_dialog_over_rect (window, rect);
}

334 335 336 337 338 339 340 341
static void
handle_response_callback (GtkDialog *dialog, int response, TransferInfo *transfer_info)
{
	transfer_info->cancelled = TRUE;
}

static void
handle_close_callback (GtkDialog *dialog, TransferInfo *transfer_info)
342
{
343
	transfer_info->cancelled = TRUE;
344 345
}

Ettore Perazzoli's avatar
Ettore Perazzoli committed
346
static void
347
create_transfer_dialog (const GnomeVFSXferProgressInfo *progress_info,
348
			TransferInfo *transfer_info)
Ettore Perazzoli's avatar
Ettore Perazzoli committed
349
{
350
	if (!transfer_info->show_progress_dialog) {
351
		return;
352
	}
353

354
	g_return_if_fail (transfer_info->progress_dialog == NULL);
Ettore Perazzoli's avatar
Ettore Perazzoli committed
355

356
	transfer_info->progress_dialog = nautilus_file_operations_progress_new 
357
		(transfer_info->operation_title, "", "", "", 0, 0);
Ettore Perazzoli's avatar
Ettore Perazzoli committed
358

359 360 361
	/* Treat clicking on the close box or use of the escape key
	 * the same as clicking cancel.
	 */
362
	g_signal_connect (transfer_info->progress_dialog,
363 364 365
			  "response",
			  G_CALLBACK (handle_response_callback),
			  NULL);
366
	g_signal_connect (transfer_info->progress_dialog,
367 368 369
			  "close",
			  G_CALLBACK (handle_close_callback),
			  transfer_info);
Ettore Perazzoli's avatar
Ettore Perazzoli committed
370

371
	/* Make the progress dialog show up over the window we are copying into */
372 373
	if (transfer_info->parent_view != NULL) {
		center_dialog_over_window (GTK_WINDOW (transfer_info->progress_dialog), 
374
					   GTK_WINDOW (gtk_widget_get_toplevel (transfer_info->parent_view)));
375
	}
376 377

	gtk_widget_show (GTK_WIDGET (transfer_info->progress_dialog));
Ettore Perazzoli's avatar
Ettore Perazzoli committed
378 379
}

Pavel Cisler's avatar
Pavel Cisler committed
380
static void
381
progress_dialog_set_to_from_item_text (NautilusFileOperationsProgress *dialog,
382 383 384
				       const char *progress_verb,
				       const char *from_uri, const char *to_uri, 
				       gulong index, gulong size)
Pavel Cisler's avatar
Pavel Cisler committed
385 386 387 388 389 390 391 392
{
	char *item;
	char *from_path;
	char *to_path;
	char *progress_label_text;
	const char *from_prefix;
	const char *to_prefix;
	GnomeVFSURI *uri;
393
	int length;
Pavel Cisler's avatar
Pavel Cisler committed
394 395 396 397 398 399 400 401 402 403 404 405

	item = NULL;
	from_path = NULL;
	to_path = NULL;
	from_prefix = "";
	to_prefix = "";
	progress_label_text = NULL;

	if (from_uri != NULL) {
		uri = gnome_vfs_uri_new (from_uri);
		item = gnome_vfs_uri_extract_short_name (uri);
		from_path = gnome_vfs_uri_extract_dirname (uri);
406 407 408 409 410 411 412

		/* remove the last '/' */
		length = strlen (from_path);
		if (from_path [length - 1] == '/') {
			from_path [length - 1] = '\0';
		}
		
Pavel Cisler's avatar
Pavel Cisler committed
413 414 415
		gnome_vfs_uri_unref (uri);
		g_assert (progress_verb);
		progress_label_text = g_strdup_printf ("%s:", progress_verb);
416
		/* "From" dialog label, source path gets placed next to it in the dialog */
Pavel Cisler's avatar
Pavel Cisler committed
417 418 419 420
		from_prefix = _("From:");
	}

	if (to_uri != NULL) {
421
		uri = gnome_vfs_uri_new (to_uri);
Pavel Cisler's avatar
Pavel Cisler committed
422
		to_path = gnome_vfs_uri_extract_dirname (uri);
423 424 425 426 427 428 429

		/* remove the last '/' */
		length = strlen (to_path);
		if (to_path [length - 1] == '/') {
			to_path [length - 1] = '\0';
		}

Pavel Cisler's avatar
Pavel Cisler committed
430
		gnome_vfs_uri_unref (uri);
431
		/* "To" dialog label, source path gets placed next to it in the dialog */
Pavel Cisler's avatar
Pavel Cisler committed
432 433 434
		to_prefix = _("To:");
	}

435 436 437 438 439 440 441
	nautilus_file_operations_progress_new_file
		(dialog,
		 progress_label_text != NULL ? progress_label_text : "",
		 item != NULL ? item : "",
		 from_path != NULL ? from_path : "",
		 to_path != NULL ? to_path : "",
		 from_prefix, to_prefix, index, size);
Pavel Cisler's avatar
Pavel Cisler committed
442 443 444 445 446 447 448

	g_free (progress_label_text);
	g_free (item);
	g_free (from_path);
	g_free (to_path);
}

449
static int
450
handle_transfer_ok (const GnomeVFSXferProgressInfo *progress_info,
451
		    TransferInfo *transfer_info)
Ettore Perazzoli's avatar
Ettore Perazzoli committed
452
{
453 454
	if (transfer_info->cancelled
		&& progress_info->phase != GNOME_VFS_XFER_PHASE_COMPLETED) {
455 456
		/* If cancelled, delete any partially copied files that are laying
		 * around and return.
457
		 */
458 459
		if (progress_info->target_name != NULL
		    && progress_info->bytes_total != progress_info->bytes_copied) {
460
			GList *delete_me;
461

462
			delete_me = g_list_prepend (NULL, progress_info->target_name);
463 464 465 466
			nautilus_file_operations_delete (delete_me, transfer_info->parent_view);
			g_list_free (delete_me);
		}

467 468 469
		return 0;
	}
	
Ettore Perazzoli's avatar
Ettore Perazzoli committed
470
	switch (progress_info->phase) {
471
	case GNOME_VFS_XFER_PHASE_INITIAL:
472
		create_transfer_dialog (progress_info, transfer_info);
473
		return 1;
474 475

	case GNOME_VFS_XFER_PHASE_COLLECTING:
476
		if (transfer_info->progress_dialog != NULL) {
477
			nautilus_file_operations_progress_set_operation_string
478 479
				(transfer_info->progress_dialog,
				 transfer_info->preparation_name);
480
		}
481
		return 1;
482 483

	case GNOME_VFS_XFER_PHASE_READYTOGO:
484
		if (transfer_info->progress_dialog != NULL) {
485 486 487
			nautilus_file_operations_progress_set_operation_string
				(transfer_info->progress_dialog,
				 transfer_info->action_label);
488
			nautilus_file_operations_progress_set_total
489 490 491
				(transfer_info->progress_dialog,
				 progress_info->files_total,
				 progress_info->bytes_total);
492
		}
493
		return 1;
494
				 
495
	case GNOME_VFS_XFER_PHASE_DELETESOURCE:
496
		nautilus_file_changes_consume_changes (FALSE);
497
		if (transfer_info->progress_dialog != NULL) {
498 499 500 501 502 503 504
			progress_dialog_set_to_from_item_text
				(transfer_info->progress_dialog,
				 transfer_info->progress_verb,
				 progress_info->source_name,
				 NULL,
				 progress_info->file_index,
				 progress_info->file_size);
Pavel Cisler's avatar
Pavel Cisler committed
505

506
			nautilus_file_operations_progress_update_sizes
507
				(transfer_info->progress_dialog,
508
				 MIN (progress_info->bytes_copied, 
509
				      progress_info->bytes_total),
510
				 MIN (progress_info->total_bytes_copied,
511
				      progress_info->bytes_total));
512
		}
513
		return 1;
514 515

	case GNOME_VFS_XFER_PHASE_MOVING:
516 517
	case GNOME_VFS_XFER_PHASE_OPENSOURCE:
	case GNOME_VFS_XFER_PHASE_OPENTARGET:
518 519
		/* fall through */
	case GNOME_VFS_XFER_PHASE_COPYING:
520
		if (transfer_info->progress_dialog != NULL) {
521
			if (progress_info->bytes_copied == 0) {
522 523 524 525 526 527 528
				progress_dialog_set_to_from_item_text
					(transfer_info->progress_dialog,
					 transfer_info->progress_verb,
					 progress_info->source_name,
					 progress_info->target_name,
					 progress_info->file_index,
					 progress_info->file_size);
529
			} else {
530
				nautilus_file_operations_progress_update_sizes
531
					(transfer_info->progress_dialog,
532
					 MIN (progress_info->bytes_copied, 
533
					      progress_info->bytes_total),
534
					 MIN (progress_info->total_bytes_copied,
535
					      progress_info->bytes_total));
536
			}
Ettore Perazzoli's avatar
Ettore Perazzoli committed
537
		}
538
		return 1;
539

540
	case GNOME_VFS_XFER_PHASE_CLEANUP:
541
		if (transfer_info->progress_dialog != NULL) {
542 543
			nautilus_file_operations_progress_clear
				(transfer_info->progress_dialog);
544
			nautilus_file_operations_progress_set_operation_string
545 546
				(transfer_info->progress_dialog,
				 transfer_info->cleanup_name);
547
		}
548
		return 1;
549

Ettore Perazzoli's avatar
Ettore Perazzoli committed
550
	case GNOME_VFS_XFER_PHASE_COMPLETED:
551
		nautilus_file_changes_consume_changes (TRUE);
552
		if (transfer_info->done_callback != NULL) {
553 554 555 556
			transfer_info->done_callback (transfer_info->debuting_uris,
						      transfer_info->done_callback_data);
			/* done_callback now owns (will free) debuting_uris */
			transfer_info->debuting_uris = NULL;
557
		}
558 559

		transfer_info_destroy (transfer_info);
560
		return 1;
561

Ettore Perazzoli's avatar
Ettore Perazzoli committed
562
	default:
563
		return 1;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
564 565 566
	}
}

567 568 569 570 571 572 573 574
typedef enum {
	ERROR_READ_ONLY,
	ERROR_NOT_READABLE,
	ERROR_NOT_WRITABLE,
	ERROR_NOT_ENOUGH_PERMISSIONS,
	ERROR_NO_SPACE,
	ERROR_OTHER
} NautilusFileOperationsErrorKind;
575

576 577 578 579 580 581 582 583 584 585 586
typedef enum {
	ERROR_LOCATION_UNKNOWN,
	ERROR_LOCATION_SOURCE,
	ERROR_LOCATION_SOURCE_PARENT,
	ERROR_LOCATION_SOURCE_OR_PARENT,
	ERROR_LOCATION_TARGET
} NautilusFileOperationsErrorLocation;


static char *
build_error_string (const char *source_name, const char *target_name,
587 588 589 590
		    TransferKind operation_kind,
		    NautilusFileOperationsErrorKind error_kind,
		    NautilusFileOperationsErrorLocation error_location,
		    GnomeVFSResult error)
Ettore Perazzoli's avatar
Ettore Perazzoli committed
591
{
592 593 594 595 596 597
	/* Avoid clever message composing here, just use brute force and
	 * duplicate the different flavors of error messages for all the
	 * possible permutations.
	 * That way localizers have an easier time and can even rearrange the
	 * order of the words in the messages easily.
	 */
Ettore Perazzoli's avatar
Ettore Perazzoli committed
598

599
	const char *error_string;
600
	char *result;
601

602 603
	error_string = NULL;
	result = NULL;
604

605
	if (error_location == ERROR_LOCATION_SOURCE_PARENT) {
606

607
		switch (operation_kind) {
608 609
		case TRANSFER_MOVE:
		case TRANSFER_MOVE_TO_TRASH:
610
			if (error_kind == ERROR_READ_ONLY) {
611
				error_string = _("Error while moving.\n\n"
612 613
						 "\"%s\" cannot be moved because it is on "
						 "a read-only disk.");
614 615
			}
			break;
616

617 618
		case TRANSFER_DELETE:
		case TRANSFER_EMPTY_TRASH:
619 620 621
			switch (error_kind) {
			case ERROR_NOT_ENOUGH_PERMISSIONS:
			case ERROR_NOT_WRITABLE:
622
				error_string = _("Error while deleting.\n\n"
623
						 "\"%s\" cannot be deleted because you do not have "
624 625 626 627
						 "permissions to modify its parent folder.");
				break;
			
			case ERROR_READ_ONLY:
628
				error_string = _("Error while deleting.\n\n"
629 630 631 632 633 634
						 "\"%s\" cannot be deleted because it is on "
						 "a read-only disk.");
				break;

			default:
				break;
635 636 637 638 639 640 641 642 643 644 645
			}
			break;

		default:
			g_assert_not_reached ();
			break;
		}
		
		if (error_string != NULL) {
			g_assert (source_name != NULL);
			result = g_strdup_printf (error_string, source_name);
646
		}
647

648
	} else if (error_location == ERROR_LOCATION_SOURCE_OR_PARENT) {
649

650 651
		g_assert (source_name != NULL);

652 653 654 655
		/* FIXME: Would be better if we could distinguish source vs parent permissions
		 * better somehow. The GnomeVFS copy engine would have to do some snooping
		 * after the failure in this case.
		 */
656
		switch (operation_kind) {
657
		case TRANSFER_MOVE:
658
			if (error_kind == ERROR_NOT_ENOUGH_PERMISSIONS) {
659
				error_string = _("Error while moving.\n\n"
660 661 662
						 "\"%s\" cannot be moved because you do not have "
						 "permissions to change it or its parent folder.");
			}
663
			break;
664
		case TRANSFER_MOVE_TO_TRASH:
665
			if (error_kind == ERROR_NOT_ENOUGH_PERMISSIONS) {
666
				error_string = _("Error while moving.\n\n"
667
						 "\"%s\" cannot be moved to the Trash because you do not have "
668 669
						 "permissions to change it or its parent folder.");
			}
670
			break;
671

672
		default:
673
			g_assert_not_reached ();
674 675
			break;
		}
676

677 678 679 680
		if (error_string != NULL) {
			g_assert (source_name != NULL);
			result = g_strdup_printf (error_string, source_name);
		}
681

682
	} else if (error_location == ERROR_LOCATION_SOURCE) {
683

684 685 686
		g_assert (source_name != NULL);

		switch (operation_kind) {
687 688
		case TRANSFER_COPY:
		case TRANSFER_DUPLICATE:
689
			if (error_kind == ERROR_NOT_READABLE) {
690
				error_string = _("Error while copying.\n\n"
691 692
						 "\"%s\" cannot be copied because you do not have "
						 "permissions to read it.");
693 694
			}
			break;
695

696 697 698
		default:
			g_assert_not_reached ();
			break;
699
		}
700

701 702 703
		if (error_string != NULL) {
			g_assert (source_name != NULL);
			result = g_strdup_printf (error_string, source_name);
704
		}
705

706 707 708 709
	} else if (error_location == ERROR_LOCATION_TARGET) {

		if (error_kind == ERROR_NO_SPACE) {
			switch (operation_kind) {
710 711
			case TRANSFER_COPY:
			case TRANSFER_DUPLICATE:
712
				error_string = _("Error while copying to \"%s\".\n\n"
713
				   		 "There is not enough space on the destination.");
714
				break;
715 716
			case TRANSFER_MOVE_TO_TRASH:
			case TRANSFER_MOVE:
717
				error_string = _("Error while moving to \"%s\".\n\n"
718
				   		 "There is not enough space on the destination.");
719
				break;
720
			case TRANSFER_LINK:
721
				error_string = _("Error while creating link in \"%s\".\n\n"
722
				   		 "There is not enough space on the destination.");
723 724 725 726 727 728 729
				break;
			default:
				g_assert_not_reached ();
				break;
			}
		} else {
			switch (operation_kind) {
730 731
			case TRANSFER_COPY:
			case TRANSFER_DUPLICATE:
732
				if (error_kind == ERROR_NOT_ENOUGH_PERMISSIONS) {
733
					error_string = _("Error while copying to \"%s\".\n\n"
734
					   		 "You do not have permissions to write to "
735
					   		 "this folder.");
736
				} else if (error_kind == ERROR_NOT_WRITABLE) {
737
					error_string = _("Error while copying to \"%s\".\n\n"
738
					   		 "The destination disk is read-only.");
739 740
				} 
				break;
741 742
			case TRANSFER_MOVE:
			case TRANSFER_MOVE_TO_TRASH:
743
				if (error_kind == ERROR_NOT_ENOUGH_PERMISSIONS) {
744
					error_string = _("Error while moving items to \"%s\".\n\n"
745
					   		 "You do not have permissions to write to "
746
					   		 "this folder.");
747
				} else if (error_kind == ERROR_NOT_WRITABLE) {
748
					error_string = _("Error while moving items to \"%s\".\n\n"
749
					   		 "The destination disk is read-only.");
750 751 752
				} 

				break;
753
			case TRANSFER_LINK:
754
				if (error_kind == ERROR_NOT_ENOUGH_PERMISSIONS) {
755
					error_string = _("Error while creating links in \"%s\".\n\n"
756
					   		 "You do not have permissions to write to "
757
					   		 "this folder.");
758
				} else if (error_kind == ERROR_NOT_WRITABLE) {
759
					error_string = _("Error while creating links in \"%s\".\n\n"
760
					   		 "The destination disk is read-only.");
761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777
				} 
				break;
			default:
				g_assert_not_reached ();
				break;
			}
		}
		if (error_string != NULL) {
			g_assert (target_name != NULL);
			result = g_strdup_printf (error_string, target_name);
		}
	}
	
	if (result == NULL) {
		/* None of the specific error messages apply, use a catch-all
		 * generic error
		 */
778 779
		g_message ("Hit unexpected error \"%s\" while doing a file operation.",
			   gnome_vfs_result_to_string (error));
780 781 782 783

		/* FIXMEs: we need to consider a single item
		 * move/copy and not offer to continue in that case
		 */
784 785
		if (source_name != NULL) {
			switch (operation_kind) {
786 787
			case TRANSFER_COPY:
			case TRANSFER_DUPLICATE:
788
				error_string = _("Error \"%s\" while copying \"%s\".\n\n"
789 790
						 "Would you like to continue?");
				break;
791
			case TRANSFER_MOVE:
792
				error_string = _("Error \"%s\" while moving \"%s\".\n\n"
793 794
						 "Would you like to continue?");
				break;
795
			case TRANSFER_LINK:
796
				error_string = _("Error \"%s\" while creating a link to \"%s\".\n\n"
797 798
						 "Would you like to continue?");
				break;
799 800 801
			case TRANSFER_DELETE:
			case TRANSFER_EMPTY_TRASH:
			case TRANSFER_MOVE_TO_TRASH:
802
				error_string = _("Error \"%s\" while deleting \"%s\".\n\n"
803 804 805
						 "Would you like to continue?");
				break;
			default:
806
				g_assert_not_reached ();
807 808 809
				break;
			}
	
810
			result = g_strdup_printf (error_string, 
811 812
						  gnome_vfs_result_to_string (error),
						  source_name);
813
		} else {
814
			switch (operation_kind) {
815 816
			case TRANSFER_COPY:
			case TRANSFER_DUPLICATE:
817
				error_string = _("Error \"%s\" while copying.\n\n"
818 819
						 "Would you like to continue?");
				break;
820
			case TRANSFER_MOVE:
821
				error_string = _("Error \"%s\" while moving.\n\n"
822 823
						 "Would you like to continue?");
				break;
824
			case TRANSFER_LINK:
825
				error_string = _("Error \"%s\" while linking.\n\n"
826 827
						 "Would you like to continue?");
				break;
828 829 830
			case TRANSFER_DELETE:
			case TRANSFER_EMPTY_TRASH:
			case TRANSFER_MOVE_TO_TRASH:
831
				error_string = _("Error \"%s\" while deleting.\n\n"
832 833 834
						 "Would you like to continue?");
				break;
			default:
835
				g_assert_not_reached ();
836 837 838
				break;
			}
	
839
			result = g_strdup_printf (error_string, 
840
						  gnome_vfs_result_to_string (error));
841
		}
842 843 844
	}
	return result;
}
845

846
static int
847
handle_transfer_vfs_error (const GnomeVFSXferProgressInfo *progress_info,
848
			   TransferInfo *transfer_info)
849
{
850
	/* Notice that the error mode in `transfer_info' is the one we have been
851 852 853
         * requested, but the transfer is always performed in mode
         * `GNOME_VFS_XFER_ERROR_MODE_QUERY'.
         */
854

855 856 857
	int error_dialog_button_pressed;
	int error_dialog_result;
	char *text;
858 859
	char *formatted_source_name;
	char *formatted_target_name;
860 861 862 863
	const char *dialog_title;
	NautilusFileOperationsErrorKind error_kind;
	NautilusFileOperationsErrorLocation error_location;
	
864
	switch (transfer_info->error_mode) {
865 866 867 868
	case GNOME_VFS_XFER_ERROR_MODE_QUERY:

		/* transfer error, prompt the user to continue or stop */

869 870
		formatted_source_name = NULL;
		formatted_target_name = NULL;
871 872

		if (progress_info->source_name != NULL) {
873
			formatted_source_name = format_and_ellipsize_uri_for_dialog
874 875 876 877
				(progress_info->source_name);
		}

		if (progress_info->target_name != NULL) {
878
			formatted_target_name = format_and_ellipsize_uri_for_dialog
879 880 881 882 883
				(progress_info->target_name);
		}

		error_kind = ERROR_OTHER;
		error_location = ERROR_LOCATION_UNKNOWN;
884
		
885 886 887 888 889
		/* Single out a few common error conditions for which we have
		 * custom-taylored error messages.
		 */
		if ((progress_info->vfs_status == GNOME_VFS_ERROR_READ_ONLY_FILE_SYSTEM
				|| progress_info->vfs_status == GNOME_VFS_ERROR_READ_ONLY)
890 891
			&& (transfer_info->kind == TRANSFER_DELETE
				|| transfer_info->kind == TRANSFER_EMPTY_TRASH)) {
892 893 894
			error_location = ERROR_LOCATION_SOURCE_PARENT;
			error_kind = ERROR_READ_ONLY;
		} else if (progress_info->vfs_status == GNOME_VFS_ERROR_ACCESS_DENIED
895 896
			&& (transfer_info->kind == TRANSFER_DELETE
				|| transfer_info->kind == TRANSFER_EMPTY_TRASH)) {
897 898 899 900
			error_location = ERROR_LOCATION_SOURCE_PARENT;
			error_kind = ERROR_NOT_ENOUGH_PERMISSIONS;
		} else if ((progress_info->vfs_status == GNOME_VFS_ERROR_READ_ONLY_FILE_SYSTEM
				|| progress_info->vfs_status == GNOME_VFS_ERROR_READ_ONLY)
901 902
			&& (transfer_info->kind == TRANSFER_MOVE
				|| transfer_info->kind == TRANSFER_MOVE_TO_TRASH)
903 904 905
			&& progress_info->phase != GNOME_VFS_XFER_CHECKING_DESTINATION) {
			error_location = ERROR_LOCATION_SOURCE_PARENT;
			error_kind = ERROR_READ_ONLY;
906 907 908 909 910
		} else if (progress_info->vfs_status == GNOME_VFS_ERROR_ACCESS_DENIED
			&& transfer_info->kind == TRANSFER_MOVE
			&& progress_info->phase == GNOME_VFS_XFER_PHASE_OPENTARGET) {
			error_location = ERROR_LOCATION_TARGET;
			error_kind = ERROR_NOT_ENOUGH_PERMISSIONS;
911
		} else if (progress_info->vfs_status == GNOME_VFS_ERROR_ACCESS_DENIED
912 913
			&& (transfer_info->kind == TRANSFER_MOVE
				|| transfer_info->kind == TRANSFER_MOVE_TO_TRASH)
914 915 916 917
			&& progress_info->phase != GNOME_VFS_XFER_CHECKING_DESTINATION) {
			error_location = ERROR_LOCATION_SOURCE_OR_PARENT;
			error_kind = ERROR_NOT_ENOUGH_PERMISSIONS;
		} else if (progress_info->vfs_status == GNOME_VFS_ERROR_ACCESS_DENIED
918 919
			&& (transfer_info->kind == TRANSFER_COPY
				|| transfer_info->kind == TRANSFER_DUPLICATE)
920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938
			&& (progress_info->phase == GNOME_VFS_XFER_PHASE_OPENSOURCE
				|| progress_info->phase == GNOME_VFS_XFER_PHASE_COLLECTING
				|| progress_info->phase == GNOME_VFS_XFER_PHASE_INITIAL)) {
			error_location = ERROR_LOCATION_SOURCE;
			error_kind = ERROR_NOT_READABLE;
		} else if ((progress_info->vfs_status == GNOME_VFS_ERROR_READ_ONLY_FILE_SYSTEM
				|| progress_info->vfs_status == GNOME_VFS_ERROR_READ_ONLY)
			&& progress_info->phase == GNOME_VFS_XFER_CHECKING_DESTINATION) {
			error_location = ERROR_LOCATION_TARGET;
			error_kind = ERROR_NOT_WRITABLE;
		} else if (progress_info->vfs_status == GNOME_VFS_ERROR_ACCESS_DENIED
			&& progress_info->phase == GNOME_VFS_XFER_CHECKING_DESTINATION) {
			error_location = ERROR_LOCATION_TARGET;
			error_kind = ERROR_NOT_ENOUGH_PERMISSIONS;
		} else if (progress_info->vfs_status == GNOME_VFS_ERROR_NO_SPACE) {
			error_location = ERROR_LOCATION_TARGET;
			error_kind = ERROR_NO_SPACE;
		}

939 940 941 942
		text = build_error_string (formatted_source_name, formatted_target_name,
					   transfer_info->kind,
					   error_kind, error_location,
					   progress_info->vfs_status);
943

944 945 946
		switch (transfer_info->kind) {
		case TRANSFER_COPY:
		case TRANSFER_DUPLICATE:
947 948
			dialog_title = _("Error while copying.");
			break;
949
		case TRANSFER_MOVE:
950 951
			dialog_title = _("Error while moving.");
			break;
952
		case TRANSFER_LINK:
953 954
			dialog_title = _("Error while linking.");
			break;
955 956 957
		case TRANSFER_DELETE:
		case TRANSFER_EMPTY_TRASH:
		case TRANSFER_MOVE_TO_TRASH:
958 959
			dialog_title = _("Error while deleting.");
			break;
960
		default:
961 962 963
			dialog_title = NULL;
			break;
		}
964

965 966
		if (error_location == ERROR_LOCATION_TARGET) {
			/* We can't continue, just tell the user. */
Ramiro Estrugo's avatar
Ramiro Estrugo committed
967
			eel_run_simple_dialog (parent_for_error_dialog (transfer_info),
968 969 970 971 972 973 974 975 976 977 978 979
				TRUE, text, dialog_title, _("Stop"), NULL);
			error_dialog_result = GNOME_VFS_XFER_ERROR_ACTION_ABORT;

		} else if ((error_location == ERROR_LOCATION_SOURCE
				|| error_location == ERROR_LOCATION_SOURCE_PARENT
				|| error_location == ERROR_LOCATION_SOURCE_OR_PARENT)
			&& (error_kind == ERROR_NOT_ENOUGH_PERMISSIONS
				|| error_kind == ERROR_NOT_READABLE)) {
			/* The error could have happened on any of the files
			 * in the moved/copied/deleted hierarchy, we can probably
			 * continue. Allow the user to skip.
			 */
Ramiro Estrugo's avatar
Ramiro Estrugo committed
980
			error_dialog_button_pressed = eel_run_simple_dialog
981
				(parent_for_error_dialog (transfer_info), TRUE, text, 
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998
				dialog_title,
				 _("Skip"), _("Stop"), NULL);
				 
			switch (error_dialog_button_pressed) {
			case 0:
				error_dialog_result = GNOME_VFS_XFER_ERROR_ACTION_SKIP;
				break;
			case 1:
				error_dialog_result = GNOME_VFS_XFER_ERROR_ACTION_ABORT;
				break;
			default:
				g_assert_not_reached ();
				error_dialog_result = GNOME_VFS_XFER_ERROR_ACTION_ABORT;
			}
								
		} else {
			/* Generic error, offer to retry and skip. */
Ramiro Estrugo's avatar
Ramiro Estrugo committed
999
			error_dialog_button_pressed = eel_run_simple_dialog
1000
				(parent_for_error_dialog (transfer_info), TRUE, text, 
1001
				 dialog_title,
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020
				 _("Skip"), _("Retry"), _("Stop"), NULL);

			switch (error_dialog_button_pressed) {
			case 0:
				error_dialog_result = GNOME_VFS_XFER_ERROR_ACTION_SKIP;
				break;
			case 1:
				error_dialog_result = GNOME_VFS_XFER_ERROR_ACTION_RETRY;
				break;
			case 2:
				error_dialog_result = GNOME_VFS_XFER_ERROR_ACTION_ABORT;
				break;
			default:
				g_assert_not_reached ();
				error_dialog_result = GNOME_VFS_XFER_ERROR_ACTION_ABORT;
			}
		}
			
		g_free (text);
1021 1022 1023
		g_free (formatted_source_name);
		g_free (formatted_target_name);

1024
		return error_dialog_result;
1025

Ettore Perazzoli's avatar
Ettore Perazzoli committed
1026 1027
	case GNOME_VFS_XFER_ERROR_MODE_ABORT:
	default:
1028
		if (transfer_info->progress_dialog != NULL) {
1029 1030
			nautilus_file_operations_progress_done
				(transfer_info->progress_dialog);
1031
		}
Ettore Perazzoli's avatar
Ettore Perazzoli committed
1032 1033 1034 1035
		return GNOME_VFS_XFER_ERROR_ACTION_ABORT;
	}
}

1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063
/* is_special_link
 *
 * Check and see if file is one of our special links.
 * A special link ould be one of the following:
 * 	trash, home, volume
 */
static gboolean
is_special_link (const char *uri)
{
	char *local_path;
	gboolean is_special;

	local_path = gnome_vfs_get_local_path_from_uri (uri);

	/* FIXME: This should use some API to check if the file is a
	 * link. Normally we use the MIME type. As things stand, this
	 * will read files and try to parse them as XML, which could
	 * result in a lot of output to the console, since the XML
	 * parser reports errors directly there.
	 */
	is_special = local_path != NULL
		&& nautilus_link_local_get_link_type (local_path) != NAUTILUS_LINK_GENERIC;
	
	g_free (local_path);
	
	return is_special;
}

1064
static int
1065
handle_transfer_overwrite (const GnomeVFSXferProgressInfo *progress_info,
1066
		           TransferInfo *transfer_info)
1067
{
1068
	int result;
1069
	char *text, *formatted_name;
1070

1071
	/* Handle special case files such as Trash, mount links and home directory */	
1072
	if (is_special_link (progress_info->target_name)) {
1073 1074
		formatted_name = extract_and_ellipsize_file_name_for_dialog
			(progress_info->target_name);
1075 1076 1077
		
		if (transfer_info->kind == TRANSFER_MOVE) {
			text = g_strdup_printf (_("\"%s\" could not be moved to the new location, "
1078 1079
						  "because its name is already used for a special item that "
						  "cannot be removed or replaced.\n\n"
1080 1081 1082 1083
						  "If you still want to move \"%s\", rename it and try again."),
						formatted_name, formatted_name);
		} else {
			text = g_strdup_printf (_("\"%s\" could not be copied to the new location, "
1084 1085
						  "because its name is already used for a special item that "
						  "cannot be removed or replaced.\n\n"
1086 1087
						  "If you still want to copy \"%s\", rename it and try again."),
						formatted_name, formatted_name);
1088
		}
1089
		
Ramiro Estrugo's avatar
Ramiro Estrugo committed
1090
		eel_run_simple_dialog (parent_for_error_dialog (transfer_info), TRUE, text,
1091
				       _("Unable to replace file."), GTK_STOCK_OK, NULL, NULL);
1092 1093 1094 1095

		g_free (text);
		g_free (formatted_name);

1096 1097 1098 1099
		return GNOME_VFS_XFER_OVERWRITE_ACTION_SKIP;
	}
	
	/* transfer conflict, prompt the user to replace or skip */
1100
	formatted_name = format_and_ellipsize_uri_for_dialog (progress_info->target_name);
1101
	text = g_strdup_printf (_("File \"%s\" already exists.\n\n"
1102
				  "Would you like to replace it?"), 
1103 1104
				formatted_name);
	g_free (formatted_name);
1105 1106 1107 1108 1109

	if (progress_info->duplicate_count == 1) {
		/* we are going to only get one duplicate alert, don't offer
		 * Replace All
		 */
Ramiro Estrugo's avatar
Ramiro Estrugo committed
1110
		result = eel_run_simple_dialog
1111
			(parent_for_error_dialog (transfer_info), TRUE, text, 
1112
			 _("Conflict while copying"),
1113
			 _("Replace"), _("Skip"), NULL);
1114 1115 1116
		switch (result) {
		case 0:
			return GNOME_VFS_XFER_OVERWRITE_ACTION_REPLACE;
1117 1118 1119
		default:
			g_assert_not_reached ();
			/* fall through */
1120 1121 1122 1123
		case 1:
			return GNOME_VFS_XFER_OVERWRITE_ACTION_SKIP;
		}
	} else {
Ramiro Estrugo's avatar
Ramiro Estrugo committed
1124
		result = eel_run_simple_dialog
1125
			(parent_for_error_dialog (transfer_info), TRUE, text, 
1126
			 _("Conflict while copying"),
1127
			 _("Replace All"), _("Replace"), _("Skip"), NULL);
1128 1129 1130 1131 1132 1133

		switch (result) {
		case 0:
			return GNOME_VFS_XFER_OVERWRITE_ACTION_REPLACE_ALL;
		case 1:
			return GNOME_VFS_XFER_OVERWRITE_ACTION_REPLACE;
1134 1135 1136
		default:
			g_assert_not_reached ();
			/* fall through */
1137 1138 1139
		case 2:
			return GNOME_VFS_XFER_OVERWRITE_ACTION_SKIP;
		}
1140 1141 1142
	}
}

1143
/* Note that we have these two separate functions with separate format
1144
 * strings for ease of localization.
1145 1146 1147
 */

static char *
1148
get_link_name (char *name, int count) 
1149
{
1150
	char *result;
1151 1152 1153 1154
	char *unescaped_name;
	char *unescaped_result;

	const char *format;
1155
	
1156 1157
	g_assert (name != NULL);

1158 1159 1160
	unescaped_name = gnome_vfs_unescape_string (name, "/");
	g_free (name);

1161 1162 1163 1164 1165
	if (count < 1) {
		g_warning ("bad count in get_link_name");
		count = 1;
	}

1166 1167 1168
	if (count <= 2) {
		/* Handle special cases for low numbers.
		 * Perhaps for some locales we will need to add more.
1169
		 */
1170
		switch (count) {
1171 1172 1173
		default:
			g_assert_not_reached ();
			/* fall through */
1174
		case 1:
1175
			/* appended to new link file */
1176 1177 1178
			format = _("link to %s");
			break;
		case 2:
1179
			/* appended to new link file */
1180 1181 1182
			format = _("another link to %s");
			break;
		}
1183
		unescaped_result = g_strdup_printf (format, unescaped_name);
1184 1185 1186 1187 1188

	} else {
		/* Handle special cases for the first few numbers of each ten.
		 * For locales where getting this exactly right is difficult,
		 * these can just be made all the same as the general case below.
1189
		 */
1190 1191 1192 1193 1194 1195 1196 1197 1198
		switch (count % 10) {
		case 1:
			/* Localizers: Feel free to leave out the "st" suffix
			 * if there's no way to do that nicely for a
			 * particular language.
			 */
			format = _("%dst link to %s");
			break;
		case 2:
1199
			/* appended to new link file */
1200 1201 1202
			format = _("%dnd link to %s");
			break;
		case 3:
1203
			/* appended to new link file */
1204 1205 1206
			format = _("%drd link to %s");
			break;
		default:
1207
			/* appended to new link file */
1208 1209 1210
			format = _("%dth link to %s");
			break;
		}
1211
		unescaped_result = g_strdup_printf (format, count, unescaped_name);
1212
	}
1213

1214 1215 1216 1217 1218
	result = gnome_vfs_escape_path_string (unescaped_result);
	
	g_free (unescaped_name);
	g_free (unescaped_result);

1219
	return result;
1220 1221
}

1222 1223 1224 1225 1226
/* Localizers: 
 * Feel free to leave out the st, nd, rd and th suffix or
 * make some or all of them match.
 */

1227
/* localizers: tag used to detect the first copy of a file */
1228
static const char untranslated_copy_duplicate_tag[] = N_(" (copy)");
1229
/* localizers: tag used to detect the second copy of a file */
1230
static const char untranslated_another_copy_duplicate_tag[] = N_(" (another copy)");
1231 1232 1233 1234 1235 1236 1237 1238

/* localizers: tag used to detect the x11th copy of a file */
static const char untranslated_x11th_copy_duplicate_tag[] = N_("th copy)");
/* localizers: tag used to detect the x12th copy of a file */
static const char untranslated_x12th_copy_duplicate_tag[] = N_("th copy)");
/* localizers: tag used to detect the x13th copy of a file */
static const char untranslated_x13th_copy_duplicate_tag[] = N_("th copy)");

1239
/* localizers: tag used to detect the x1st copy of a file */
1240
static const char untranslated_st_copy_duplicate_tag[] = N_("st copy)");
1241
/* localizers: tag used to detect the x2nd copy of a file */
1242
static const char untranslated_nd_copy_duplicate_tag[] = N_("nd copy)");
1243
/* localizers: tag used to detect the x3rd copy of a file */
1244
static const char untranslated_rd_copy_duplicate_tag[] = N_("rd copy)");
1245

1246
/* localizers: tag used to detect the xxth copy of a file */
1247 1248 1249 1250
static const char untranslated_th_copy_duplicate_tag[] = N_("th copy)");

#define COPY_DUPLICATE_TAG _(untranslated_copy_duplicate_tag)
#define ANOTHER_COPY_DUPLICATE_TAG _(untranslated_another_copy_duplicate_tag)
1251 1252 1253 1254
#define X11TH_COPY_DUPLICATE_TAG _(untranslated_x11th_copy_duplicate_tag)
#define X12TH_COPY_DUPLICATE_TAG _(untranslated_x12th_copy_duplicate_tag)
#define X13TH_COPY_DUPLICATE_TAG _(untranslated_x13th_copy_duplicate_tag)

1255 1256 1257