changeset 2915:8536c3a680ea

Fix #664: Recursive slideshow does not respect file sorting https://github.com/BestImageViewer/geeqie/issues/664
author Colin Clark <colin.clark@cclark.uk>
date Mon, 08 Apr 2019 11:32:12 +0100
parents ea342d5f9d14
children ae6cdcd69d9f
files src/filedata.c src/filedata.h src/remote.c src/view_dir.c
diffstat 4 files changed, 49 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/filedata.c	Mon Apr 01 11:56:36 2019 +0100
+++ b/src/filedata.c	Mon Apr 08 11:32:12 2019 +0100
@@ -1633,6 +1633,33 @@
 		}
 }
 
+static void filelist_recursive_append_full(GList **list, GList *dirs, SortType method, gboolean ascend)
+{
+	GList *work;
+
+	work = dirs;
+	while (work)
+		{
+		FileData *fd = (FileData *)(work->data);
+		GList *f;
+		GList *d;
+
+		if (filelist_read(fd, &f, &d))
+			{
+			f = filelist_filter(f, FALSE);
+			f = filelist_sort_full(f, method, ascend, (GCompareFunc) filelist_sort_file_cb);
+			*list = g_list_concat(*list, f);
+
+			d = filelist_filter(d, TRUE);
+			d = filelist_sort_path(d);
+			filelist_recursive_append_full(list, d, method, ascend);
+			filelist_free(d);
+			}
+
+		work = work->next;
+		}
+}
+
 GList *filelist_recursive(FileData *dir_fd)
 {
 	GList *list;
@@ -1650,6 +1677,23 @@
 	return list;
 }
 
+GList *filelist_recursive_full(FileData *dir_fd, SortType method, gboolean ascend)
+{
+	GList *list;
+	GList *d;
+
+	if (!filelist_read(dir_fd, &list, &d)) return NULL;
+	list = filelist_filter(list, FALSE);
+	list = filelist_sort_full(list, method, ascend, (GCompareFunc) filelist_sort_file_cb);
+
+	d = filelist_filter(d, TRUE);
+	d = filelist_sort_path(d);
+	filelist_recursive_append_full(&list, d, method, ascend);
+	filelist_free(d);
+
+	return list;
+}
+
 /*
  *-----------------------------------------------------------------------------
  * file modification support
--- a/src/filedata.h	Mon Apr 01 11:56:36 2019 +0100
+++ b/src/filedata.h	Mon Apr 08 11:32:12 2019 +0100
@@ -86,6 +86,7 @@
 
 GList *filelist_sort_path(GList *list);
 GList *filelist_recursive(FileData *dir_fd);
+GList *filelist_recursive_full(FileData *dir_fd, SortType method, gboolean ascend);
 
 typedef gboolean (* FileDataGetMarkFunc)(FileData *fd, gint n, gpointer data);
 typedef gboolean (* FileDataSetMarkFunc)(FileData *fd, gint n, gboolean value, gpointer data);
--- a/src/remote.c	Mon Apr 01 11:56:36 2019 +0100
+++ b/src/remote.c	Mon Apr 08 11:32:12 2019 +0100
@@ -495,7 +495,9 @@
 {
 	GList *list;
 	FileData *dir_fd = file_data_new_dir(text);
-	list = filelist_recursive(dir_fd);
+
+	layout_valid(&lw_id);
+	list = filelist_recursive_full(dir_fd, lw_id->sort_method, lw_id->sort_ascend);
 	file_data_unref(dir_fd);
 	if (!list) return;
 //printf("length: %d\n", g_list_length(list));
--- a/src/view_dir.c	Mon Apr 01 11:56:36 2019 +0100
+++ b/src/view_dir.c	Mon Apr 08 11:32:12 2019 +0100
@@ -476,7 +476,7 @@
 	if (!vd->layout) return;
 	if (!vd->click_fd) return;
 
-	list = filelist_recursive(vd->click_fd);
+	list = filelist_recursive_full(vd->click_fd, vd->layout->sort_method, vd->layout->sort_ascend);
 
 	layout_image_slideshow_stop(vd->layout);
 	layout_image_slideshow_start_from_list(vd->layout, list);