[nautilus] file-undo-manager: handle undo_redo_flag internally
- From: Răzvan-Mihai Chițu <razvanchitu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] file-undo-manager: handle undo_redo_flag internally
- Date: Tue, 12 Jan 2016 19:37:09 +0000 (UTC)
commit d52c523414a9fde659c22c1446494ccee9354ec1
Author: Razvan Chitu <razvan ch95 gmail com>
Date: Fri Jan 8 23:42:51 2016 +0200
file-undo-manager: handle undo_redo_flag internally
Nautilus undo manager reuses undo information based on a flag that marks whether
an undo / redo operation is currently being performed. Previously, the flag was
managed both internally and externally. This proved to be unnecessary and even
harmful, as it led to an unexpected behavior.
Remove push and pop functions and handle the flag explicitly, at the start and
at the end of an undo / redo operation. Replace external use of pop with the use
of a getter function, also introduced in this patch.
https://bugzilla.gnome.org/show_bug.cgi?id=759850
libnautilus-private/nautilus-file-operations.c | 18 +++++++-------
libnautilus-private/nautilus-file-undo-manager.c | 26 ++++---------------
libnautilus-private/nautilus-file-undo-manager.h | 3 +-
.../nautilus-file-undo-operations.c | 7 -----
libnautilus-private/nautilus-file.c | 8 +++---
5 files changed, 20 insertions(+), 42 deletions(-)
---
diff --git a/libnautilus-private/nautilus-file-operations.c b/libnautilus-private/nautilus-file-operations.c
index c48bbb3..2b5fc58 100644
--- a/libnautilus-private/nautilus-file-operations.c
+++ b/libnautilus-private/nautilus-file-operations.c
@@ -2231,7 +2231,7 @@ trash_or_delete_internal (GList *files,
inhibit_power_manager ((CommonJob *)job, _("Deleting Files"));
}
- if (!nautilus_file_undo_manager_pop_flag () && try_trash) {
+ if (!nautilus_file_undo_manager_get_flag () && try_trash) {
job->common.undo_info = nautilus_file_undo_info_trash_new (g_list_length (files));
}
@@ -5126,7 +5126,7 @@ nautilus_file_operations_copy (GList *files,
inhibit_power_manager ((CommonJob *)job, _("Copying Files"));
- if (!nautilus_file_undo_manager_pop_flag ()) {
+ if (!nautilus_file_undo_manager_get_flag ()) {
GFile* src_dir;
src_dir = g_file_get_parent (files->data);
@@ -5667,7 +5667,7 @@ nautilus_file_operations_move (GList *files,
inhibit_power_manager ((CommonJob *)job, _("Moving Files"));
- if (!nautilus_file_undo_manager_pop_flag ()) {
+ if (!nautilus_file_undo_manager_get_flag ()) {
GFile* src_dir;
src_dir = g_file_get_parent (files->data);
@@ -5994,7 +5994,7 @@ nautilus_file_operations_link (GList *files,
}
job->debuting_files = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, g_object_unref,
NULL);
- if (!nautilus_file_undo_manager_pop_flag ()) {
+ if (!nautilus_file_undo_manager_get_flag ()) {
GFile* src_dir;
src_dir = g_file_get_parent (files->data);
@@ -6042,7 +6042,7 @@ nautilus_file_operations_duplicate (GList *files,
}
job->debuting_files = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, g_object_unref,
NULL);
- if (!nautilus_file_undo_manager_pop_flag ()) {
+ if (!nautilus_file_undo_manager_get_flag ()) {
GFile* src_dir;
src_dir = g_file_get_parent (files->data);
@@ -6214,7 +6214,7 @@ nautilus_file_set_permissions_recursive (const char *directory,
job->done_callback = callback;
job->done_callback_data = callback_data;
- if (!nautilus_file_undo_manager_pop_flag ()) {
+ if (!nautilus_file_undo_manager_get_flag ()) {
job->common.undo_info =
nautilus_file_undo_info_rec_permissions_new (job->file,
file_permissions, file_mask,
@@ -6739,7 +6739,7 @@ nautilus_file_operations_new_folder (GtkWidget *parent_view,
job->has_position = TRUE;
}
- if (!nautilus_file_undo_manager_pop_flag ()) {
+ if (!nautilus_file_undo_manager_get_flag ()) {
job->common.undo_info = nautilus_file_undo_info_create_new
(NAUTILUS_FILE_UNDO_OP_CREATE_FOLDER);
}
@@ -6781,7 +6781,7 @@ nautilus_file_operations_new_file_from_template (GtkWidget *parent_view,
job->src = g_file_new_for_uri (template_uri);
}
- if (!nautilus_file_undo_manager_pop_flag ()) {
+ if (!nautilus_file_undo_manager_get_flag ()) {
job->common.undo_info = nautilus_file_undo_info_create_new
(NAUTILUS_FILE_UNDO_OP_CREATE_FILE_FROM_TEMPLATE);
}
@@ -6822,7 +6822,7 @@ nautilus_file_operations_new_file (GtkWidget *parent_view,
job->length = length;
job->filename = g_strdup (target_filename);
- if (!nautilus_file_undo_manager_pop_flag ()) {
+ if (!nautilus_file_undo_manager_get_flag ()) {
job->common.undo_info = nautilus_file_undo_info_create_new
(NAUTILUS_FILE_UNDO_OP_CREATE_EMPTY_FILE);
}
diff --git a/libnautilus-private/nautilus-file-undo-manager.c
b/libnautilus-private/nautilus-file-undo-manager.c
index 497e3d1..7de9701 100644
--- a/libnautilus-private/nautilus-file-undo-manager.c
+++ b/libnautilus-private/nautilus-file-undo-manager.c
@@ -158,6 +158,8 @@ undo_info_apply_ready (GObject *source,
success = nautilus_file_undo_info_apply_finish (info, res, &user_cancel, NULL);
+ self->priv->undo_redo_flag = FALSE;
+
/* just return in case we got another another operation set */
if ((self->priv->info != NULL) &&
(self->priv->info != info)) {
@@ -189,8 +191,8 @@ do_undo_redo (NautilusFileUndoManager *self,
gboolean undo = self->priv->state == NAUTILUS_FILE_UNDO_MANAGER_STATE_UNDO;
self->priv->last_state = self->priv->state;
-
- nautilus_file_undo_manager_push_flag ();
+
+ self->priv->undo_redo_flag = TRUE;
nautilus_file_undo_info_apply_async (self->priv->info, undo, parent_window,
undo_info_apply_ready, self);
@@ -261,28 +263,12 @@ nautilus_file_undo_manager_get_state (void)
return self->priv->state;
}
-void
-nautilus_file_undo_manager_push_flag ()
-{
- NautilusFileUndoManager *self = get_singleton ();
- NautilusFileUndoManagerPrivate *priv = self->priv;
-
- priv->undo_redo_flag = TRUE;
-}
gboolean
-nautilus_file_undo_manager_pop_flag ()
+nautilus_file_undo_manager_get_flag ()
{
NautilusFileUndoManager *self = get_singleton ();
- NautilusFileUndoManagerPrivate *priv = self->priv;
- gboolean retval = FALSE;
-
- if (priv->undo_redo_flag) {
- retval = TRUE;
- }
-
- priv->undo_redo_flag = FALSE;
- return retval;
+ return self->priv->undo_redo_flag;
}
NautilusFileUndoManager *
diff --git a/libnautilus-private/nautilus-file-undo-manager.h
b/libnautilus-private/nautilus-file-undo-manager.h
index f8d8ccd..8163a32 100644
--- a/libnautilus-private/nautilus-file-undo-manager.h
+++ b/libnautilus-private/nautilus-file-undo-manager.h
@@ -79,7 +79,6 @@ NautilusFileUndoManagerState nautilus_file_undo_manager_get_state (void);
void nautilus_file_undo_manager_undo (GtkWindow *parent_window);
void nautilus_file_undo_manager_redo (GtkWindow *parent_window);
-void nautilus_file_undo_manager_push_flag (void);
-gboolean nautilus_file_undo_manager_pop_flag (void);
+gboolean nautilus_file_undo_manager_get_flag (void);
#endif /* __NAUTILUS_FILE_UNDO_MANAGER_H__ */
diff --git a/libnautilus-private/nautilus-file-undo-operations.c
b/libnautilus-private/nautilus-file-undo-operations.c
index 6a47223..7201ced 100644
--- a/libnautilus-private/nautilus-file-undo-operations.c
+++ b/libnautilus-private/nautilus-file-undo-operations.c
@@ -1218,9 +1218,6 @@ trash_undo_func (NautilusFileUndoInfo *info,
{
NautilusFileUndoInfoTrash *self = NAUTILUS_FILE_UNDO_INFO_TRASH (info);
- /* Internally managed op, pop flag. */
- nautilus_file_undo_manager_pop_flag ();
-
trash_retrieve_files_to_restore_async (self, trash_retrieve_files_ready, NULL);
}
@@ -1349,10 +1346,6 @@ rec_permissions_undo_func (NautilusFileUndoInfo *info,
{
NautilusFileUndoInfoRecPermissions *self = NAUTILUS_FILE_UNDO_INFO_REC_PERMISSIONS (info);
- /* Internally managed op, pop flag. */
- /* TODO: why? */
- nautilus_file_undo_manager_pop_flag ();
-
if (g_hash_table_size (self->priv->original_permissions) > 0) {
GList *gfiles_list;
guint32 perm;
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index e1219f6..9f809b2 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -1970,7 +1970,7 @@ nautilus_file_rename (NautilusFile *file,
location = nautilus_file_get_location (file);
/* Tell the undo manager a rename is taking place */
- if (!nautilus_file_undo_manager_pop_flag ()) {
+ if (!nautilus_file_undo_manager_get_flag ()) {
op->undo_info = nautilus_file_undo_info_rename_new ();
old_name = nautilus_file_get_display_name (file);
@@ -5249,7 +5249,7 @@ nautilus_file_set_permissions (NautilusFile *file,
return;
}
- if (!nautilus_file_undo_manager_pop_flag ()) {
+ if (!nautilus_file_undo_manager_get_flag ()) {
NautilusFileUndoInfo *undo_info;
undo_info = nautilus_file_undo_info_permissions_new (nautilus_file_get_location (file),
@@ -5562,7 +5562,7 @@ nautilus_file_set_owner (NautilusFile *file,
return;
}
- if (!nautilus_file_undo_manager_pop_flag ()) {
+ if (!nautilus_file_undo_manager_get_flag ()) {
NautilusFileUndoInfo *undo_info;
char* current_owner;
@@ -5840,7 +5840,7 @@ nautilus_file_set_group (NautilusFile *file,
return;
}
- if (!nautilus_file_undo_manager_pop_flag ()) {
+ if (!nautilus_file_undo_manager_get_flag ()) {
NautilusFileUndoInfo *undo_info;
char *current_group;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]