ImageView: Reliably show image restored from trash

Closes #316
This commit is contained in:
Sophie Herold 2024-01-28 21:05:55 +01:00
parent f1f8ba9a88
commit 0e44037239
2 changed files with 22 additions and 9 deletions

View file

@ -81,6 +81,10 @@ mod imp {
pub drag_source: gtk::DragSource,
/// File where trash operation has been undone
#[property(get, set, nullable)]
trash_restore: RefCell<Option<gio::File>>,
pub(super) model: RefCell<LpFileModel>,
pub(super) preserve_content: Cell<bool>,
@ -522,6 +526,16 @@ impl LpImageView {
/// Handle files are added or removed from directory
fn model_content_changed_cb(&self) {
// Animate to image that was restored from trash
if let Some(trash_restore) = self.trash_restore() {
if self.model().contains(&trash_restore) {
self.set_trash_restore(gio::File::NONE);
self.update_sliding_view(&trash_restore);
self.scroll_sliding_view(&trash_restore);
return;
}
}
let Some(current_file) = self.current_file() else {
return;
};