[nautilus] undo: fix Redo Trash not updating the trashed mtime



commit d60b724d5ee183b1074a137d9cc24c22b3a2259d
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Jan 30 10:39:00 2012 -0500

    undo: fix Redo Trash not updating the trashed mtime
    
    When we redo a trash operation, we should make sure our trashed files
    hash table stores the updated timestamp when we trashed the file again,
    or we won't be able to trash them again.

 .../nautilus-file-undo-operations.c                |   39 +++++++++++++++++++-
 1 files changed, 38 insertions(+), 1 deletions(-)
---
diff --git a/libnautilus-private/nautilus-file-undo-operations.c b/libnautilus-private/nautilus-file-undo-operations.c
index 4a17cd3..dc0e2a4 100644
--- a/libnautilus-private/nautilus-file-undo-operations.c
+++ b/libnautilus-private/nautilus-file-undo-operations.c
@@ -976,6 +976,43 @@ trash_strings_func (NautilusFileUndoInfo *info,
 }
 
 static void
+trash_redo_func_callback (GHashTable *debuting_uris,
+			  gboolean user_cancel,
+			  gpointer user_data)
+{
+	NautilusFileUndoInfoTrash *self = user_data;
+	GHashTable *new_trashed_files;
+	GTimeVal current_time;
+	gsize updated_trash_time;
+	GFile *file;
+	GList *keys, *l;
+
+	if (!user_cancel) {
+		new_trashed_files = 
+			g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal, 
+					       g_object_unref, NULL);
+
+		keys = g_hash_table_get_keys (self->priv->trashed);
+
+		g_get_current_time (&current_time);
+		updated_trash_time = current_time.tv_sec;
+
+		for (l = keys; l != NULL; l = l->next) {
+			file = l->data;
+			g_hash_table_insert (new_trashed_files,
+					     g_object_ref (file), GSIZE_TO_POINTER (updated_trash_time));
+		}
+
+		g_list_free (keys);
+		g_hash_table_destroy (self->priv->trashed);
+
+		self->priv->trashed = new_trashed_files;
+	}
+
+	file_undo_info_delete_callback (debuting_uris, user_cancel, user_data);
+}
+
+static void
 trash_redo_func (NautilusFileUndoInfo *info,
 		 GtkWindow *parent_window)
 {
@@ -986,7 +1023,7 @@ trash_redo_func (NautilusFileUndoInfo *info,
 
 		locations = g_hash_table_get_keys (self->priv->trashed);
 		nautilus_file_operations_trash_or_delete (locations, parent_window,
-							  file_undo_info_delete_callback, self);
+							  trash_redo_func_callback, self);
 
 		g_list_free (locations);
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]