diff --git a/examples/simple.rs b/examples/simple.rs index b3f21dc..a45decc 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -5,10 +5,10 @@ use std::sync::{Arc, RwLock}; use std::mem; extern crate barfly; -use barfly::Barfly; +use barfly::Sysbar; fn main() { - let mut fly = barfly::new("Barfly"); + let mut fly = Sysbar::new("Barfly"); // make a hash map for the callbacks to mess with let hm: HashMap = HashMap::new(); diff --git a/src/lib.rs b/src/lib.rs index 1d859d4..6e01380 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,7 +5,27 @@ mod mac_os; #[macro_use] extern crate objc; -pub trait Barfly { +pub struct Sysbar(PlatformFly); + +impl Sysbar { + pub fn new(name: &str) -> Self { + Sysbar(PlatformFly::new(name)) + } + + pub fn add_item(&mut self, menu_item: &str, cbs: Box ()>) { + self.0.add_item(menu_item, cbs) + } + + pub fn add_quit_item(&mut self, label: &str) { + self.0.add_quit_item(label) + } + + pub fn display(&mut self) { + self.0.display() + } +} + +trait Barfly { fn new(name: &str) -> Self; fn add_item(&mut self, menu_item: &str, cbs: Box ()>); fn add_quit_item(&mut self, label: &str); @@ -13,11 +33,7 @@ pub trait Barfly { } #[cfg(target_os = "macos")] -pub type PlatformFly = mac_os::MacOsBarfly; - -pub fn new(name: &str) -> PlatformFly { - PlatformFly::new(name) -} +type PlatformFly = mac_os::MacOsBarfly; #[test] fn it_works() {