summary history branches tags files
commit:ba51744500dcfa56a1e3e170e7a88ceaa977a706
author:Trevor Bentley
committer:Trevor Bentley
date:Sun Apr 23 19:05:34 2017 +0200
parents:e3f794c7ac5fa72e4fd5134fae740fce4d546719
Start of Windows systray support
diff --git a/Cargo.toml b/Cargo.toml
line changes: +3/-0
index 680a185..730aa1a
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -43,6 +43,9 @@ log4rs = "0.6.3"
 ctrlc = "3.0.1"
 
 [target."cfg(windows)".dependencies]
+#systray = "0.1.1"
+#systray = {path = "../systray-rs"}
+systray = {git = "https://github.com/mrmekon/systray-rs.git"}
 
 [target."cfg(all(unix, not(target_os = \"macos\")))".dependencies]
 

diff --git a/src/lib.rs b/src/lib.rs
line changes: +14/-7
index 8bb66c3..ab6b4b7
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -11,6 +11,9 @@ extern crate log;
 #[cfg(target_os = "macos")]
 pub mod osx;
 
+#[cfg(target_os = "windows")]
+pub mod win;
+
 #[cfg(target_os = "macos")]
 #[macro_use]
 extern crate objc;
@@ -36,15 +39,19 @@ pub mod spotify_api {
     pub const PLAYER: &'static str = "https://api.spotify.com/v1/me/player";
 }
 
+#[cfg(target_os = "unix")]
+pub type Object = u64;
+#[cfg(target_os = "windows")]
+pub type Object = u32;
 #[cfg(target_os = "macos")]
 pub type Object = osx::Object;
-#[cfg(target_os = "macos")]
-pub type StatusBar = osx::OSXStatusBar;
 
-#[cfg(not(target_os = "macos"))]
-pub type Object = u64;
-#[cfg(not(target_os = "macos"))]
+#[cfg(target_os = "unix")]
 pub type StatusBar = DummyStatusBar;
+#[cfg(target_os = "macos")]
+pub type StatusBar = osx::OSXStatusBar;
+#[cfg(target_os = "windows")]
+pub type StatusBar = windows::WindowsStatusBar;
 
 pub type MenuItem = *mut Object;
 pub trait TStatusBar {
@@ -58,7 +65,7 @@ pub trait TStatusBar {
     fn update_item(&mut self, item: *mut Object, label: &str);
     fn sel_item(&mut self, sender: u64);
     fn unsel_item(&mut self, sender: u64);
-    fn set_tooltip(&self, text: &str);
+    fn set_tooltip(&mut self, text: &str);
     fn run(&mut self, block: bool);
 }
 
@@ -77,7 +84,7 @@ impl TStatusBar for DummyStatusBar {
     fn update_item(&mut self, _: *mut Object, _: &str) {}
     fn sel_item(&mut self, _: u64) {}
     fn unsel_item(&mut self, _: u64) {}
-    fn set_tooltip(&self, _: &str) {}
+    fn set_tooltip(&mut self, _: &str) {}
     fn run(&mut self, _: bool) {}
 }
 

diff --git a/src/main.rs b/src/main.rs
line changes: +1/-1
index 07932db..76be926
--- a/src/main.rs
+++ b/src/main.rs
@@ -81,7 +81,7 @@ fn fill_menu<T: TStatusBar>(app: &mut ConnectrApp, spotify: &mut connectr::Spoti
     let ref player_state = app.player_state.as_ref().unwrap();
 
     println!("Playback State:\n{}", player_state);
-    let play_str = format!("{: ^50}\n{: ^50}\n{: ^50}",
+    let play_str = format!("{}\n{}\n{}",
                            &player_state.item.name,
                            &player_state.item.artists[0].name,
                            &player_state.item.album.name);