{
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;
}
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;
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);
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)
{
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);
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++;
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);