[nautilus/undo-manager: 96/98] file-operations: only add undo action items if we're not undoing/redoing
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/undo-manager: 96/98] file-operations: only add undo action items if we're not undoing/redoing
- Date: Tue, 7 Dec 2010 12:07:13 +0000 (UTC)
commit 640ec0c416499d71de226f2556eb4b78d0b0e596
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Dec 7 13:02:42 2010 +0100
file-operations: only add undo action items if we're not undoing/redoing
libnautilus-private/nautilus-file-operations.c | 81 +++++++++++++++++-------
1 files changed, 59 insertions(+), 22 deletions(-)
---
diff --git a/libnautilus-private/nautilus-file-operations.c b/libnautilus-private/nautilus-file-operations.c
index fba2b18..2da5096 100644
--- a/libnautilus-private/nautilus-file-operations.c
+++ b/libnautilus-private/nautilus-file-operations.c
@@ -957,8 +957,10 @@ finalize_common (CommonJob *common)
g_hash_table_destroy (common->skip_readdir_error);
}
- nautilus_undo_stack_manager_add_action (nautilus_undo_stack_manager_get (),
- common->undo_redo_data);
+ if (common->undo_redo_data != NULL) {
+ nautilus_undo_stack_manager_add_action (nautilus_undo_stack_manager_get (),
+ common->undo_redo_data);
+ }
g_object_unref (common->progress);
g_object_unref (common->cancellable);
@@ -1829,7 +1831,9 @@ trash_files (CommonJob *job, GList *files, int *files_skipped)
} else {
nautilus_file_changes_queue_file_removed (file);
- nautilus_undo_stack_action_data_add_trashed_file (job->undo_redo_data, file, mtime);
+ if (job->undo_redo_data != NULL) {
+ nautilus_undo_stack_action_data_add_trashed_file (job->undo_redo_data, file, mtime);
+ }
files_trashed++;
report_trash_progress (job, files_trashed, total_files);
@@ -1979,9 +1983,13 @@ trash_or_delete_internal (GList *files,
*/
if (try_trash && !nautilus_undo_stack_manager_is_undo_redo (nautilus_undo_stack_manager_get ())) {
GFile* src_dir;
+
job->common.undo_redo_data = nautilus_undo_stack_action_data_new (NAUTILUS_UNDO_STACK_MOVE_TO_TRASH, g_list_length(files));
src_dir = g_file_get_parent (files->data);
+
nautilus_undo_stack_action_data_set_src_dir (job->common.undo_redo_data, src_dir);
+
+ g_object_unref (src_dir);
}
g_io_scheduler_push_job (delete_job,
@@ -3398,7 +3406,9 @@ create_dest_dir (CommonJob *job,
}
nautilus_file_changes_queue_file_added (*dest);
- nautilus_undo_stack_action_data_add_origin_target_pair (job->undo_redo_data, src, *dest);
+ if (job->undo_redo_data != NULL) {
+ nautilus_undo_stack_action_data_add_origin_target_pair (job->undo_redo_data, src, *dest);
+ }
return CREATE_DEST_DIR_SUCCESS;
}
@@ -4157,7 +4167,9 @@ copy_move_file (CopyMoveJob *copy_job,
FALSE);
}
- nautilus_undo_stack_action_data_add_origin_target_pair (job->undo_redo_data, src, dest);
+ if (job->undo_redo_data != NULL) {
+ nautilus_undo_stack_action_data_add_origin_target_pair (job->undo_redo_data, src, dest);
+ }
g_object_unref (dest);
return;
@@ -4620,11 +4632,14 @@ nautilus_file_operations_copy (GList *files,
if (!nautilus_undo_stack_manager_is_undo_redo (nautilus_undo_stack_manager_get ())) {
GFile* src_dir;
+
job->common.undo_redo_data = nautilus_undo_stack_action_data_new (NAUTILUS_UNDO_STACK_COPY, g_list_length(files));
src_dir = g_file_get_parent (files->data);
+
nautilus_undo_stack_action_data_set_src_dir (job->common.undo_redo_data, src_dir);
- g_object_ref (target_dir);
nautilus_undo_stack_action_data_set_dest_dir (job->common.undo_redo_data, target_dir);
+
+ g_object_unref (src_dir);
}
g_io_scheduler_push_job (copy_job,
@@ -4785,7 +4800,9 @@ move_file_prepare (CopyMoveJob *move_job,
nautilus_file_changes_queue_schedule_position_remove (dest);
}
- nautilus_undo_stack_action_data_add_origin_target_pair (job->undo_redo_data, src, dest);
+ if (job->undo_redo_data != NULL) {
+ nautilus_undo_stack_action_data_add_origin_target_pair (job->undo_redo_data, src, dest);
+ }
return;
}
@@ -5150,15 +5167,19 @@ nautilus_file_operations_move (GList *files,
if (!nautilus_undo_stack_manager_is_undo_redo (nautilus_undo_stack_manager_get ())) {
GFile* src_dir;
+
if (g_file_has_uri_scheme (g_list_first(files)->data, "trash")) {
job->common.undo_redo_data = nautilus_undo_stack_action_data_new (NAUTILUS_UNDO_STACK_RESTORE_FROM_TRASH, g_list_length(files));
} else {
job->common.undo_redo_data = nautilus_undo_stack_action_data_new (NAUTILUS_UNDO_STACK_MOVE, g_list_length(files));
}
+
src_dir = g_file_get_parent (files->data);
+
nautilus_undo_stack_action_data_set_src_dir (job->common.undo_redo_data, src_dir);
- g_object_ref (target_dir);
nautilus_undo_stack_action_data_set_dest_dir (job->common.undo_redo_data, target_dir);
+
+ g_object_unref (src_dir);
}
g_io_scheduler_push_job (move_job,
@@ -5255,7 +5276,9 @@ link_file (CopyMoveJob *job,
common->cancellable,
&error)) {
- nautilus_undo_stack_action_data_add_origin_target_pair (common->undo_redo_data, src, dest);
+ if (common->undo_redo_data != NULL) {
+ nautilus_undo_stack_action_data_add_origin_target_pair (common->undo_redo_data, src, dest);
+ }
g_free (path);
if (debuting_files) {
@@ -5469,11 +5492,14 @@ nautilus_file_operations_link (GList *files,
if (!nautilus_undo_stack_manager_is_undo_redo (nautilus_undo_stack_manager_get ())) {
GFile* src_dir;
+
job->common.undo_redo_data = nautilus_undo_stack_action_data_new (NAUTILUS_UNDO_STACK_CREATE_LINK, g_list_length(files));
src_dir = g_file_get_parent (files->data);
+
nautilus_undo_stack_action_data_set_src_dir (job->common.undo_redo_data, src_dir);
- g_object_ref (target_dir);
nautilus_undo_stack_action_data_set_dest_dir (job->common.undo_redo_data, target_dir);
+
+ g_object_unref (src_dir);
}
g_io_scheduler_push_job (link_job,
@@ -5509,11 +5535,15 @@ nautilus_file_operations_duplicate (GList *files,
if (!nautilus_undo_stack_manager_is_undo_redo (nautilus_undo_stack_manager_get ())) {
GFile* src_dir;
- job->common.undo_redo_data = nautilus_undo_stack_action_data_new (NAUTILUS_UNDO_STACK_DUPLICATE, g_list_length(files));
+
+ job->common.undo_redo_data =
+ nautilus_undo_stack_action_data_new (NAUTILUS_UNDO_STACK_DUPLICATE, g_list_length(files));
src_dir = g_file_get_parent (files->data);
+
nautilus_undo_stack_action_data_set_src_dir (job->common.undo_redo_data, src_dir);
- g_object_ref (src_dir);
nautilus_undo_stack_action_data_set_dest_dir (job->common.undo_redo_data, src_dir);
+
+ g_object_unref (src_dir);
}
g_io_scheduler_push_job (copy_job,
@@ -5586,7 +5616,9 @@ set_permissions_file (SetPermissionsJob *job,
g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_UNIX_MODE)) {
current = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_MODE);
- nautilus_undo_stack_action_data_add_file_permissions (common->undo_redo_data, file, current);
+ if (common->undo_redo_data != NULL) {
+ nautilus_undo_stack_action_data_add_file_permissions (common->undo_redo_data, file, current);
+ }
current = (current & ~mask) | value;
@@ -5673,9 +5705,11 @@ nautilus_file_set_permissions_recursive (const char *directory,
if (!nautilus_undo_stack_manager_is_undo_redo (nautilus_undo_stack_manager_get ())) {
job->common.undo_redo_data = nautilus_undo_stack_action_data_new (NAUTILUS_UNDO_STACK_RECURSIVE_SET_PERMISSIONS, 1);
- g_object_ref (job->file);
+
nautilus_undo_stack_action_data_set_dest_dir (job->common.undo_redo_data, job->file);
- nautilus_undo_stack_action_data_set_recursive_permissions (job->common.undo_redo_data, file_permissions, file_mask, dir_permissions, dir_mask);
+ nautilus_undo_stack_action_data_set_recursive_permissions
+ (job->common.undo_redo_data,
+ file_permissions, file_mask, dir_permissions, dir_mask);
}
g_io_scheduler_push_job (set_permissions_job,
@@ -5927,7 +5961,7 @@ create_job (GIOSchedulerJob *io_job,
common->cancellable,
&error);
- if (res) {
+ if (res && common->undo_redo_data != NULL) {
nautilus_undo_stack_action_data_set_create_data (common->undo_redo_data,
dest,
NULL);
@@ -5942,10 +5976,14 @@ create_job (GIOSchedulerJob *io_job,
NULL, NULL,
&error);
- if (res) {
+ if (res && common->undo_redo_data != NULL) {
+ gchar *uri;
+
+ uri = g_file_get_uri (job->src);
nautilus_undo_stack_action_data_set_create_data (common->undo_redo_data,
- dest,
- g_file_get_uri (job->src));
+ dest, uri);
+
+ g_free (uri);
}
} else {
@@ -5971,10 +6009,9 @@ create_job (GIOSchedulerJob *io_job,
common->cancellable,
&error);
- if (res) {
+ if (res && common->undo_redo_data != NULL) {
nautilus_undo_stack_action_data_set_create_data (common->undo_redo_data,
- dest,
- g_strdup (data));
+ dest, data);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]