gtk4/0001-filerchooser-Show-Recent-files-in-inverse-order.patch

86 lines
2.3 KiB
Diff
Raw Normal View History

From 442fa8d9723ff320993bd4a869c7ec1258c45218 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Thu, 9 Mar 2023 15:42:16 -0500
Subject: [PATCH] filerchooser: Show Recent files in inverse order
When looking at Recent files in the file chooser, it makes more
sense to show the recent files on top.
This commit flips the sort order for that case.
---
gtk/gtkfilechooserwidget.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 3a0dc6e41b..142daf6e2d 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -7083,60 +7083,64 @@ time_sort_func (gconstpointer a,
if (impl->operation_mode == OPERATION_MODE_RECENT)
{
time_a = (glong) g_file_info_get_attribute_uint64 ((GFileInfo *)a, G_FILE_ATTRIBUTE_TIME_ACCESS);
time_b = (glong) g_file_info_get_attribute_uint64 ((GFileInfo *)b, G_FILE_ATTRIBUTE_TIME_ACCESS);
}
else
{
time_a = (glong) g_file_info_get_attribute_uint64 ((GFileInfo *)a, G_FILE_ATTRIBUTE_TIME_MODIFIED);
time_b = (glong) g_file_info_get_attribute_uint64 ((GFileInfo *)b, G_FILE_ATTRIBUTE_TIME_MODIFIED);
}
if (time_a < time_b)
return GTK_ORDERING_SMALLER;
else if (time_a > time_b)
return GTK_ORDERING_LARGER;
else
return GTK_ORDERING_EQUAL;
}
static GtkOrdering
recent_sort_func (gconstpointer a,
gconstpointer b,
gpointer user_data)
{
GtkOrdering result;
result = time_sort_func (a, b, user_data);
+ /* Recent files should show most recently changed items first
+ */
+ result = -result;
+
if (result == GTK_ORDERING_EQUAL)
result = name_sort_func (a, b, user_data);
if (result == GTK_ORDERING_EQUAL)
result = location_sort_func (a, b, user_data);
return result;
}
static GtkOrdering
search_sort_func (gconstpointer a,
gconstpointer b,
gpointer user_data)
{
GtkOrdering result;
result = location_sort_func (a, b, user_data);
if (result == GTK_ORDERING_EQUAL)
result = name_sort_func (a, b, user_data);
if (result == GTK_ORDERING_EQUAL)
result = time_sort_func (a, b, user_data);
return result;
}
static char *
get_name (GFileInfo *info)
{
--
2.39.2