From 936b3c0d814456bb876ef916e76872344201f0aa Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Fri, 7 Jan 2022 12:27:16 -0500 Subject: [PATCH] cleanup --- examples/dock/main.rs | 18 +----------------- examples/dock/utils.rs | 6 +++--- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/examples/dock/main.rs b/examples/dock/main.rs index eb8be135..ada38c70 100644 --- a/examples/dock/main.rs +++ b/examples/dock/main.rs @@ -11,14 +11,13 @@ use gtk4::CssProvider; use gtk4::StyleContext; use once_cell::sync::OnceCell; use serde::{Deserialize, Serialize}; -use std::future::Future; use tokio::sync::mpsc; use x11rb::rust_connection::RustConnection; use zbus::Connection; use zvariant_derive::Type; use crate::dock_list::DockListType; -use crate::utils::BoxedWindowList; +use crate::utils::{block_on, thread_context, BoxedWindowList}; use self::dock_object::DockObject; use self::window::Window; @@ -54,21 +53,6 @@ pub struct Item { desktop_entry: String, } -fn thread_context() -> glib::MainContext { - glib::MainContext::thread_default().unwrap_or_else(|| { - let ctx = glib::MainContext::new(); - ctx.push_thread_default(); - ctx - }) -} - -fn block_on(future: F) -> F::Output -where - F: Future, -{ - thread_context().block_on(future) -} - fn spawn_zbus(tx: mpsc::Sender) -> Connection { let connection = block_on(Connection::session()).unwrap(); diff --git a/examples/dock/utils.rs b/examples/dock/utils.rs index 42b27c7e..21269e5c 100644 --- a/examples/dock/utils.rs +++ b/examples/dock/utils.rs @@ -22,7 +22,7 @@ pub fn data_path() -> PathBuf { path } -pub fn _thread_context() -> glib::MainContext { +pub fn thread_context() -> glib::MainContext { glib::MainContext::thread_default().unwrap_or_else(|| { let ctx = glib::MainContext::new(); ctx.push_thread_default(); @@ -30,9 +30,9 @@ pub fn _thread_context() -> glib::MainContext { }) } -pub fn _block_on(future: F) -> F::Output +pub fn block_on(future: F) -> F::Output where F: Future, { - _thread_context().block_on(future) + thread_context().block_on(future) }