parent
f1f8ba9a88
commit
0e44037239
2 changed files with 22 additions and 9 deletions
|
|
@ -81,6 +81,10 @@ mod imp {
|
||||||
|
|
||||||
pub drag_source: gtk::DragSource,
|
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) model: RefCell<LpFileModel>,
|
||||||
pub(super) preserve_content: Cell<bool>,
|
pub(super) preserve_content: Cell<bool>,
|
||||||
|
|
||||||
|
|
@ -522,6 +526,16 @@ impl LpImageView {
|
||||||
|
|
||||||
/// Handle files are added or removed from directory
|
/// Handle files are added or removed from directory
|
||||||
fn model_content_changed_cb(&self) {
|
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 {
|
let Some(current_file) = self.current_file() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -667,16 +667,15 @@ impl LpWindow {
|
||||||
toast.connect_button_clicked(glib::clone!(@weak self as win => move |_| {
|
toast.connect_button_clicked(glib::clone!(@weak self as win => move |_| {
|
||||||
let path = path.clone();
|
let path = path.clone();
|
||||||
glib::spawn_future_local(async move {
|
glib::spawn_future_local(async move {
|
||||||
|
win.image_view()
|
||||||
|
.set_trash_restore(Some(gio::File::for_path(&path)));
|
||||||
let result = crate::util::untrash(&path).await;
|
let result = crate::util::untrash(&path).await;
|
||||||
match result {
|
if let Err(err) = result {
|
||||||
Ok(()) => win.image_view().set_images_from_files(Vec::from([gio::File::for_path(&path)])),
|
log::error!("Failed to untrash {path:?}: {err}");
|
||||||
Err(err) => {
|
win.show_toast(
|
||||||
log::error!("Failed to untrash {path:?}: {err}");
|
gettext("Failed to restore image from trash"),
|
||||||
win.show_toast(
|
adw::ToastPriority::High,
|
||||||
gettext("Failed to restore image from trash"),
|
);
|
||||||
adw::ToastPriority::High,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue