spawn with idle priority
This commit is contained in:
@ -30,16 +30,19 @@ impl<W: glib::IsA<gtk::Widget>> SpawnWithToast for W {
|
|||||||
.ancestor(adw::ToastOverlay::static_type())
|
.ancestor(adw::ToastOverlay::static_type())
|
||||||
.and_downcast();
|
.and_downcast();
|
||||||
let win: Option<NotifyWindow> = self.ancestor(NotifyWindow::static_type()).and_downcast();
|
let win: Option<NotifyWindow> = self.ancestor(NotifyWindow::static_type()).and_downcast();
|
||||||
glib::MainContext::default().spawn_local(async move {
|
glib::MainContext::ref_thread_default().spawn_local_with_priority(
|
||||||
if let Err(e) = f.await {
|
glib::Priority::DEFAULT_IDLE,
|
||||||
if let Some(o) = toast_overlay
|
async move {
|
||||||
.as_ref()
|
if let Err(e) = f.await {
|
||||||
.or_else(|| win.as_ref().map(|win| win.imp().toast_overlay.as_ref()))
|
if let Some(o) = toast_overlay
|
||||||
{
|
.as_ref()
|
||||||
o.add_toast(adw::Toast::builder().title(&e.to_string()).build())
|
.or_else(|| win.as_ref().map(|win| win.imp().toast_overlay.as_ref()))
|
||||||
|
{
|
||||||
|
o.add_toast(adw::Toast::builder().title(&e.to_string()).build())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user