# HG changeset patch # User nadvornik # Date 1238535234 0 # Node ID 331e2d60d44710d51bdc561d7d47917213d4a1ac # Parent 08f97835e816613914c1bff76da879b8751f61c9 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. diff -r 08f97835e816 -r 331e2d60d447 src/layout.c --- 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; } diff -r 08f97835e816 -r 331e2d60d447 src/view_file.c --- 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; diff -r 08f97835e816 -r 331e2d60d447 src/view_file.h --- 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); diff -r 08f97835e816 -r 331e2d60d447 src/view_file_icon.c --- 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) { diff -r 08f97835e816 -r 331e2d60d447 src/view_file_icon.h --- 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); diff -r 08f97835e816 -r 331e2d60d447 src/view_file_list.c --- 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++; diff -r 08f97835e816 -r 331e2d60d447 src/view_file_list.h --- 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);