Slightly optimize file monitoring event handling
This commit is contained in:
parent
4c8df56193
commit
28a1237d62
|
@ -673,6 +673,26 @@ materialize_icon(FivBrowser *self, Entry *entry)
|
||||||
g_object_unref(icon_info);
|
g_object_unref(icon_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
reload_one_thumbnail_finish(FivBrowser *self, Entry *entry)
|
||||||
|
{
|
||||||
|
if (!entry->removed && entry->thumbnail) {
|
||||||
|
g_hash_table_insert(self->thumbnail_cache, g_strdup(entry->e->uri),
|
||||||
|
cairo_surface_reference(entry->thumbnail));
|
||||||
|
}
|
||||||
|
|
||||||
|
materialize_icon(self, entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
reload_one_thumbnail(FivBrowser *self, Entry *entry)
|
||||||
|
{
|
||||||
|
entry_add_thumbnail(entry, self);
|
||||||
|
reload_one_thumbnail_finish(self, entry);
|
||||||
|
|
||||||
|
gtk_widget_queue_resize(GTK_WIDGET(self));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
reload_thumbnails(FivBrowser *self)
|
reload_thumbnails(FivBrowser *self)
|
||||||
{
|
{
|
||||||
|
@ -684,16 +704,8 @@ reload_thumbnails(FivBrowser *self)
|
||||||
|
|
||||||
// Once a URI disappears from the model, its thumbnail is forgotten.
|
// Once a URI disappears from the model, its thumbnail is forgotten.
|
||||||
g_hash_table_remove_all(self->thumbnail_cache);
|
g_hash_table_remove_all(self->thumbnail_cache);
|
||||||
|
for (guint i = 0; i < self->entries->len; i++)
|
||||||
for (guint i = 0; i < self->entries->len; i++) {
|
reload_one_thumbnail_finish(self, self->entries->pdata[i]);
|
||||||
Entry *entry = self->entries->pdata[i];
|
|
||||||
if (!entry->removed && entry->thumbnail) {
|
|
||||||
g_hash_table_insert(self->thumbnail_cache, g_strdup(entry->e->uri),
|
|
||||||
cairo_surface_reference(entry->thumbnail));
|
|
||||||
}
|
|
||||||
|
|
||||||
materialize_icon(self, entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_widget_queue_resize(GTK_WIDGET(self));
|
gtk_widget_queue_resize(GTK_WIDGET(self));
|
||||||
}
|
}
|
||||||
|
@ -1903,12 +1915,11 @@ on_model_changed(FivIoModel *model, FivIoModelEntry *old, FivIoModelEntry *new,
|
||||||
|
|
||||||
// Add new entries to the end, so as to not disturb the layout.
|
// Add new entries to the end, so as to not disturb the layout.
|
||||||
if (!old) {
|
if (!old) {
|
||||||
g_ptr_array_add(
|
Entry *entry = entry_new(fiv_io_model_entry_ref(new));
|
||||||
self->entries, entry_new(fiv_io_model_entry_ref(new)));
|
g_ptr_array_add(self->entries, entry);
|
||||||
|
|
||||||
// TODO(p): Only process this one item, not everything at once.
|
reload_one_thumbnail(self, entry);
|
||||||
// (This mainly has an effect on thumbnail-less entries.)
|
// TODO(p): Try to add to thumbnailer queue if already started.
|
||||||
reload_thumbnails(self);
|
|
||||||
thumbnailers_start(self);
|
thumbnailers_start(self);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1934,9 +1945,8 @@ on_model_changed(FivIoModel *model, FivIoModelEntry *old, FivIoModelEntry *new,
|
||||||
// TODO(p): If there is a URI mismatch, don't reload thumbnails,
|
// TODO(p): If there is a URI mismatch, don't reload thumbnails,
|
||||||
// so that there's no jumping around. Or, a bit more properly,
|
// so that there's no jumping around. Or, a bit more properly,
|
||||||
// move the thumbnail cache entry to the new URI.
|
// move the thumbnail cache entry to the new URI.
|
||||||
// TODO(p): Only process this one item, not everything at once.
|
reload_one_thumbnail(self, found);
|
||||||
// (This mainly has an effect on thumbnail-less entries.)
|
// TODO(p): Try to add to thumbnailer queue if already started.
|
||||||
reload_thumbnails(self);
|
|
||||||
thumbnailers_start(self);
|
thumbnailers_start(self);
|
||||||
} else {
|
} else {
|
||||||
found->removed = TRUE;
|
found->removed = TRUE;
|
||||||
|
|
Loading…
Reference in New Issue