[nautilus] batch-rename: use nautilus files for cleaner code
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] batch-rename: use nautilus files for cleaner code
- Date: Tue, 20 Sep 2016 14:45:58 +0000 (UTC)
commit b5a906a1d86137a78a03b680c0f373c6acdac886
Author: Carlos Soriano <csoriano gnome org>
Date: Thu Sep 15 18:11:33 2016 +0200
batch-rename: use nautilus files for cleaner code
We were using gchar* for uris, instead of actual files, and converting
back and forward.
Instead use directly nautilus files.
src/nautilus-batch-rename-dialog.c | 6 +---
src/nautilus-batch-rename-utilities.c | 41 +++++++++++++++-----------------
2 files changed, 21 insertions(+), 26 deletions(-)
---
diff --git a/src/nautilus-batch-rename-dialog.c b/src/nautilus-batch-rename-dialog.c
index 8e3008f..0f259b2 100644
--- a/src/nautilus-batch-rename-dialog.c
+++ b/src/nautilus-batch-rename-dialog.c
@@ -1288,10 +1288,8 @@ file_names_list_has_duplicates_async_thread (GTask *task,
g_mutex_lock (&task_data->wait_ready_mutex);
task_data->directory_conflicts_ready = FALSE;
- directory_conflict_uri = l->data;
- conflict_directory = nautilus_directory_get_by_uri (directory_conflict_uri);
- nautilus_directory_call_when_ready (conflict_directory,
+ nautilus_directory_call_when_ready (l->data,
NAUTILUS_FILE_ATTRIBUTE_INFO,
TRUE,
on_directory_conflicts_ready,
@@ -1307,10 +1305,10 @@ file_names_list_has_duplicates_async_thread (GTask *task,
g_mutex_unlock (&task_data->wait_ready_mutex);
- nautilus_directory_unref (conflict_directory);
}
g_task_return_boolean (task, TRUE);
+ nautilus_directory_list_free (directories);
}
static void
diff --git a/src/nautilus-batch-rename-utilities.c b/src/nautilus-batch-rename-utilities.c
index 3a855ac..1b09ef1 100644
--- a/src/nautilus-batch-rename-utilities.c
+++ b/src/nautilus-batch-rename-utilities.c
@@ -995,42 +995,39 @@ check_metadata_for_selection (NautilusBatchRenameDialog *dialog,
g_string_free (query, TRUE);
}
+static gint
+compare_files (gpointer a,
+ gpointer b)
+{
+ NautilusFile *file1 = NAUTILUS_FILE (a);
+ NautilusFile *file2 = NAUTILUS_FILE (b);
+ g_autoptr (GFile) location1 = nautilus_file_get_location (file1);
+ g_autoptr (GFile) location2 = nautilus_file_get_location (file2);
+
+ return g_file_equal (location1, location2) ? 0 : 1;
+}
+
GList *
batch_rename_files_get_distinct_parents (GList *selection)
{
GList *result;
GList *l1;
- GList *l2;
NautilusFile *file;
- gboolean exists;
- gchar *parent_uri;
+ NautilusFile *directory;
+ GFile *parent;
result = NULL;
-
for (l1 = selection; l1 != NULL; l1 = l1->next)
{
- exists = FALSE;
-
file = NAUTILUS_FILE (l1->data);
- parent_uri = nautilus_file_get_parent_uri (file);
-
- for (l2 = result; l2 != NULL; l2 = l2->next)
+ parent = nautilus_file_get_parent (file);
+ directory = nautilus_directory_get_for_file (parent);
+ if (!g_list_find (result, directory))
{
- if (g_strcmp0 (parent_uri, l2->data) == 0)
- {
- exists = TRUE;
- break;
- }
+ result = g_list_prepend (result, directory);
}
- if (!exists)
- {
- result = g_list_prepend (result, parent_uri);
- }
- else
- {
- g_free (parent_uri);
- }
+ nautilus_file_unref (parent);
}
return result;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]