Skip to main content

winio_ui_gtk/
lib.rs

1//! GTK backend for winio.
2
3#![cfg_attr(docsrs, feature(doc_cfg))]
4#![cfg(not(any(windows, target_os = "macos")))]
5
6use winio_callback::Runnable;
7
8pub(crate) struct GlobalRuntime;
9
10impl Runnable for GlobalRuntime {
11    #[inline]
12    fn run() {
13        RUNTIME.with(|runtime| runtime.run())
14    }
15}
16
17scoped_tls::scoped_thread_local!(pub(crate) static RUNTIME: Runtime);
18
19mod runtime;
20pub use runtime::*;
21
22mod ui;
23pub use ui::*;
24
25#[derive(Debug, thiserror::Error)]
26#[non_exhaustive]
27pub enum Error {
28    /// IO error.
29    #[error("IO error: {0}")]
30    Io(#[from] std::io::Error),
31    /// Bool error.
32    #[error("Bool error: {0}")]
33    Bool(#[from] gtk4::glib::BoolError),
34    /// Glib error.
35    #[error("Glib error: {0}")]
36    Glib(#[from] gtk4::glib::Error),
37    /// Cairo error.
38    #[error("Cairo error: {0}")]
39    Cairo(#[from] gtk4::cairo::Error),
40    /// Index error.
41    #[error("Index error: {0}")]
42    Index(usize),
43    /// Null pointer returned.
44    #[error("Null pointer returned")]
45    NullPointer,
46    /// Cast failed.
47    #[error("Cast failed")]
48    CastFailed,
49    /// Color theme is not available.
50    #[error("Color theme is not available")]
51    NoColorTheme,
52    /// Feature not supported.
53    #[error("Feature not supported")]
54    NotSupported,
55}
56
57/// Result type for GTK.
58pub type Result<T, E = Error> = std::result::Result<T, E>;