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

@ -31,6 +31,8 @@ use ashpd::WindowIdentifier;
use once_cell::sync::Lazy;
use std::cell::{Cell, RefCell};
use gtk_macros::spawn;
use crate::file_model::LpFileModel;
use crate::thumbnail::Thumbnail;
use crate::widgets::LpImagePage;
@ -360,8 +362,7 @@ impl LpImageView {
pub fn set_wallpaper(&self) -> anyhow::Result<()> {
let wallpaper = self.uri().context("No URI for current file")?;
let ctx = glib::MainContext::default();
ctx.spawn_local(clone!(@weak self as view => async move {
spawn!(clone!(@weak self as view => async move {
let id = WindowIdentifier::from_native(
&view.native().expect("View should have a GtkNative"),
)