big refactor and cleanup of dock + use tokio mpsc

This commit is contained in:
Ashley Wulber 2022-01-02 01:46:44 -05:00
parent 346701b16d
commit 35eb571528
14 changed files with 578 additions and 674 deletions

View file

@ -1,6 +1,7 @@
use std::path::PathBuf;
use glib;
use gtk4::glib;
use std::future::Future;
use crate::DockObject;
use crate::Item;
@ -20,3 +21,18 @@ pub fn data_path() -> PathBuf {
path.push("data.json");
path
}
pub fn _thread_context() -> glib::MainContext {
glib::MainContext::thread_default().unwrap_or_else(|| {
let ctx = glib::MainContext::new();
ctx.push_thread_default();
ctx
})
}
pub fn _block_on<F>(future: F) -> F::Output
where
F: Future,
{
_thread_context().block_on(future)
}