aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-06-04 15:24:27 +0200
committerPřemysl Eric Janouch <p@janouch.name>2022-06-04 16:37:25 +0200
commitbb97445a967c610c9aed9a88a34549b04221c422 (patch)
tree343b69f36b5c51095271f77515197e9540bbbc54
parente2adac72cc15e47b2aa47c1bea07c61a60c547d7 (diff)
downloadfiv-bb97445a967c610c9aed9a88a34549b04221c422.tar.gz
fiv-bb97445a967c610c9aed9a88a34549b04221c422.tar.xz
fiv-bb97445a967c610c9aed9a88a34549b04221c422.zip
Attach mtime to the browser's rescaled thumbnails
-rw-r--r--fiv-browser.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/fiv-browser.c b/fiv-browser.c
index 56d5692..1b01f77 100644
--- a/fiv-browser.c
+++ b/fiv-browser.c
@@ -84,6 +84,9 @@ struct _FivBrowser {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+/// The "last modified" timestamp of source images for thumbnails.
+static cairo_user_data_key_t fiv_browser_key_mtime_msec;
+
struct entry {
char *uri; ///< GIO URI
gint64 mtime_msec; ///< Modification time in milliseconds
@@ -431,8 +434,13 @@ entry_add_thumbnail(gpointer data, gpointer user_data)
self->thumbnail = rescale_thumbnail(
fiv_thumbnail_lookup(self->uri, self->mtime_msec, browser->item_size),
browser->item_height);
- if (self->thumbnail)
+ if (self->thumbnail) {
+ // This choice of mtime favours unnecessary thumbnail reloading.
+ cairo_surface_set_user_data(self->thumbnail,
+ &fiv_browser_key_mtime_msec, (void *) (intptr_t) self->mtime_msec,
+ NULL);
return;
+ }
// Fall back to symbolic icons, though there's only so much we can do
// in parallel--GTK+ isn't thread-safe.
@@ -530,6 +538,11 @@ thumbnailer_reprocess_entry(FivBrowser *self, GBytes *output, Entry *entry)
fiv_io_deserialize(output), self->item_height))) {
entry_add_thumbnail(entry, self);
materialize_icon(self, entry);
+ } else {
+ // This choice of mtime favours unnecessary thumbnail reloading.
+ cairo_surface_set_user_data(entry->thumbnail,
+ &fiv_browser_key_mtime_msec, (void *) (intptr_t) entry->mtime_msec,
+ NULL);
}
gtk_widget_queue_resize(GTK_WIDGET(self));