2021-12-29 17:31:01 -05:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
2022-01-02 01:46:44 -05:00
|
|
|
use gtk4::glib;
|
|
|
|
|
use std::future::Future;
|
2021-12-29 17:31:01 -05:00
|
|
|
|
2021-12-27 17:59:49 -05:00
|
|
|
use crate::DockObject;
|
2021-12-22 12:32:46 -05:00
|
|
|
use crate::Item;
|
|
|
|
|
|
2021-12-20 23:52:59 -05:00
|
|
|
#[derive(Clone, Debug, Default, glib::GBoxed)]
|
2021-12-22 12:32:46 -05:00
|
|
|
#[gboxed(type_name = "BoxedWindowList")]
|
|
|
|
|
pub struct BoxedWindowList(pub Vec<Item>);
|
2021-12-29 17:31:01 -05:00
|
|
|
|
2021-12-27 17:59:49 -05:00
|
|
|
#[derive(Clone, Debug, Default, glib::GBoxed)]
|
|
|
|
|
#[gboxed(type_name = "BoxedDockObject")]
|
|
|
|
|
pub struct BoxedDockObject(pub Option<DockObject>);
|
|
|
|
|
|
|
|
|
|
pub fn data_path() -> PathBuf {
|
|
|
|
|
let mut path = glib::user_data_dir();
|
|
|
|
|
path.push("com.cosmic.dock");
|
|
|
|
|
std::fs::create_dir_all(&path).expect("Could not create directory.");
|
|
|
|
|
path.push("data.json");
|
|
|
|
|
path
|
|
|
|
|
}
|
2022-01-02 01:46:44 -05:00
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
}
|