[gthumb] Fixed bug 448585 - keep file selections after rename
- From: Michael J. Chudobiak <mjc src gnome org>
- To: svn-commits-list gnome org
- Subject: [gthumb] Fixed bug 448585 - keep file selections after rename
- Date: Tue, 26 May 2009 12:59:36 -0400 (EDT)
commit 07ea7db6084e6c466683a7ddd6cdf06c6a1d69fa
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date: Tue May 26 12:58:29 2009 -0400
Fixed bug 448585 - keep file selections after rename
---
libgthumb/file-utils.c | 15 ++++++++++++++-
libgthumb/gth-file-list.c | 20 +++++++++++---------
libgthumb/gth-file-list.h | 3 ++-
src/dlg-file-utils.c | 35 +----------------------------------
src/gth-browser.c | 4 ++--
5 files changed, 30 insertions(+), 47 deletions(-)
diff --git a/libgthumb/file-utils.c b/libgthumb/file-utils.c
index 4753416..12df768 100644
--- a/libgthumb/file-utils.c
+++ b/libgthumb/file-utils.c
@@ -1269,7 +1269,20 @@ gboolean
same_uri (const char *uri1,
const char *uri2)
{
- return uricmp (uri1, uri2) == 0;
+ FileData *fd1;
+ FileData *fd2;
+ gboolean result = FALSE;
+
+ fd1 = file_data_new (uri1);
+ fd2 = file_data_new (uri2);
+
+ if (strcmp (fd1->utf8_path, fd2->utf8_path) == 0)
+ result = TRUE;
+
+ file_data_unref (fd1);
+ file_data_unref (fd2);
+
+ return result;
}
diff --git a/libgthumb/gth-file-list.c b/libgthumb/gth-file-list.c
index 574929c..8fb7bca 100644
--- a/libgthumb/gth-file-list.c
+++ b/libgthumb/gth-file-list.c
@@ -1354,16 +1354,19 @@ gth_file_list_pos_from_path (GthFileList *file_list,
FileData *
gth_file_list_filedata_from_path (GthFileList *file_list,
- const char *path)
+ const char *path,
+ int *pos)
{
FileData *result = NULL;
GList *list, *scan;
+ int i=-1;
g_return_val_if_fail (file_list != NULL, NULL);
if (path == NULL)
return NULL;
+ i = 0;
list = gth_file_view_get_list (file_list->view);
for (scan = list; scan; scan = scan->next) {
FileData *fd = scan->data;
@@ -1371,9 +1374,13 @@ gth_file_list_filedata_from_path (GthFileList *file_list,
result = file_data_ref (fd);
break;
}
+ i++;
}
file_data_list_free (list);
+ if (pos != NULL)
+ *pos = i;
+
return result;
}
@@ -1620,7 +1627,7 @@ gfl_delete (GthFileList *file_list,
{
FileData *fd;
- fd = gth_file_list_filedata_from_path (file_list, uri);
+ fd = gth_file_list_filedata_from_path (file_list, uri, NULL);
if (fd != NULL) {
gth_file_view_remove (file_list->view, fd);
file_data_unref (fd);
@@ -1669,7 +1676,7 @@ gfl_rename (GthFileList *file_list,
FileData *fd;
int pos;
- fd = gth_file_list_filedata_from_path (file_list, from_uri);
+ fd = gth_file_list_filedata_from_path (file_list, from_uri, &pos);
if (fd == NULL)
return;
@@ -1679,7 +1686,6 @@ gfl_rename (GthFileList *file_list,
/* Set the new name. */
- pos = gth_file_list_pos_from_path (file_list, from_uri);
if (pos != -1) {
gth_file_view_set_image_text (file_list->view, pos, fd->utf8_name);
gth_file_view_sorted (file_list->view,
@@ -1744,11 +1750,7 @@ gfl_update_thumb (GthFileList *file_list,
FileData *fd;
int pos;
- pos = gth_file_list_pos_from_path (file_list, uri);
- if (pos == -1)
- return;
-
- fd = gth_file_list_filedata_from_path (file_list, uri);
+ fd = gth_file_list_filedata_from_path (file_list, uri, &pos);
if (fd == NULL)
return;
diff --git a/libgthumb/gth-file-list.h b/libgthumb/gth-file-list.h
index 4ba49c3..52a5368 100644
--- a/libgthumb/gth-file-list.h
+++ b/libgthumb/gth-file-list.h
@@ -83,7 +83,8 @@ void gth_file_list_set_sort_type (GthFileList *file_list,
GtkSortType sort_type,
gboolean update);
FileData * gth_file_list_filedata_from_path (GthFileList *file_list,
- const char *path);
+ const char *path,
+ int *pos);
int gth_file_list_pos_from_path (GthFileList *file_list,
const char *path);
GList* gth_file_list_get_all (GthFileList *file_list);
diff --git a/src/dlg-file-utils.c b/src/dlg-file-utils.c
index bd2805d..519b4fb 100644
--- a/src/dlg-file-utils.c
+++ b/src/dlg-file-utils.c
@@ -930,27 +930,6 @@ dlg_overwrite_run (GthWindow *window,
}
-static GList *
-my_list_remove (GList *list,
- const char *path)
-{
- GList *link;
-
- if (list == NULL)
- return NULL;
-
- link = g_list_find_custom (list, path, (GCompareFunc) uricmp);
- if (link == NULL)
- return list;
-
- list = g_list_remove_link (list, link);
- g_free (link->data);
- g_list_free (link);
-
- return list;
-}
-
-
void
dlg_file_rename_series (GthWindow *window,
GList *old_names,
@@ -961,8 +940,6 @@ dlg_file_rename_series (GthWindow *window,
int overwrite_result = OVERWRITE_RESULT_UNSPECIFIED;
gboolean file_exists, show_ow_all_none;
gboolean error = FALSE;
- GList *files_deleted = NULL;
- GList *files_created = NULL;
char *last_error_message;
gth_monitor_pause ();
@@ -1030,13 +1007,7 @@ dlg_file_rename_series (GthWindow *window,
if (gerror == NULL) {
cache_move (old_full_path, new_full_path);
comment_move (old_full_path, new_full_path);
-
- files_deleted = g_list_prepend (files_deleted, g_strdup (old_full_path));
- files_created = g_list_prepend (files_created, g_strdup (new_full_path));
-
- files_deleted = my_list_remove (files_deleted, new_full_path);
- files_created = my_list_remove (files_created, old_full_path);
-
+ gth_monitor_notify_file_renamed (old_full_path, new_full_path);
o_scan = o_scan->next;
}
else {
@@ -1054,8 +1025,6 @@ dlg_file_rename_series (GthWindow *window,
n_scan = n_scan->next;
}
- gth_monitor_notify_update_files (GTH_MONITOR_EVENT_DELETED, files_deleted);
- gth_monitor_notify_update_files (GTH_MONITOR_EVENT_CREATED, files_created);
gth_monitor_resume ();
if (error) {
@@ -1075,8 +1044,6 @@ dlg_file_rename_series (GthWindow *window,
path_list_free (error_list);
path_list_free (old_names);
path_list_free (new_names);
- path_list_free (files_deleted);
- path_list_free (files_created);
g_free (last_error_message);
}
diff --git a/src/gth-browser.c b/src/gth-browser.c
index 5d5c1f8..fabd82b 100644
--- a/src/gth-browser.c
+++ b/src/gth-browser.c
@@ -5570,8 +5570,8 @@ gth_browser_notify_files_changed (GthBrowser *browser,
for (scan = list; scan; scan = scan->next) {
char *filename = scan->data;
FileData *fd;
-
- fd = gth_file_list_filedata_from_path (priv->file_list, filename);
+
+ fd = gth_file_list_filedata_from_path (priv->file_list, filename, NULL);
if (fd != NULL) {
file_data_unref (fd);
continue;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]