Index: libnautilus-private/nautilus-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file.c,v
retrieving revision 1.370
diff -u -p -r1.370 nautilus-file.c
--- libnautilus-private/nautilus-file.c	22 Aug 2005 21:17:58 -0000	1.370
+++ libnautilus-private/nautilus-file.c	28 Aug 2005 13:19:05 -0000
@@ -5817,11 +5845,84 @@ nautilus_file_list_sort_by_display_name 
 typedef struct 
 {
 	GList *file_list;
-	GList *remaining_files;
 	NautilusFileListCallback callback;
 	gpointer callback_data;
+
+	GList *remaining_files;
 } FileListReadyData;
 
+static int
+file_list_ready_data_compare (gconstpointer a,
+			      gconstpointer b)
+{
+	const FileListReadyData *a_key;
+	const FileListReadyData *b_key;
+
+	g_return_val_if_fail (a != NULL && b != NULL, 0);
+
+	if (a == b) {
+		return 0;
+	}
+
+	a_key = (FileListReadyData *) a;
+	b_key = (FileListReadyData *) a;
+
+	return !((a_key->file_list == b_key->file_list)
+		  && (a_key->callback == b_key->callback)
+		  && (a_key->callback_data == b_key->callback_data));
+}
+
+static FileListReadyData *
+file_list_ready_data_lookup (GList *file_list,
+			     NautilusFileListCallback callback,
+			     gpointer callback_data)
+{
+	GList *l;
+	FileListReadyData key;
+
+	key.file_list = file_list;
+	key.callback = callback;
+	key.callback_data = callback_data;
+
+	l = g_list_find_custom (ready_data_list, &key,
+				file_list_ready_data_compare);
+
+	return l != NULL ? l->data : NULL;
+}
+
+static void
+file_list_ready_data_free (FileListReadyData *data)
+{
+	GList *l;
+
+	l = g_list_find (ready_data_list, data);
+	if (l != NULL) {
+		ready_data_list = g_list_delete_link (ready_data_list, l);
+
+		nautilus_file_list_free (data->file_list);
+		g_free (data);
+	}
+}
+
+static FileListReadyData *
+file_list_ready_data_new (GList *file_list,
+			  NautilusFileListCallback callback,
+			  gpointer callback_data)
+{
+	FileListReadyData *data;
+
+	data = g_new0 (FileListReadyData, 1);
+	data->file_list = nautilus_file_list_copy (file_list);
+	data->remaining_files = g_list_copy (file_list);
+	data->callback = callback;
+	data->callback_data = callback_data;
+
+	ready_data_list = g_list_prepend
+		(ready_data_list, data);
+
+	return data;
+}
+
 static void
 file_list_file_ready_callback (NautilusFile *file,
 			       gpointer user_data)
@@ -5835,9 +5936,8 @@ file_list_file_ready_callback (NautilusF
 		if (data->callback) {
 			(*data->callback) (data->file_list, data->callback_data);
 		}
-		
-		nautilus_file_list_free (data->file_list);
-		g_free (data);
+
+		file_list_ready_data_free (data);
 	}
 }
 
@@ -5852,12 +5952,9 @@ nautilus_file_list_call_when_ready (GLis
 	
 	g_return_if_fail (file_list != NULL);
 
-	data = g_new0 (FileListReadyData, 1);
-	data->file_list = nautilus_file_list_copy (file_list);
-	data->remaining_files = g_list_copy (file_list);
-	data->callback = callback;
-	data->callback_data = callback_data;
-	
+	data = file_list_ready_data_new
+		(file_list, callback, callback_data);
+
 	for (l = file_list; l != NULL; l = l->next) {
 		nautilus_file_call_when_ready (NAUTILUS_FILE (l->data),
 					       attributes,
@@ -5865,6 +5962,34 @@ nautilus_file_list_call_when_ready (GLis
 					       data);
 	}
 }
+
+void
+nautilus_file_list_cancel_call_when_ready (GList                          *file_list,
+					   NautilusFileListCallback        callback,
+					   gpointer                        callback_data)
+{
+	GList *l;
+	NautilusFile *file;
+	FileListReadyData *data;
+
+	g_return_if_fail (callback != NULL);
+
+	if (file_list == NULL) {
+		return;
+	}
+
+	data = file_list_ready_data_lookup (file_list, callback, callback_data);
+	if (data != NULL) {
+		for (l = file_list; l != NULL; l = l->next) {
+			file = NAUTILUS_FILE (l->data);
+
+			EEL_CALL_METHOD
+				(NAUTILUS_FILE_CLASS, file,
+				 cancel_call_when_ready, (file, file_list_file_ready_callback, data));
+		}
+	}
+}
+
 
 static char *
 try_to_make_utf8 (const char *text, int *length)
Index: libnautilus-private/nautilus-file.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file.h,v
retrieving revision 1.106
diff -u -p -r1.106 nautilus-file.h
--- libnautilus-private/nautilus-file.h	22 Aug 2005 21:17:58 -0000	1.106
+++ libnautilus-private/nautilus-file.h	28 Aug 2005 13:19:05 -0000
@@ -339,6 +340,9 @@ GList *                 nautilus_file_li
 GList *			nautilus_file_list_sort_by_display_name		(GList				*file_list);
 void                    nautilus_file_list_call_when_ready              (GList                          *file_list,
 									 NautilusFileAttributes          attributes,
+									 NautilusFileListCallback        callback,
+									 gpointer                        callback_data);
+void                    nautilus_file_list_cancel_call_when_ready       (GList                          *file_list,
 									 NautilusFileListCallback        callback,
 									 gpointer                        callback_data);
 
