improved next/prev operation on sidecar files
authorVladimir Nadvornik <nadvornik@suse.cz>
Tue, 31 Mar 2009 21:33:54 +0000 (21:33 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Tue, 31 Mar 2009 21:33:54 +0000 (21:33 +0000)
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.

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

index 26bd75b..d4209f3 100644 (file)
@@ -975,7 +975,7 @@ gint layout_list_get_index(LayoutWindow *lw, FileData *fd)
 {
        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;
 }
index b653bfc..7e35dec 100644 (file)
@@ -66,14 +66,14 @@ FileData *vf_index_get_data(ViewFile *vf, gint row)
        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;
index f9cfca8..b6a4714 100644 (file)
@@ -40,7 +40,6 @@ GList *vf_pop_menu_file_list(ViewFile *vf);
 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);
index 8387950..42eeb6f 100644 (file)
@@ -2054,25 +2054,6 @@ FileData *vficon_index_get_data(ViewFile *vf, gint row)
        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)
 {
index e5fc484..d0561ef 100644 (file)
@@ -37,7 +37,6 @@ void vficon_popup_destroy_cb(GtkWidget *widget, gpointer data);
 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);
index 462a2e3..13fc527 100644 (file)
@@ -1217,18 +1217,28 @@ FileData *vflist_index_get_data(ViewFile *vf, gint row)
        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++;
index fd46eb8..4b2a36c 100644 (file)
@@ -40,7 +40,7 @@ void vflist_popup_destroy_cb(GtkWidget *widget, gpointer data);
 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);