general: Use gtk_macros::spawn!()

Makes the code a tad cleaner because we're not manually
getting `glib::MainContext` every time we want to spawn
a future.
This commit is contained in:
Christopher Davis 2022-08-03 19:32:02 -04:00
parent 386b41e482
commit d99215bfd1
4 changed files with 14 additions and 13 deletions

View file

@ -25,6 +25,8 @@ use gtk::prelude::*;
use gtk::subclass::prelude::*;
use gtk::CompositeTemplate;
use gtk_macros::spawn;
use once_cell::sync::OnceCell;
use crate::widgets::LpImage;
@ -106,8 +108,7 @@ impl LpImagePage {
// via the file chooser portal. I'm not sure how to make this work.
gtk::RecentManager::default().add_item(&file.uri());
let ctx = glib::MainContext::default();
ctx.spawn_local(clone!(@weak obj, @weak file => async move {
spawn!(clone!(@weak obj, @weak file => async move {
let imp = obj.imp();
match load_texture_from_file(&file).await {
Ok(texture) => {