This commit is contained in:
Ospald, Julian 2017-07-11 15:15:36 +02:00
parent 162e344bf9
commit 67f9f7c89b
3 changed files with 18 additions and 14 deletions

View File

@ -1,4 +1,5 @@
use alsa; use alsa;
use glib;
use std::convert::From; use std::convert::From;
use std; use std;
use toml; use toml;
@ -10,6 +11,7 @@ error_chain! {
Alsa(alsa::Error); Alsa(alsa::Error);
IO(std::io::Error); IO(std::io::Error);
Toml(toml::de::Error); Toml(toml::de::Error);
Glib(glib::BoolError);
} }
} }

View File

@ -62,9 +62,7 @@ mod notif;
use app_state::*; use app_state::*;
#[cfg(feature = "notify")] #[cfg(feature = "notify")]
use libnotify::functions::*; use libnotify::*;
#[cfg(feature = "notify")]
use libnotify::manual_functions::*;

View File

@ -44,8 +44,8 @@ impl Notif {
from_tray: Cell::new(false), from_tray: Cell::new(false),
from_external: Cell::new(false), from_external: Cell::new(false),
volume_notif: libnotify::Notification::new("", None, None).unwrap(), volume_notif: libnotify::Notification::new("", None, None),
text_notif: libnotify::Notification::new("", None, None).unwrap(), text_notif: libnotify::Notification::new("", None, None),
}; };
notif.reload(prefs)?; notif.reload(prefs)?;
@ -61,14 +61,14 @@ impl Notif {
self.from_tray.set(prefs.notify_prefs.notify_mouse_scroll); self.from_tray.set(prefs.notify_prefs.notify_mouse_scroll);
self.from_external.set(prefs.notify_prefs.notify_external); self.from_external.set(prefs.notify_prefs.notify_external);
self.volume_notif.set_notification_timeout(timeout as i32); self.volume_notif.set_timeout(timeout as i32);
self.volume_notif self.volume_notif
.set_hint("x-canonical-private-synchronous", Some("".to_variant()))?; .set_hint("x-canonical-private-synchronous", Some("".to_variant()));
self.text_notif.set_notification_timeout(timeout as i32); self.text_notif.set_timeout(timeout as i32);
self.text_notif self.text_notif
.set_hint("x-canonical-private-synchronous", Some("".to_variant()))?; .set_hint("x-canonical-private-synchronous", Some("".to_variant()));
return Ok(()); return Ok(());
} }
@ -103,17 +103,21 @@ impl Notif {
} }
}; };
self.volume_notif.update(summary.as_str(), None, Some(icon))?; // TODO: error handling
self.volume_notif.set_hint("value", Some((vol as i32).to_variant()))?; self.volume_notif.update(summary.as_str(), None, Some(icon)).unwrap();
self.volume_notif.show()?; self.volume_notif.set_hint("value", Some((vol as i32).to_variant()));
// TODO: error handling
self.volume_notif.show().unwrap();
return Ok(()); return Ok(());
} }
pub fn show_text_notif(&self, summary: &str, body: &str) -> Result<()> { pub fn show_text_notif(&self, summary: &str, body: &str) -> Result<()> {
self.text_notif.update(summary, Some(body), None)?; // TODO: error handling
self.text_notif.show()?; self.text_notif.update(summary, Some(body), None).unwrap();
// TODO: error handling
self.text_notif.show().unwrap();
return Ok(()); return Ok(());
} }