aboutsummaryrefslogtreecommitdiff
path: root/fastiv-browser.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-11-21 21:05:45 +0100
committerPřemysl Eric Janouch <p@janouch.name>2021-11-21 21:07:51 +0100
commit1c57eef05ad73dadc3d647c973be9f37fde13a81 (patch)
treebc39287188f9b88c0be8d93915182e3d33eed452 /fastiv-browser.c
parent5fea2245f119029f6b2699dda11aaf8f5e461e4e (diff)
downloadfiv-1c57eef05ad73dadc3d647c973be9f37fde13a81.tar.gz
fiv-1c57eef05ad73dadc3d647c973be9f37fde13a81.tar.xz
fiv-1c57eef05ad73dadc3d647c973be9f37fde13a81.zip
Sort files in the browser as well
Diffstat (limited to 'fastiv-browser.c')
-rw-r--r--fastiv-browser.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/fastiv-browser.c b/fastiv-browser.c
index 09d7ab0..955f6a1 100644
--- a/fastiv-browser.c
+++ b/fastiv-browser.c
@@ -768,6 +768,19 @@ fastiv_browser_init(FastivBrowser *self)
// --- Public interface --------------------------------------------------------
+static gint
+entry_compare(gconstpointer a, gconstpointer b)
+{
+ const Entry *entry1 = a;
+ const Entry *entry2 = b;
+ GFile *location1 = g_file_new_for_path(entry1->filename);
+ GFile *location2 = g_file_new_for_path(entry2->filename);
+ gint result = fastiv_io_filecmp(location1, location2);
+ g_object_unref(location1);
+ g_object_unref(location2);
+ return result;
+}
+
void
fastiv_browser_load(
FastivBrowser *self, FastivBrowserFilterCallback cb, const char *path)
@@ -791,8 +804,6 @@ fastiv_browser_load(
break;
if (g_file_info_get_file_type(info) == G_FILE_TYPE_DIRECTORY)
continue;
-
- // TODO(p): Support being passed a sort function.
if (cb && !cb(g_file_info_get_name(info)))
continue;
@@ -801,6 +812,8 @@ fastiv_browser_load(
}
g_object_unref(enumerator);
- // TODO(p): Sort the entries before.
+ // TODO(p): Support being passed a sort function.
+ g_array_sort(self->entries, entry_compare);
+
reload_thumbnails(self);
}