diff --git a/data/ui/prefs-dialog.glade b/data/ui/prefs-dialog.glade
index c074a2228..3b4292ca0 100644
--- a/data/ui/prefs-dialog.glade
+++ b/data/ui/prefs-dialog.glade
@@ -805,12 +805,6 @@
diff --git a/src/alsa_card.rs b/src/alsa_card.rs
index f55bf374e..612331f3c 100644
--- a/src/alsa_card.rs
+++ b/src/alsa_card.rs
@@ -36,10 +36,11 @@ pub struct AlsaCard {
impl AlsaCard {
- pub fn new(card_name: Option,
- elem_name: Option,
- cb: Rc)
- -> Result> {
+ pub fn new(
+ card_name: Option,
+ elem_name: Option,
+ cb: Rc,
+ ) -> Result> {
let card = {
match card_name {
Some(name) => get_alsa_card_by_name(name)?,
@@ -50,26 +51,26 @@ impl AlsaCard {
let vec_pollfd = PollDescriptors::get(&mixer)?;
- let selem_id =
- get_selem_by_name(&mixer,
- elem_name.unwrap_or(String::from("Master")))
- .unwrap()
- .get_id();
+ let selem_id = get_selem_by_name(
+ &mixer,
+ elem_name.unwrap_or(String::from("Master")),
+ ).unwrap()
+ .get_id();
let acard = Box::new(AlsaCard {
- _cannot_construct: (),
- card: card,
- mixer: mixer,
- selem_id: selem_id,
- watch_ids: Cell::new(vec![]),
- cb: cb,
- });
+ _cannot_construct: (),
+ card: card,
+ mixer: mixer,
+ selem_id: selem_id,
+ watch_ids: Cell::new(vec![]),
+ cb: cb,
+ });
/* TODO: callback is registered here, which must be unregistered
* when the card is destroyed!!
* poll descriptors must be unwatched too */
- let watch_ids = AlsaCard::watch_poll_descriptors(vec_pollfd,
- acard.as_ref());
+ let watch_ids =
+ AlsaCard::watch_poll_descriptors(vec_pollfd, acard.as_ref());
acard.watch_ids.set(watch_ids);
return Ok(acard);
@@ -82,9 +83,7 @@ impl AlsaCard {
pub fn chan_name(&self) -> Result {
- let n = self.selem_id
- .get_name()
- .map(|y| String::from(y))?;
+ let n = self.selem_id.get_name().map(|y| String::from(y))?;
return Ok(n);
}
@@ -113,7 +112,9 @@ impl AlsaCard {
}
let range = selem.get_playback_volume_range();
- selem.set_playback_volume_all(percent_to_vol(new_vol, range))?;
+ selem.set_playback_volume_all(
+ percent_to_vol(new_vol, range),
+ )?;
return Ok(());
}
@@ -140,9 +141,10 @@ impl AlsaCard {
}
- fn watch_poll_descriptors(polls: Vec,
- acard: &AlsaCard)
- -> Vec {
+ fn watch_poll_descriptors(
+ polls: Vec,
+ acard: &AlsaCard,
+ ) -> Vec {
let mut watch_ids: Vec = vec![];
let acard_ptr =
unsafe { mem::transmute::<&AlsaCard, glib_sys::gpointer>(acard) };
@@ -199,10 +201,11 @@ impl Drop for AlsaCard {
}
-extern "C" fn watch_cb(chan: *mut glib_sys::GIOChannel,
- cond: glib_sys::GIOCondition,
- data: glib_sys::gpointer)
- -> glib_sys::gboolean {
+extern "C" fn watch_cb(
+ chan: *mut glib_sys::GIOChannel,
+ cond: glib_sys::GIOCondition,
+ data: glib_sys::gpointer,
+) -> glib_sys::gboolean {
let acard =
unsafe { mem::transmute::(data) };
@@ -221,14 +224,15 @@ extern "C" fn watch_cb(chan: *mut glib_sys::GIOChannel,
let mut buf: Vec = vec![0; 256];
while sread > 0 {
- let stat: glib_sys::GIOStatus =
- unsafe {
- glib_sys::g_io_channel_read_chars(chan,
- buf.as_mut_ptr() as *mut u8,
- 256,
- &mut sread as *mut size_t,
- ptr::null_mut())
- };
+ let stat: glib_sys::GIOStatus = unsafe {
+ glib_sys::g_io_channel_read_chars(
+ chan,
+ buf.as_mut_ptr() as *mut u8,
+ 256,
+ &mut sread as *mut size_t,
+ ptr::null_mut(),
+ )
+ };
match stat {
glib_sys::G_IO_STATUS_AGAIN => {
diff --git a/src/app_state.rs b/src/app_state.rs
index 9fc19345d..ff1d37ffd 100644
--- a/src/app_state.rs
+++ b/src/app_state.rs
@@ -4,6 +4,7 @@ use gtk;
use prefs::*;
use std::cell::RefCell;
use ui_entry::Gui;
+use ui_prefs_dialog::show_prefs_dialog;
// TODO: notify popups
@@ -22,30 +23,43 @@ pub struct AppS {
impl AppS {
pub fn new() -> AppS {
- let builder_popup_window =
- gtk::Builder::new_from_string(include_str!("../data/ui/popup-window.glade"));
- let builder_popup_menu = gtk::Builder::new_from_string(include_str!("../data/ui/popup-menu.glade"));
+ let builder_popup_window = gtk::Builder::new_from_string(include_str!(
+ "../data/ui/popup-window.glade"
+ ));
+ let builder_popup_menu = gtk::Builder::new_from_string(
+ include_str!("../data/ui/popup-menu.glade"),
+ );
let prefs = RefCell::new(Prefs::new().unwrap());
let gui =
Gui::new(builder_popup_window, builder_popup_menu, &prefs.borrow());
return AppS {
- _cant_construct: (),
- gui: gui,
- audio: Audio::new(None, Some(String::from("Master")))
- .unwrap(),
- prefs: prefs,
- };
+ _cant_construct: (),
+ gui: gui,
+ audio: Audio::new(None, Some(String::from("Master"))).unwrap(),
+ prefs: prefs,
+ };
}
+
+ /* some functions that need to be easily accessible */
+
pub fn update_tray_icon(&self) -> Result<()> {
debug!("Update tray icon!");
- return self.gui.tray_icon.update_all(&self.prefs.borrow(), &self.audio, None);
+ return self.gui.tray_icon.update_all(
+ &self.prefs.borrow(),
+ &self.audio,
+ None,
+ );
}
pub fn update_popup_window(&self) -> Result<()> {
debug!("Update PopupWindow!");
return self.gui.popup_window.update(&self.audio);
}
-}
+ pub fn show_preferences(&self) {
+ // show_prefs_dialog(self);
+ }
+
+}
diff --git a/src/audio.rs b/src/audio.rs
index d2c992d4c..f5c3a8ad9 100644
--- a/src/audio.rs
+++ b/src/audio.rs
@@ -73,9 +73,10 @@ pub struct Audio {
impl Audio {
- pub fn new(card_name: Option,
- elem_name: Option)
- -> Result