Simplify async code

- Update Cargo.lock
- Use new gtk-core API
- Remove unneeded async
- Remove unneeded clones

Part-of: <https://gitlab.gnome.org/GNOME/loupe/-/merge_requests/310>
This commit is contained in:
Julian Hofer 2023-11-22 09:12:07 +01:00
parent 8d185e1e10
commit cd8188a1bb
10 changed files with 26 additions and 40 deletions

View file

@ -26,7 +26,6 @@
use crate::deps::*;
use crate::util::gettext::*;
use crate::util::spawn;
use adw::prelude::*;
use adw::subclass::prelude::*;
use glib::clone;
@ -595,10 +594,10 @@ impl LpWindow {
.build();
toast.connect_button_clicked(glib::clone!(@weak self as win => move |_| {
let path = path.clone();
spawn(async move {
glib::spawn_future_local(async move {
let result = crate::util::untrash(&path).await;
match result {
Ok(()) => win.image_view().set_images_from_files(vec![gio::File::for_path(&path)]),
Ok(()) => win.image_view().set_images_from_files(Vec::from([gio::File::for_path(&path)])),
Err(err) => {
log::error!("Failed to untrash {path:?}: {err}");
win.show_toast(