Mercurial > geeqie.yaz
changeset 1503:331e2d60d447
improved next/prev operation on sidecar files
all operations with list index seem to be broken but IMHO this fix is
sufficient for 1.0. Then it definitely needs a better interface.
author | nadvornik |
---|---|
date | Tue, 31 Mar 2009 21:33:54 +0000 |
parents | 08f97835e816 |
children | 1e2737565cb7 |
files | src/layout.c src/view_file.c src/view_file.h src/view_file_icon.c src/view_file_icon.h src/view_file_list.c src/view_file_list.h |
diffstat | 7 files changed, 21 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/src/layout.c Tue Mar 31 20:57:31 2009 +0000 +++ b/src/layout.c Tue Mar 31 21:33:54 2009 +0000 @@ -975,7 +975,7 @@ { if (!layout_valid(&lw) || !fd) return -1; - if (lw->vf) return vf_index_by_path(lw->vf, fd->path); + if (lw->vf) return vf_index_by_fd(lw->vf, fd); return -1; }
--- a/src/view_file.c Tue Mar 31 20:57:31 2009 +0000 +++ b/src/view_file.c Tue Mar 31 21:33:54 2009 +0000 @@ -66,14 +66,14 @@ return fd; } -gint vf_index_by_path(ViewFile *vf, const gchar *path) +gint vf_index_by_fd(ViewFile *vf, FileData *fd) { gint index = -1; switch (vf->type) { - case FILEVIEW_LIST: index = vflist_index_by_path(vf, path); break; - case FILEVIEW_ICON: index = vficon_index_by_path(vf, path); break; + case FILEVIEW_LIST: index = vflist_index_by_fd(vf, fd); break; + case FILEVIEW_ICON: index = vficon_index_by_fd(vf, fd); break; } return index;
--- a/src/view_file.h Tue Mar 31 20:57:31 2009 +0000 +++ b/src/view_file.h Tue Mar 31 21:33:54 2009 +0000 @@ -40,7 +40,6 @@ GtkWidget *vf_pop_menu(ViewFile *vf); FileData *vf_index_get_data(ViewFile *vf, gint row); -gint vf_index_by_path(ViewFile *vf, const gchar *path); gint vf_index_by_fd(ViewFile *vf, FileData *in_fd); guint vf_count(ViewFile *vf, gint64 *bytes); GList *vf_get_list(ViewFile *vf);
--- a/src/view_file_icon.c Tue Mar 31 20:57:31 2009 +0000 +++ b/src/view_file_icon.c Tue Mar 31 21:33:54 2009 +0000 @@ -2054,25 +2054,6 @@ return id ? id->fd : NULL; } -gint vficon_index_by_path(ViewFile *vf, const gchar *path) -{ - gint p = 0; - GList *work; - - if (!path) return -1; - - work = vf->list; - while (work) - { - IconData *id = work->data; - FileData *fd = id->fd; - if (strcmp(path, fd->path) == 0) return p; - work = work->next; - p++; - } - - return -1; -} gint vficon_index_by_fd(ViewFile *vf, FileData *in_fd) {
--- a/src/view_file_icon.h Tue Mar 31 20:57:31 2009 +0000 +++ b/src/view_file_icon.h Tue Mar 31 21:33:54 2009 +0000 @@ -37,7 +37,6 @@ void vficon_pop_menu_show_names_cb(GtkWidget *widget, gpointer data); FileData *vficon_index_get_data(ViewFile *vf, gint row); -gint vficon_index_by_path(ViewFile *vf, const gchar *path); gint vficon_index_by_fd(ViewFile *vf, FileData *in_fd); guint vficon_count(ViewFile *vf, gint64 *bytes); GList *vficon_get_list(ViewFile *vf);
--- a/src/view_file_list.c Tue Mar 31 20:57:31 2009 +0000 +++ b/src/view_file_list.c Tue Mar 31 21:33:54 2009 +0000 @@ -1217,18 +1217,28 @@ return g_list_nth_data(vf->list, row); } -gint vflist_index_by_path(ViewFile *vf, const gchar *path) +gint vflist_index_by_fd(ViewFile *vf, FileData *fd) { gint p = 0; - GList *work; - - if (!path) return -1; + GList *work, *work2; work = vf->list; while (work) { - FileData *fd = work->data; - if (strcmp(path, fd->path) == 0) return p; + FileData *list_fd = work->data; + if (list_fd == fd) return p; + + work2 = list_fd->sidecar_files; + while (work2) + { + /* FIXME: return the same index also for sidecars + it is sufficient for next/prev navigation but it should be rewritten + without using indexes at all + */ + FileData *sidecar_fd = work2->data; + if (sidecar_fd == fd) return p; + work2 = work2->next; + } work = work->next; p++;
--- a/src/view_file_list.h Tue Mar 31 20:57:31 2009 +0000 +++ b/src/view_file_list.h Tue Mar 31 21:33:54 2009 +0000 @@ -40,7 +40,7 @@ void vflist_pop_menu_thumbs_cb(GtkWidget *widget, gpointer data); FileData *vflist_index_get_data(ViewFile *vf, gint row); -gint vflist_index_by_path(ViewFile *vf, const gchar *path); +gint vflist_index_by_fd(ViewFile *vf, FileData *fd); guint vflist_count(ViewFile *vf, gint64 *bytes); GList *vflist_get_list(ViewFile *vf);