Files
gpui-native-kit/crates/theme/src/source.rs
T

29 lines
755 B
Rust

//! Platform adapters behind one seam: `snapshot()` reads the running
//! system, `install_watchers()` forwards real change events.
use gpui::AsyncApp;
use crate::ThemeVariant;
use crate::system::SystemTheme;
pub(crate) trait ThemeSource: 'static {
fn snapshot(&self, variant: ThemeVariant) -> SystemTheme;
fn install_watchers(&mut self, _async_cx: AsyncApp) {}
fn label(&self) -> &'static str;
}
#[cfg(target_os = "macos")]
pub(crate) fn platform_source() -> Box<dyn ThemeSource> {
Box::new(macos::MacosSource::default())
}
#[cfg(not(target_os = "macos"))]
pub(crate) fn platform_source() -> Box<dyn ThemeSource> {
Box::new(fallback::FallbackSource)
}
#[cfg(target_os = "macos")]
pub(crate) mod macos;
pub(crate) mod fallback;