Update
This commit is contained in:
parent
f8939ec581
commit
5e0d7f9550
@ -56,21 +56,30 @@ impl AlsaCard {
|
|||||||
match mycard {
|
match mycard {
|
||||||
Ok(card) => card,
|
Ok(card) => card,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
warn!("Card {} not playable, trying others", name);
|
warn!("Card {} not playable, trying others",
|
||||||
|
name);
|
||||||
get_first_playable_alsa_card()?
|
get_first_playable_alsa_card()?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
None => get_first_playable_alsa_card()?,
|
None => get_first_playable_alsa_card()?,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let mixer = get_mixer(&card)?;
|
let mixer = get_mixer(&card)?;
|
||||||
|
|
||||||
let selem_id =
|
let selem_id = {
|
||||||
get_playable_selem_by_name(&mixer,
|
let requested_selem =
|
||||||
elem_name.unwrap_or(String::from("Master")))?
|
get_playable_selem_by_name(&mixer,
|
||||||
.get_id();
|
elem_name.unwrap_or(String::from("Master")));
|
||||||
|
match requested_selem {
|
||||||
|
Ok(s) => s.get_id(),
|
||||||
|
Err(_) => {
|
||||||
|
warn!("No playable Selem found, trying others");
|
||||||
|
get_first_playable_selem(&mixer)?.get_id()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let vec_pollfd = PollDescriptors::get(&mixer)?;
|
let vec_pollfd = PollDescriptors::get(&mixer)?;
|
||||||
|
|
||||||
|
@ -24,21 +24,28 @@ pub struct AppS {
|
|||||||
impl AppS {
|
impl AppS {
|
||||||
pub fn new() -> AppS {
|
pub fn new() -> AppS {
|
||||||
let builder_popup_window =
|
let builder_popup_window =
|
||||||
gtk::Builder::new_from_string(include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/data/ui/popup-window.glade")));
|
gtk::Builder::new_from_string(include_str!(concat!(env!("CARGO_MANIFEST_DIR"),
|
||||||
let builder_popup_menu = gtk::Builder::new_from_string(include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/data/ui/popup-menu.glade")));
|
"/data/ui/popup-window.glade")));
|
||||||
|
let builder_popup_menu =
|
||||||
|
gtk::Builder::new_from_string(include_str!(concat!(env!("CARGO_MANIFEST_DIR"),
|
||||||
|
"/data/ui/popup-menu.glade")));
|
||||||
let prefs = RefCell::new(Prefs::new().unwrap());
|
let prefs = RefCell::new(Prefs::new().unwrap());
|
||||||
let gui =
|
let gui =
|
||||||
Gui::new(builder_popup_window, builder_popup_menu, &prefs.borrow());
|
Gui::new(builder_popup_window, builder_popup_menu, &prefs.borrow());
|
||||||
|
|
||||||
let card_name = prefs.borrow().device_prefs.card.clone();
|
let card_name = prefs.borrow()
|
||||||
let chan_name = prefs.borrow().device_prefs.channel.clone();
|
.device_prefs
|
||||||
|
.card
|
||||||
|
.clone();
|
||||||
|
let chan_name = prefs.borrow()
|
||||||
|
.device_prefs
|
||||||
|
.channel
|
||||||
|
.clone();
|
||||||
|
|
||||||
return AppS {
|
return AppS {
|
||||||
_cant_construct: (),
|
_cant_construct: (),
|
||||||
gui: gui,
|
gui: gui,
|
||||||
audio: Audio::new(Some(card_name),
|
audio: Audio::new(Some(card_name), Some(chan_name)).unwrap(),
|
||||||
Some(chan_name))
|
|
||||||
.unwrap(),
|
|
||||||
prefs: prefs,
|
prefs: prefs,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ mod ui_prefs_dialog;
|
|||||||
mod ui_tray_icon;
|
mod ui_tray_icon;
|
||||||
mod prefs;
|
mod prefs;
|
||||||
mod support_alsa;
|
mod support_alsa;
|
||||||
|
mod support_audio;
|
||||||
mod support_cmd;
|
mod support_cmd;
|
||||||
mod support_ui;
|
mod support_ui;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ pub fn get_first_playable_alsa_card() -> Result<Card> {
|
|||||||
if alsa_card_has_playable_selem(&card) {
|
if alsa_card_has_playable_selem(&card) {
|
||||||
return Ok(card);
|
return Ok(card);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,7 +50,7 @@ pub fn get_playable_alsa_card_names() -> Vec<String> {
|
|||||||
vec.push(m_name.unwrap())
|
vec.push(m_name.unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,6 +104,15 @@ pub fn get_playable_selems(mixer: &Mixer) -> Vec<Selem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub fn get_first_playable_selem(mixer: &Mixer) -> Result<Selem> {
|
||||||
|
for s in mixer.iter().map(get_selem).filter(selem_is_playable) {
|
||||||
|
return Ok(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
bail!("No playable Selem found!")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn get_playable_selem_names(mixer: &Mixer) -> Vec<String> {
|
pub fn get_playable_selem_names(mixer: &Mixer) -> Vec<String> {
|
||||||
let mut vec = vec![];
|
let mut vec = vec![];
|
||||||
for selem in get_playable_selems(mixer) {
|
for selem in get_playable_selems(mixer) {
|
||||||
@ -118,7 +127,9 @@ pub fn get_playable_selem_names(mixer: &Mixer) -> Vec<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn get_playable_selem_by_name(mixer: &Mixer, name: String) -> Result<Selem> {
|
pub fn get_playable_selem_by_name(mixer: &Mixer,
|
||||||
|
name: String)
|
||||||
|
-> Result<Selem> {
|
||||||
for selem in get_playable_selems(mixer) {
|
for selem in get_playable_selems(mixer) {
|
||||||
let n = selem.get_id()
|
let n = selem.get_id()
|
||||||
.get_name()
|
.get_name()
|
||||||
|
15
src/support_audio.rs
Normal file
15
src/support_audio.rs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
use audio::{Audio, AudioUser};
|
||||||
|
use errors::*;
|
||||||
|
use prefs::*;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pub fn audio_reload(audio: &Audio,
|
||||||
|
prefs: &Prefs,
|
||||||
|
user: AudioUser)
|
||||||
|
-> Result<()> {
|
||||||
|
let card = &prefs.device_prefs.card;
|
||||||
|
let channel = &prefs.device_prefs.channel;
|
||||||
|
// TODO: is this clone safe?
|
||||||
|
return audio.switch_acard(Some(card.clone()), Some(channel.clone()), user);
|
||||||
|
}
|
@ -5,8 +5,10 @@ use std::cell::RefCell;
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use ui_popup_menu::*;
|
use ui_popup_menu::*;
|
||||||
use ui_popup_window::*;
|
use ui_popup_window::*;
|
||||||
use ui_prefs_dialog::PrefsDialog;
|
use ui_prefs_dialog::*;
|
||||||
use ui_tray_icon::*;
|
use ui_tray_icon::*;
|
||||||
|
use audio::{AudioUser, AudioSignal};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -37,20 +39,21 @@ impl Gui {
|
|||||||
|
|
||||||
pub fn init(appstate: Rc<AppS>) {
|
pub fn init(appstate: Rc<AppS>) {
|
||||||
{
|
{
|
||||||
let mut apps = appstate.clone();
|
let apps = appstate.clone();
|
||||||
// appstate.audio.connect_handler(
|
appstate.audio.connect_handler(
|
||||||
// Box::new(move |s, u| match (s, u) {
|
Box::new(move |s, u| match (s, u) {
|
||||||
// (AudioSignal::ValuesChanged, AudioUser::Unknown) => {
|
(AudioSignal::ValuesChanged, AudioUser::Unknown) => {
|
||||||
// debug!("External volume change!");
|
debug!("Appstate references: {}!", Rc::strong_count(&apps));
|
||||||
|
|
||||||
// }
|
}
|
||||||
// _ => debug!("Nix"),
|
_ => debug!("Nix"),
|
||||||
// }),
|
}),
|
||||||
// );
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init_tray_icon(appstate.clone());
|
init_tray_icon(appstate.clone());
|
||||||
init_popup_window(appstate.clone());
|
init_popup_window(appstate.clone());
|
||||||
init_popup_menu(appstate.clone());
|
init_popup_menu(appstate.clone());
|
||||||
|
init_prefs_callback(appstate.clone());
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ use audio::{AudioUser, AudioSignal};
|
|||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use gtk;
|
use gtk;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
use support_audio::*;
|
||||||
use support_cmd::*;
|
use support_cmd::*;
|
||||||
use ui_prefs_dialog::*;
|
use ui_prefs_dialog::*;
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ pub fn init_popup_menu(appstate: Rc<AppS>) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
match (s, u) {
|
match (s, u) {
|
||||||
(_, _) => set_mute_check(&apps)
|
(_, _) => set_mute_check(&apps),
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -50,9 +51,7 @@ pub fn init_popup_menu(appstate: Rc<AppS>) {
|
|||||||
appstate.gui
|
appstate.gui
|
||||||
.popup_menu
|
.popup_menu
|
||||||
.menu
|
.menu
|
||||||
.connect_show(move |_| {
|
.connect_show(move |_| set_mute_check(&apps));
|
||||||
set_mute_check(&apps)
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,13 +93,22 @@ pub fn init_popup_menu(appstate: Rc<AppS>) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* reload_item.connect_activate_link */
|
||||||
|
{
|
||||||
|
let apps = appstate.clone();
|
||||||
|
let reload_item = &appstate.gui.popup_menu.reload_item;
|
||||||
|
reload_item.connect_activate(move |_| {
|
||||||
|
try_w!(audio_reload(&apps.audio,
|
||||||
|
&apps.prefs.borrow(),
|
||||||
|
AudioUser::Popup))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* quit_item.connect_activate_link */
|
/* quit_item.connect_activate_link */
|
||||||
{
|
{
|
||||||
let quit_item = &appstate.gui.popup_menu.quit_item;
|
let quit_item = &appstate.gui.popup_menu.quit_item;
|
||||||
quit_item.connect_activate(|_| {
|
quit_item.connect_activate(|_| { gtk::main_quit(); });
|
||||||
gtk::main_quit();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,27 +160,18 @@ fn on_prefs_item_activate(appstate: &Rc<AppS>) {
|
|||||||
|
|
||||||
|
|
||||||
fn set_mute_check(apps: &Rc<AppS>) {
|
fn set_mute_check(apps: &Rc<AppS>) {
|
||||||
let mute_check = &apps.gui
|
let mute_check = &apps.gui.popup_menu.mute_check;
|
||||||
.popup_menu
|
|
||||||
.mute_check;
|
|
||||||
let m_muted = apps.audio.get_mute();
|
let m_muted = apps.audio.get_mute();
|
||||||
match m_muted {
|
match m_muted {
|
||||||
Ok(muted) => {
|
Ok(muted) => {
|
||||||
mute_check
|
mute_check.set_sensitive(false);
|
||||||
.set_sensitive(false);
|
mute_check.set_active(muted);
|
||||||
mute_check
|
mute_check.set_tooltip_text("");
|
||||||
.set_active(muted);
|
}
|
||||||
mute_check.set_tooltip_text(
|
|
||||||
"");
|
|
||||||
},
|
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
mute_check
|
mute_check.set_active(true);
|
||||||
.set_active(true);
|
mute_check.set_sensitive(false);
|
||||||
mute_check
|
mute_check.set_tooltip_text("Soundcard has no mute switch");
|
||||||
.set_sensitive(false);
|
|
||||||
mute_check.set_tooltip_text(
|
|
||||||
"Soundcard has no mute switch",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ pub fn set_slider(vol_scale_adj: >k::Adjustment, scale: f64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn grab_devices(window: >k::Window) -> Result<()> {
|
fn grab_devices(window: >k::Window) -> Result<()> {
|
||||||
let device = gtk::get_current_event_device().ok_or("No current device")?;
|
let device = gtk::get_current_event_device().ok_or("No current device")?;
|
||||||
|
|
||||||
let gdk_window = window.get_window().ok_or("No window?!")?;
|
let gdk_window = window.get_window().ok_or("No window?!")?;
|
||||||
|
@ -1,52 +1,56 @@
|
|||||||
use app_state::*;
|
use app_state::*;
|
||||||
use audio::{AudioUser, AudioSignal};
|
use audio::{AudioUser, AudioSignal};
|
||||||
|
use errors::*;
|
||||||
use gdk;
|
use gdk;
|
||||||
use gtk::ResponseType;
|
use gtk::ResponseType;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use gtk;
|
use gtk;
|
||||||
use prefs::*;
|
use prefs::*;
|
||||||
|
use std::mem;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use support_alsa::*;
|
use support_alsa::*;
|
||||||
use errors::*;
|
use support_audio::*;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: misbehavior when popup_window is open
|
// TODO: reference count leak
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pub struct PrefsDialog {
|
pub struct PrefsDialog {
|
||||||
_cant_construct: (),
|
_cant_construct: (),
|
||||||
pub prefs_dialog: gtk::Dialog,
|
prefs_dialog: gtk::Dialog,
|
||||||
|
|
||||||
/* DevicePrefs */
|
/* DevicePrefs */
|
||||||
pub card_combo: gtk::ComboBoxText,
|
card_combo: gtk::ComboBoxText,
|
||||||
pub chan_combo: gtk::ComboBoxText,
|
chan_combo: gtk::ComboBoxText,
|
||||||
|
|
||||||
/* ViewPrefs */
|
/* ViewPrefs */
|
||||||
pub vol_meter_draw_check: gtk::CheckButton,
|
vol_meter_draw_check: gtk::CheckButton,
|
||||||
pub vol_meter_pos_spin: gtk::SpinButton,
|
vol_meter_pos_spin: gtk::SpinButton,
|
||||||
pub vol_meter_color_button: gtk::ColorButton,
|
vol_meter_color_button: gtk::ColorButton,
|
||||||
pub system_theme: gtk::CheckButton,
|
system_theme: gtk::CheckButton,
|
||||||
|
|
||||||
/* BehaviorPrefs */
|
/* BehaviorPrefs */
|
||||||
pub vol_control_entry: gtk::Entry,
|
vol_control_entry: gtk::Entry,
|
||||||
pub scroll_step_spin: gtk::SpinButton,
|
scroll_step_spin: gtk::SpinButton,
|
||||||
pub middle_click_combo: gtk::ComboBoxText,
|
middle_click_combo: gtk::ComboBoxText,
|
||||||
pub custom_entry: gtk::Entry,
|
custom_entry: gtk::Entry,
|
||||||
|
|
||||||
/* NotifyPrefs */
|
/* NotifyPrefs */
|
||||||
pub noti_enable_check: gtk::CheckButton,
|
noti_enable_check: gtk::CheckButton,
|
||||||
pub noti_timeout_spin: gtk::SpinButton,
|
noti_timeout_spin: gtk::SpinButton,
|
||||||
// pub noti_hotkey_check: gtk::CheckButton,
|
// pub noti_hotkey_check: gtk::CheckButton,
|
||||||
pub noti_mouse_check: gtk::CheckButton,
|
noti_mouse_check: gtk::CheckButton,
|
||||||
pub noti_popup_check: gtk::CheckButton,
|
noti_popup_check: gtk::CheckButton,
|
||||||
pub noti_ext_check: gtk::CheckButton,
|
noti_ext_check: gtk::CheckButton,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PrefsDialog {
|
impl PrefsDialog {
|
||||||
pub fn new() -> PrefsDialog {
|
fn new() -> PrefsDialog {
|
||||||
let builder = gtk::Builder::new_from_string(include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/data/ui/prefs-dialog.glade")));
|
let builder =
|
||||||
|
gtk::Builder::new_from_string(include_str!(concat!(env!("CARGO_MANIFEST_DIR"),
|
||||||
|
"/data/ui/prefs-dialog.glade")));
|
||||||
let prefs_dialog = PrefsDialog {
|
let prefs_dialog = PrefsDialog {
|
||||||
_cant_construct: (),
|
_cant_construct: (),
|
||||||
prefs_dialog: builder.get_object("prefs_dialog").unwrap(),
|
prefs_dialog: builder.get_object("prefs_dialog").unwrap(),
|
||||||
@ -81,7 +85,7 @@ impl PrefsDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn from_prefs(&self, prefs: &Prefs) {
|
fn from_prefs(&self, prefs: &Prefs) {
|
||||||
/* DevicePrefs */
|
/* DevicePrefs */
|
||||||
/* filled on show signal with audio info */
|
/* filled on show signal with audio info */
|
||||||
self.card_combo.remove_all();
|
self.card_combo.remove_all();
|
||||||
@ -137,7 +141,7 @@ impl PrefsDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn to_prefs(&self) -> Prefs {
|
fn to_prefs(&self) -> Prefs {
|
||||||
// TODO: remove duplication with default instance
|
// TODO: remove duplication with default instance
|
||||||
let device_prefs =
|
let device_prefs =
|
||||||
DevicePrefs {
|
DevicePrefs {
|
||||||
@ -227,36 +231,32 @@ pub fn show_prefs_dialog(appstate: &Rc<AppS>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* TODO: do the references get dropped when the dialog window is gone? */
|
pub fn init_prefs_callback(appstate: Rc<AppS>) {
|
||||||
pub fn init_prefs_dialog(appstate: &Rc<AppS>) {
|
let apps = appstate.clone();
|
||||||
/* audio.connect_handler */
|
appstate.audio.connect_handler(Box::new(move |s, u| {
|
||||||
{
|
match (s, u) {
|
||||||
let apps = appstate.clone();
|
(AudioSignal::CardInitialized, _) => (),
|
||||||
appstate.audio.connect_handler(Box::new(move |s, u| {
|
(AudioSignal::CardCleanedUp, _) => {
|
||||||
match (s, u) {
|
fill_card_combo(&apps);
|
||||||
(AudioSignal::CardInitialized, _) => (),
|
fill_chan_combo(&apps, None);
|
||||||
(AudioSignal::CardCleanedUp, _) => {
|
},
|
||||||
fill_card_combo(&apps);
|
_ => (),
|
||||||
fill_chan_combo(&apps, None);
|
}
|
||||||
},
|
}));
|
||||||
_ => (),
|
}
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
fn init_prefs_dialog(appstate: &Rc<AppS>) {
|
||||||
|
|
||||||
/* prefs_dialog.connect_show */
|
/* prefs_dialog.connect_show */
|
||||||
{
|
{
|
||||||
let apps = appstate.clone();
|
let apps = appstate.clone();
|
||||||
let m_pd = appstate.gui.prefs_dialog.borrow();
|
let m_pd = appstate.gui.prefs_dialog.borrow();
|
||||||
let pd = m_pd.as_ref().unwrap();
|
let pd = m_pd.as_ref().unwrap();
|
||||||
pd.prefs_dialog.connect_show(
|
pd.prefs_dialog.connect_show(move |_| {
|
||||||
move |_| {
|
fill_card_combo(&apps);
|
||||||
fill_card_combo(&apps);
|
fill_chan_combo(&apps, None);
|
||||||
fill_chan_combo(&apps, None);
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* card_combo.connect_changed */
|
/* card_combo.connect_changed */
|
||||||
@ -268,8 +268,7 @@ pub fn init_prefs_dialog(appstate: &Rc<AppS>) {
|
|||||||
card_combo.connect_changed(move |_| {
|
card_combo.connect_changed(move |_| {
|
||||||
let m_cc = apps.gui.prefs_dialog.borrow();
|
let m_cc = apps.gui.prefs_dialog.borrow();
|
||||||
let card_combo = &m_cc.as_ref().unwrap().card_combo;
|
let card_combo = &m_cc.as_ref().unwrap().card_combo;
|
||||||
let card_name = card_combo
|
let card_name = card_combo.get_active_text().unwrap();
|
||||||
.get_active_text().unwrap();
|
|
||||||
fill_chan_combo(&apps, Some(card_name));
|
fill_chan_combo(&apps, Some(card_name));
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
@ -290,7 +289,6 @@ pub fn init_prefs_dialog(appstate: &Rc<AppS>) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: does Rc<AppS> get dropped?!
|
|
||||||
if response_id != ResponseType::Apply.into() {
|
if response_id != ResponseType::Apply.into() {
|
||||||
let mut prefs_dialog = apps.gui.prefs_dialog.borrow_mut();
|
let mut prefs_dialog = apps.gui.prefs_dialog.borrow_mut();
|
||||||
prefs_dialog.as_ref().unwrap().prefs_dialog.destroy();
|
prefs_dialog.as_ref().unwrap().prefs_dialog.destroy();
|
||||||
@ -304,12 +302,7 @@ pub fn init_prefs_dialog(appstate: &Rc<AppS>) {
|
|||||||
try_w!(apps.update_popup_window());
|
try_w!(apps.update_popup_window());
|
||||||
{
|
{
|
||||||
let prefs = apps.prefs.borrow();
|
let prefs = apps.prefs.borrow();
|
||||||
let card = &prefs.device_prefs.card;
|
try_w!(audio_reload(&apps.audio, &prefs, AudioUser::PrefsWindow));
|
||||||
let channel = &prefs.device_prefs.channel;
|
|
||||||
try_w!(apps.audio.switch_acard(
|
|
||||||
Some(card.clone()),
|
|
||||||
Some(channel.clone()),
|
|
||||||
AudioUser::PrefsWindow));
|
|
||||||
}
|
}
|
||||||
let prefs = apps.prefs.borrow_mut();
|
let prefs = apps.prefs.borrow_mut();
|
||||||
try_w!(prefs.store_config());
|
try_w!(prefs.store_config());
|
||||||
@ -353,9 +346,7 @@ fn fill_chan_combo(appstate: &AppS, cardname: Option<String>) {
|
|||||||
|
|
||||||
let cur_acard = appstate.audio.acard.borrow();
|
let cur_acard = appstate.audio.acard.borrow();
|
||||||
let card = match cardname {
|
let card = match cardname {
|
||||||
Some(name) => {
|
Some(name) => try_w!(get_alsa_card_by_name(name).from_err()),
|
||||||
try_w!(get_alsa_card_by_name(name).from_err())
|
|
||||||
},
|
|
||||||
None => cur_acard.as_ref().card,
|
None => cur_acard.as_ref().card,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -378,4 +369,3 @@ fn fill_chan_combo(appstate: &AppS, cardname: Option<String>) {
|
|||||||
chan_combo.set_active(c_index);
|
chan_combo.set_active(c_index);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ impl TrayIcon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn update_audio(&self, audio: &Audio) -> Result<()> {
|
fn update_audio(&self, audio: &Audio) -> Result<()> {
|
||||||
|
|
||||||
return self.update_pixbuf(audio.vol()?, audio.vol_level());
|
return self.update_pixbuf(audio.vol()?, audio.vol_level());
|
||||||
}
|
}
|
||||||
@ -97,8 +97,12 @@ impl TrayIcon {
|
|||||||
|
|
||||||
let audio_pix = AudioPix::new(self.icon_size.get(), &prefs)?;
|
let audio_pix = AudioPix::new(self.icon_size.get(), &prefs)?;
|
||||||
*self.audio_pix.borrow_mut() = audio_pix;
|
*self.audio_pix.borrow_mut() = audio_pix;
|
||||||
let volmeter = VolMeter::new(&prefs);
|
|
||||||
*self.volmeter.borrow_mut() = Some(volmeter);
|
let draw_vol_meter = prefs.view_prefs.draw_vol_meter;
|
||||||
|
if draw_vol_meter {
|
||||||
|
let volmeter = VolMeter::new(&prefs);
|
||||||
|
*self.volmeter.borrow_mut() = Some(volmeter);
|
||||||
|
}
|
||||||
|
|
||||||
return self.update_pixbuf(audio.vol()?, audio.vol_level());
|
return self.update_pixbuf(audio.vol()?, audio.vol_level());
|
||||||
}
|
}
|
||||||
@ -119,7 +123,7 @@ pub struct VolMeter {
|
|||||||
|
|
||||||
|
|
||||||
impl VolMeter {
|
impl VolMeter {
|
||||||
pub fn new(prefs: &Prefs) -> VolMeter {
|
fn new(prefs: &Prefs) -> VolMeter {
|
||||||
return VolMeter {
|
return VolMeter {
|
||||||
red: prefs.view_prefs.vol_meter_color.red,
|
red: prefs.view_prefs.vol_meter_color.red,
|
||||||
green: prefs.view_prefs.vol_meter_color.green,
|
green: prefs.view_prefs.vol_meter_color.green,
|
||||||
@ -223,7 +227,7 @@ pub struct AudioPix {
|
|||||||
|
|
||||||
|
|
||||||
impl AudioPix {
|
impl AudioPix {
|
||||||
pub fn new(size: i32, prefs: &Prefs) -> Result<AudioPix> {
|
fn new(size: i32, prefs: &Prefs) -> Result<AudioPix> {
|
||||||
let system_theme = prefs.view_prefs.system_theme;
|
let system_theme = prefs.view_prefs.system_theme;
|
||||||
|
|
||||||
let pix = {
|
let pix = {
|
||||||
@ -282,7 +286,7 @@ impl AudioPix {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn select_pix(&self, vol_level: VolLevel) -> &gdk_pixbuf::Pixbuf {
|
fn select_pix(&self, vol_level: VolLevel) -> &gdk_pixbuf::Pixbuf {
|
||||||
match vol_level {
|
match vol_level {
|
||||||
VolLevel::Muted => &self.muted,
|
VolLevel::Muted => &self.muted,
|
||||||
VolLevel::Low => &self.low,
|
VolLevel::Low => &self.low,
|
||||||
@ -304,13 +308,11 @@ pub fn init_tray_icon(appstate: Rc<AppS>) {
|
|||||||
/* connect audio handler */
|
/* connect audio handler */
|
||||||
{
|
{
|
||||||
let apps = appstate.clone();
|
let apps = appstate.clone();
|
||||||
appstate.audio.connect_handler(
|
appstate.audio.connect_handler(Box::new(move |s, u| match (s, u) {
|
||||||
Box::new(move |s, u| match (s, u) {
|
(_, _) => {
|
||||||
(_, _) => {
|
try_w!(apps.gui.tray_icon.update_audio(&apps.audio));
|
||||||
try_w!(apps.gui.tray_icon.update_audio(&apps.audio));
|
}
|
||||||
},
|
}));
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* tray_icon.connect_size_changed */
|
/* tray_icon.connect_size_changed */
|
||||||
|
Loading…
Reference in New Issue
Block a user