Commit 69a8b942 authored by Cosimo Cecchi's avatar Cosimo Cecchi Committed by Cosimo Cecchi

Reset selection_was_removed in FMDirectoryView if the user cancels the

2008-02-19  Cosimo Cecchi  <cosimoc@gnome.org>

	* libnautilus-private/nautilus-file-operations.c:
	(delete_job_done), (delete_job), (trash_or_delete_internal),
	(callback_for_move_to_trash), (nautilus_file_operations_copy_move):
	* libnautilus-private/nautilus-file-operations.h:
	* src/file-manager/fm-directory-view.c:
	(trash_or_delete_selected_files), (trash_or_delete_done_cb),
	(trash_or_delete_files), (action_location_trash_callback):
	Reset selection_was_removed in FMDirectoryView if the user
	cancels the deletion from trash (#337937).

svn path=/trunk/; revision=13772
parent fbb7d640
2008-02-19 Cosimo Cecchi <cosimoc@gnome.org>
* libnautilus-private/nautilus-file-operations.c:
(delete_job_done), (delete_job), (trash_or_delete_internal),
(callback_for_move_to_trash), (nautilus_file_operations_copy_move):
* libnautilus-private/nautilus-file-operations.h:
* src/file-manager/fm-directory-view.c:
(trash_or_delete_selected_files), (trash_or_delete_done_cb),
(trash_or_delete_files), (action_location_trash_callback):
Reset selection_was_removed in FMDirectoryView if the user
cancels the deletion from trash (#337937).
2008-02-19 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-clipboard.c:
......
......@@ -102,6 +102,7 @@ typedef struct {
CommonJob common;
GList *files;
gboolean try_trash;
gboolean user_cancel;
NautilusDeleteCallback done_callback;
gpointer done_callback_data;
} DeleteJob;
......@@ -1617,7 +1618,7 @@ delete_job_done (gpointer user_data)
if (job->done_callback) {
debuting_uris = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, g_object_unref, NULL);
job->done_callback (debuting_uris, job->done_callback_data);
job->done_callback (debuting_uris, job->user_cancel, job->done_callback_data);
g_hash_table_unref (debuting_uris);
}
......@@ -1683,6 +1684,8 @@ delete_job (GIOSchedulerJob *io_job,
}
if (confirmed) {
delete_files (common, to_delete_files);
} else {
job->user_cancel = TRUE;
}
}
......@@ -1719,6 +1722,7 @@ trash_or_delete_internal (GList *files,
job = op_job_new (DeleteJob, parent_window);
job->files = eel_g_object_list_copy (files);
job->try_trash = try_trash;
job->user_cancel = FALSE;
job->done_callback = done_callback;
job->done_callback_data = done_callback_data;
......@@ -4554,6 +4558,20 @@ location_list_from_uri_list (const GList *uris)
return g_list_reverse (files);
}
typedef struct {
NautilusCopyCallback real_callback;
gpointer real_data;
} MoveTrashCBData;
static void
callback_for_move_to_trash (GHashTable *debuting_uris,
gboolean user_cancelled,
MoveTrashCBData *data)
{
data->real_callback (debuting_uris, data->real_data);
g_slice_free (MoveTrashCBData, data);
}
void
nautilus_file_operations_copy_move (const GList *item_uris,
GArray *relative_item_points,
......@@ -4594,9 +4612,15 @@ nautilus_file_operations_copy_move (const GList *item_uris,
} else if (copy_action == GDK_ACTION_MOVE) {
if (g_file_has_uri_scheme (dest, "trash")) {
MoveTrashCBData *cb_data;
cb_data = g_slice_new0 (MoveTrashCBData);
cb_data->real_callback = done_callback;
cb_data->real_data = done_callback_data;
nautilus_file_operations_trash_or_delete (locations,
parent_window,
done_callback, done_callback_data);
(NautilusDeleteCallback) callback_for_move_to_trash,
cb_data);
} else {
nautilus_file_operations_move (locations,
relative_item_points,
......
......@@ -37,6 +37,7 @@ typedef void (* NautilusCreateCallback) (GFile *new_file,
gpointer callback_data);
typedef void (* NautilusOpCallback) (gpointer callback_data);
typedef void (* NautilusDeleteCallback) (GHashTable *debuting_uris,
gboolean user_cancel,
gpointer callback_data);
/* FIXME: int copy_action should be an enum */
......
......@@ -298,7 +298,8 @@ static void fm_directory_view_create_links_for_files (FMDirectoryView
GArray *item_locations);
static void trash_or_delete_files (GtkWindow *parent_window,
const GList *files,
gboolean delete_if_all_already_in_trash);
gboolean delete_if_all_already_in_trash,
FMDirectoryView *view);
static void load_directory (FMDirectoryView *view,
NautilusDirectory *directory);
static void fm_directory_view_merge_menus (FMDirectoryView *view);
......@@ -905,7 +906,9 @@ trash_or_delete_selected_files (FMDirectoryView *view)
*/
if (!view->details->selection_was_removed) {
selection = fm_directory_view_get_selection_for_file_transfer (view);
trash_or_delete_files (fm_directory_view_get_containing_window (view), selection, TRUE);
trash_or_delete_files (fm_directory_view_get_containing_window (view),
selection, TRUE,
view);
nautilus_file_list_free (selection);
view->details->selection_was_removed = TRUE;
}
......@@ -3590,10 +3593,21 @@ desktop_or_home_dir_in_selection (FMDirectoryView *view)
return saw_desktop_or_home_dir;
}
static void
trash_or_delete_done_cb (GHashTable *debuting_uris,
gboolean user_cancel,
FMDirectoryView *view)
{
if (user_cancel) {
view->details->selection_was_removed = FALSE;
}
}
static void
trash_or_delete_files (GtkWindow *parent_window,
const GList *files,
gboolean delete_if_all_already_in_trash)
gboolean delete_if_all_already_in_trash,
FMDirectoryView *view)
{
GList *locations;
const GList *node;
......@@ -3608,7 +3622,8 @@ trash_or_delete_files (GtkWindow *parent_window,
nautilus_file_operations_trash_or_delete (locations,
parent_window,
NULL, NULL);
(NautilusDeleteCallback) trash_or_delete_done_cb,
view);
eel_g_object_list_free (locations);
}
......@@ -6123,7 +6138,9 @@ action_location_trash_callback (GtkAction *action,
g_return_if_fail (file != NULL);
files = g_list_append (NULL, file);
trash_or_delete_files (fm_directory_view_get_containing_window (view), files, TRUE);
trash_or_delete_files (fm_directory_view_get_containing_window (view),
files, TRUE,
view);
g_list_free (files);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment