espanso/src/ui/mod.rs

42 lines
788 B
Rust
Raw Normal View History

2019-09-06 14:06:41 +00:00
#[cfg(target_os = "windows")]
mod windows;
#[cfg(target_os = "linux")]
mod linux;
#[cfg(target_os = "macos")]
mod macos;
pub trait UIManager {
fn notify(&self, message: &str);
2019-09-12 21:24:55 +00:00
fn show_menu(&self, menu: Vec<MenuItem>);
2019-09-06 14:06:41 +00:00
}
2019-09-12 20:14:41 +00:00
pub enum MenuItemType {
Button,
2019-09-12 21:24:55 +00:00
Separator,
2019-09-12 20:14:41 +00:00
}
pub struct MenuItem {
2019-09-12 21:24:55 +00:00
pub item_id: i32,
pub item_type: MenuItemType,
pub item_name: String,
2019-09-12 20:14:41 +00:00
}
2019-09-06 14:06:41 +00:00
// MAC IMPLEMENTATION
#[cfg(target_os = "macos")]
2019-09-06 20:30:20 +00:00
pub fn get_uimanager() -> impl UIManager {
2019-09-09 13:15:01 +00:00
macos::MacUIManager::new()
2019-09-06 20:30:20 +00:00
}
// LINUX IMPLEMENTATION
#[cfg(target_os = "linux")]
pub fn get_uimanager() -> impl UIManager {
linux::LinuxUIManager::new()
}
// WINDOWS IMPLEMENTATION
#[cfg(target_os = "windows")]
pub fn get_uimanager() -> impl UIManager {
2019-09-07 22:51:08 +00:00
windows::WindowsUIManager::new()
2019-09-06 14:06:41 +00:00
}