diff src/view_file_list.c @ 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 bc3f5c0432f6
children d352a44545a6
line wrap: on
line diff
--- 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++;