This commit is contained in:
Julian Ospald 2017-07-10 21:27:57 +02:00
parent 20e5b97842
commit c04a975edf
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
3 changed files with 38 additions and 13 deletions

View File

@ -1,8 +1,9 @@
use audio::Audio; use audio::{Audio, AudioUser};
use errors::*; use errors::*;
use gtk; use gtk;
use prefs::*; use prefs::*;
use std::cell::RefCell; use std::cell::RefCell;
use support_audio::*;
use ui_entry::Gui; use ui_entry::Gui;
#[cfg(feature = "notify")] #[cfg(feature = "notify")]
@ -72,4 +73,23 @@ impl AppS {
debug!("Update PopupWindow!"); debug!("Update PopupWindow!");
return self.gui.popup_window.update(&self.audio); return self.gui.popup_window.update(&self.audio);
} }
#[cfg(feature = "notify")]
pub fn update_notify(&self) -> Result<()> {
return self.notif.reload(&self.prefs.borrow());
}
#[cfg(not(feature = "notify"))]
pub fn update_notify(&self) -> Result<()> {
return Ok(());
}
pub fn update_audio(&self, user: AudioUser) -> Result<()> {
return audio_reload(&self.audio, &self.prefs.borrow(), user);
}
pub fn update_config(&self) -> Result<()> {
let prefs = self.prefs.borrow_mut();
return prefs.store_config();
}
} }

View File

@ -24,6 +24,7 @@ pub struct PopupWindow {
pub mute_check: gtk::CheckButton, pub mute_check: gtk::CheckButton,
pub mixer_button: gtk::Button, pub mixer_button: gtk::Button,
pub toggle_signal: Cell<u64>, pub toggle_signal: Cell<u64>,
pub changed_signal: Cell<u64>,
} }
impl PopupWindow { impl PopupWindow {
@ -36,6 +37,7 @@ impl PopupWindow {
mute_check: builder.get_object("mute_check").unwrap(), mute_check: builder.get_object("mute_check").unwrap(),
mixer_button: builder.get_object("mixer_button").unwrap(), mixer_button: builder.get_object("mixer_button").unwrap(),
toggle_signal: Cell::new(0), toggle_signal: Cell::new(0),
changed_signal: Cell::new(0),
}; };
} }
@ -148,9 +150,14 @@ pub fn init_popup_window(appstate: Rc<AppS>) {
.gui .gui
.popup_window .popup_window
.vol_scale_adj; .vol_scale_adj;
vol_scale_adj.connect_value_changed( let changed_signal = vol_scale_adj.connect_value_changed(
move |_| on_vol_scale_value_changed(&_appstate), move |_| on_vol_scale_value_changed(&_appstate),
); );
appstate.gui
.popup_window
.changed_signal
.set(changed_signal);
} }
/* popup_window.connect_event */ /* popup_window.connect_event */
@ -181,10 +188,13 @@ pub fn init_popup_window(appstate: Rc<AppS>) {
fn on_popup_window_show(appstate: &AppS) { fn on_popup_window_show(appstate: &AppS) {
let popup_window = &appstate.gui.popup_window;
appstate.gui.popup_window.set_vol_increment(&appstate.prefs.borrow()); appstate.gui.popup_window.set_vol_increment(&appstate.prefs.borrow());
glib::signal_handler_block(&popup_window.vol_scale_adj, popup_window.changed_signal.get());
try_w!(appstate.gui.popup_window.update(&appstate.audio)); try_w!(appstate.gui.popup_window.update(&appstate.audio));
appstate.gui glib::signal_handler_unblock(&popup_window.vol_scale_adj,
.popup_window popup_window.changed_signal.get());
popup_window
.vol_scale .vol_scale
.grab_focus(); .grab_focus();
try_w!(grab_devices(&appstate.gui.popup_window.popup_window)); try_w!(grab_devices(&appstate.gui.popup_window.popup_window));

View File

@ -335,17 +335,12 @@ fn init_prefs_dialog(appstate: &Rc<AppS>) {
if response_id == ResponseType::Ok.into() || if response_id == ResponseType::Ok.into() ||
response_id == ResponseType::Apply.into() { response_id == ResponseType::Apply.into() {
// TODO: update popup, tray_icon, hotkeys, notification and audio // TODO: update hotkeys
#[cfg(feature = "notify")] try_w!(apps.update_notify());
try_w!(apps.notif.reload(&apps.prefs.borrow()));
try_w!(apps.update_tray_icon()); try_w!(apps.update_tray_icon());
try_w!(apps.update_popup_window()); try_w!(apps.update_popup_window());
{ try_w!(apps.update_audio(AudioUser::PrefsWindow));
let prefs = apps.prefs.borrow(); try_w!(apps.update_config());
try_w!(audio_reload(&apps.audio, &prefs, AudioUser::PrefsWindow));
}
let prefs = apps.prefs.borrow_mut();
try_w!(prefs.store_config());
} }
}); });