general: Use spawn! less

Because widgets can install async actions, we can simply
turn our callbacks into async functions.
This commit is contained in:
Christopher Davis 2023-01-22 12:18:43 -05:00 • committed by Sophie Herold
parent 6e632e7281
commit 7b7435f50a
2 changed files with 30 additions and 35 deletions

View file

@ -146,8 +146,8 @@ mod imp {
win.rotate_image(angle.unwrap().get().unwrap());
});
klass.install_action("win.set-background", None, move |win, _, _| {
win.set_background();
klass.install_action_async("win.set-background", None, |win, _, _| async move {
win.set_background().await;
});
klass.install_action("win.print", None, move |win, _, _| {
@ -397,10 +397,10 @@ impl LpWindow {
self.imp().image_view.rotate_image(angle)
}
fn set_background(&self) {
async fn set_background(&self) {
let imp = self.imp();
if let Err(e) = imp.image_view.set_background() {
if let Err(e) = imp.image_view.set_background().await {
log::error!("Failed to set background: {}", e);
}
}