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

@ -28,6 +28,8 @@ use gtk::CompositeTemplate;
use ashpd::desktop::open_uri;
use ashpd::WindowIdentifier;
use gtk_macros::spawn;
use crate::config;
use crate::util;
use crate::widgets::{LpImageView, LpPropertiesView};
@ -253,7 +255,6 @@ impl LpWindow {
fn open_with(&self) {
let imp = self.imp();
let ctx = glib::MainContext::default();
if let Some(file) = imp
.image_view
@ -261,7 +262,7 @@ impl LpWindow {
.and_then(|f| f.peek_path())
.and_then(|p| std::fs::File::open(p).ok())
{
ctx.spawn_local(clone!(@weak self as win => async move {
spawn!(clone!(@weak self as win => async move {
if let Err(e) =
open_uri::open_file(&WindowIdentifier::from_native(&win).await, &file, true, true).await
{