Attach mtime to the browser's rescaled thumbnails

This commit is contained in:
Přemysl Eric Janouch 2022-06-04 15:24:27 +02:00
parent e2adac72cc
commit bb97445a96
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 14 additions and 1 deletions

View File

@ -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 { struct entry {
char *uri; ///< GIO URI char *uri; ///< GIO URI
gint64 mtime_msec; ///< Modification time in milliseconds gint64 mtime_msec; ///< Modification time in milliseconds
@ -431,8 +434,13 @@ entry_add_thumbnail(gpointer data, gpointer user_data)
self->thumbnail = rescale_thumbnail( self->thumbnail = rescale_thumbnail(
fiv_thumbnail_lookup(self->uri, self->mtime_msec, browser->item_size), fiv_thumbnail_lookup(self->uri, self->mtime_msec, browser->item_size),
browser->item_height); 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; return;
}
// Fall back to symbolic icons, though there's only so much we can do // Fall back to symbolic icons, though there's only so much we can do
// in parallel--GTK+ isn't thread-safe. // 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))) { fiv_io_deserialize(output), self->item_height))) {
entry_add_thumbnail(entry, self); entry_add_thumbnail(entry, self);
materialize_icon(self, entry); 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)); gtk_widget_queue_resize(GTK_WIDGET(self));