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

@ -35,7 +35,6 @@ use crate::util::gettext::*;
use crate::util::{Direction, Position};
use crate::widgets::{LpImage, LpImagePage, LpPrint, LpSlidingView};
use crate::util::spawn;
use adw::prelude::*;
use adw::subclass::prelude::*;
use anyhow::Context;
@ -306,7 +305,7 @@ impl LpImageView {
// List other files in directory
if let Some(directory) = directory {
spawn(glib::clone!(@weak self as obj, @strong file => async move {
glib::spawn_future_local(glib::clone!(@weak self as obj => async move {
if let Err(err) = obj.model().load_directory(directory.clone()).await {
log::warn!("Failed to load directory: {}", err.root_cause());
obj.activate_action("win.show-toast", Some(&(format!("{} {}", err, err.root_cause()), adw::ToastPriority::High.into_glib()).to_variant()))