mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-07-05 01:41:28 +00:00
batch-rename-utilities: Remove reordering function
This function doesn't work when there are cycles. Remove it in favor of a another solution.
This commit is contained in:
parent
fcffac9f6e
commit
b8881bb946
|
@ -422,9 +422,6 @@ static void
|
||||||
begin_batch_rename (NautilusBatchRenameDialog *dialog,
|
begin_batch_rename (NautilusBatchRenameDialog *dialog,
|
||||||
GList *new_names)
|
GList *new_names)
|
||||||
{
|
{
|
||||||
batch_rename_sort_lists_for_rename (&dialog->selection, &new_names, NULL, NULL, NULL, FALSE);
|
|
||||||
|
|
||||||
/* do the actual rename here */
|
|
||||||
nautilus_file_batch_rename (dialog->selection, new_names, NULL, NULL);
|
nautilus_file_batch_rename (dialog->selection, new_names, NULL, NULL);
|
||||||
|
|
||||||
gtk_widget_set_cursor (GTK_WIDGET (dialog->window), NULL);
|
gtk_widget_set_cursor (GTK_WIDGET (dialog->window), NULL);
|
||||||
|
|
|
@ -142,124 +142,6 @@ batch_rename_replace (gchar *string,
|
||||||
return new_string;
|
return new_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
batch_rename_sort_lists_for_rename (GList **selection,
|
|
||||||
GList **new_names,
|
|
||||||
GList **old_names,
|
|
||||||
GList **new_files,
|
|
||||||
GList **old_files,
|
|
||||||
gboolean is_undo_redo)
|
|
||||||
{
|
|
||||||
GList *new_names_list;
|
|
||||||
GList *new_names_list2;
|
|
||||||
GList *files;
|
|
||||||
GList *files2;
|
|
||||||
GList *old_names_list = NULL;
|
|
||||||
GList *new_files_list = NULL;
|
|
||||||
GList *old_files_list = NULL;
|
|
||||||
GList *old_names_list2 = NULL;
|
|
||||||
GList *new_files_list2 = NULL;
|
|
||||||
GList *old_files_list2 = NULL;
|
|
||||||
GString *new_file_name;
|
|
||||||
GString *new_name;
|
|
||||||
GString *old_name;
|
|
||||||
GFile *new_file;
|
|
||||||
GFile *old_file;
|
|
||||||
NautilusFile *file;
|
|
||||||
gboolean order_changed = TRUE;
|
|
||||||
|
|
||||||
/* in the following case:
|
|
||||||
* file1 -> file2
|
|
||||||
* file2 -> file3
|
|
||||||
* file2 must be renamed first, so because of that, the list has to be reordered
|
|
||||||
*/
|
|
||||||
while (order_changed)
|
|
||||||
{
|
|
||||||
order_changed = FALSE;
|
|
||||||
|
|
||||||
if (is_undo_redo)
|
|
||||||
{
|
|
||||||
old_names_list = *old_names;
|
|
||||||
new_files_list = *new_files;
|
|
||||||
old_files_list = *old_files;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (new_names_list = *new_names, files = *selection;
|
|
||||||
new_names_list != NULL && files != NULL;
|
|
||||||
new_names_list = new_names_list->next, files = files->next)
|
|
||||||
{
|
|
||||||
g_autoptr (NautilusFile) parent = NULL;
|
|
||||||
|
|
||||||
new_file_name = new_names_list->data;
|
|
||||||
parent = nautilus_file_get_parent (NAUTILUS_FILE (files->data));
|
|
||||||
|
|
||||||
if (is_undo_redo)
|
|
||||||
{
|
|
||||||
old_names_list2 = old_names_list;
|
|
||||||
new_files_list2 = new_files_list;
|
|
||||||
old_files_list2 = old_files_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (files2 = files, new_names_list2 = new_names_list;
|
|
||||||
files2 != NULL && new_names_list2 != NULL;
|
|
||||||
files2 = files2->next, new_names_list2 = new_names_list2->next)
|
|
||||||
{
|
|
||||||
const char *file_name;
|
|
||||||
g_autoptr (NautilusFile) parent2 = NULL;
|
|
||||||
|
|
||||||
file_name = nautilus_file_get_name (NAUTILUS_FILE (files2->data));
|
|
||||||
new_name = new_names_list2->data;
|
|
||||||
|
|
||||||
parent2 = nautilus_file_get_parent (NAUTILUS_FILE (files2->data));
|
|
||||||
|
|
||||||
if (files2 != files && g_strcmp0 (file_name, new_file_name->str) == 0 &&
|
|
||||||
parent == parent2)
|
|
||||||
{
|
|
||||||
file = NAUTILUS_FILE (files2->data);
|
|
||||||
|
|
||||||
*selection = g_list_remove_link (*selection, files2);
|
|
||||||
*new_names = g_list_remove_link (*new_names, new_names_list2);
|
|
||||||
|
|
||||||
*selection = g_list_prepend (*selection, file);
|
|
||||||
*new_names = g_list_prepend (*new_names, new_name);
|
|
||||||
|
|
||||||
if (is_undo_redo)
|
|
||||||
{
|
|
||||||
old_name = old_names_list2->data;
|
|
||||||
new_file = new_files_list2->data;
|
|
||||||
old_file = old_files_list2->data;
|
|
||||||
|
|
||||||
*old_names = g_list_remove_link (*old_names, old_names_list2);
|
|
||||||
*new_files = g_list_remove_link (*new_files, new_files_list2);
|
|
||||||
*old_files = g_list_remove_link (*old_files, old_files_list2);
|
|
||||||
|
|
||||||
*old_names = g_list_prepend (*old_names, old_name);
|
|
||||||
*new_files = g_list_prepend (*new_files, new_file);
|
|
||||||
*old_files = g_list_prepend (*old_files, old_file);
|
|
||||||
}
|
|
||||||
|
|
||||||
order_changed = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_undo_redo)
|
|
||||||
{
|
|
||||||
old_names_list2 = old_names_list2->next;
|
|
||||||
new_files_list2 = new_files_list2->next;
|
|
||||||
old_files_list2 = old_files_list2->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_undo_redo)
|
|
||||||
{
|
|
||||||
old_names_list = old_names_list->next;
|
|
||||||
new_files_list = new_files_list->next;
|
|
||||||
old_files_list = old_files_list->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This function changes the background color of the replaced part of the name */
|
/* This function changes the background color of the replaced part of the name */
|
||||||
GString *
|
GString *
|
||||||
batch_rename_replace_label_text (const char *label,
|
batch_rename_replace_label_text (const char *label,
|
||||||
|
|
|
@ -61,10 +61,3 @@ GString* batch_rename_replace_label_text (const char *label,
|
||||||
const gchar *substr);
|
const gchar *substr);
|
||||||
|
|
||||||
gchar* batch_rename_get_tag_text_representation (TagConstants tag_constants);
|
gchar* batch_rename_get_tag_text_representation (TagConstants tag_constants);
|
||||||
|
|
||||||
void batch_rename_sort_lists_for_rename (GList **selection,
|
|
||||||
GList **new_names,
|
|
||||||
GList **old_names,
|
|
||||||
GList **new_files,
|
|
||||||
GList **old_files,
|
|
||||||
gboolean is_undo_redo);
|
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#include "nautilus-file.h"
|
#include "nautilus-file.h"
|
||||||
#include "nautilus-file-undo-manager.h"
|
#include "nautilus-file-undo-manager.h"
|
||||||
#include "nautilus-batch-rename-dialog.h"
|
#include "nautilus-batch-rename-dialog.h"
|
||||||
#include "nautilus-batch-rename-utilities.h"
|
|
||||||
#include "nautilus-scheme.h"
|
#include "nautilus-scheme.h"
|
||||||
#include "nautilus-tag-manager.h"
|
#include "nautilus-tag-manager.h"
|
||||||
|
|
||||||
|
@ -1200,13 +1199,6 @@ batch_rename_redo_func (NautilusFileUndoInfo *info,
|
||||||
|
|
||||||
files = g_list_reverse (files);
|
files = g_list_reverse (files);
|
||||||
|
|
||||||
batch_rename_sort_lists_for_rename (&files,
|
|
||||||
&self->new_display_names,
|
|
||||||
&self->old_display_names,
|
|
||||||
&self->new_files,
|
|
||||||
&self->old_files,
|
|
||||||
TRUE);
|
|
||||||
|
|
||||||
nautilus_file_batch_rename (files, self->new_display_names, file_undo_info_operation_callback, self);
|
nautilus_file_batch_rename (files, self->new_display_names, file_undo_info_operation_callback, self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1233,13 +1225,6 @@ batch_rename_undo_func (NautilusFileUndoInfo *info,
|
||||||
|
|
||||||
files = g_list_reverse (files);
|
files = g_list_reverse (files);
|
||||||
|
|
||||||
batch_rename_sort_lists_for_rename (&files,
|
|
||||||
&self->old_display_names,
|
|
||||||
&self->new_display_names,
|
|
||||||
&self->old_files,
|
|
||||||
&self->new_files,
|
|
||||||
TRUE);
|
|
||||||
|
|
||||||
nautilus_file_batch_rename (files, self->old_display_names, file_undo_info_operation_callback, self);
|
nautilus_file_batch_rename (files, self->old_display_names, file_undo_info_operation_callback, self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user