🚧 Volume updating
This commit is contained in:
parent
57b44a35d5
commit
73d2401ed3
3 changed files with 10 additions and 13 deletions
|
|
@ -10,7 +10,7 @@ fn get_inputs() -> Vec<DeviceInfo> {
|
|||
.expect("failed to list input devices")
|
||||
}
|
||||
|
||||
pub fn refresh_default_input(label: &Label) {
|
||||
pub fn refresh_default_input(label: &Label) -> DeviceInfo {
|
||||
let default_input = SourceController::create()
|
||||
.expect("failed to create input controller")
|
||||
.get_default_device()
|
||||
|
|
@ -19,6 +19,7 @@ pub fn refresh_default_input(label: &Label) {
|
|||
Some(name) => name.as_str(),
|
||||
None => "Input Device",
|
||||
});
|
||||
default_input
|
||||
}
|
||||
|
||||
pub fn refresh_input_widgets(inputs: &ListBox) {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,6 @@ fn app(application: &Application) {
|
|||
set_format_value_func: |_, value| {
|
||||
format!("{:.0}%", value)
|
||||
},
|
||||
//set_value: watch! { model.default_output.as_ref().map(|info| (info.volume.avg().0 as f64 / Volume::NORMAL.0 as f64) * 100.).unwrap_or(0.) },
|
||||
set_value_pos: PositionType::Right,
|
||||
set_hexpand: true
|
||||
}
|
||||
|
|
@ -100,12 +99,6 @@ fn app(application: &Application) {
|
|||
set_format_value_func: |_, value| {
|
||||
format!("{:.0}%", value)
|
||||
},
|
||||
/*set_value: watch! {
|
||||
model.default_input
|
||||
.as_ref()
|
||||
.map(|info| (info.volume.avg().0 as f64 / Volume::NORMAL.0 as f64) * 100.)
|
||||
.unwrap_or(0.)
|
||||
},*/
|
||||
set_value_pos: PositionType::Right,
|
||||
set_hexpand: true
|
||||
}
|
||||
|
|
@ -159,17 +152,19 @@ fn app(application: &Application) {
|
|||
}
|
||||
refresh_input_rx.attach(
|
||||
None,
|
||||
clone!(@weak inputs, @weak current_input => @default-return Continue(true), move |_| {
|
||||
clone!(@weak inputs, @weak current_input, @weak input_volume => @default-return Continue(true), move |_| {
|
||||
input::refresh_input_widgets(&inputs);
|
||||
input::refresh_default_input(¤t_input);
|
||||
let default_input = input::refresh_default_input(¤t_input);
|
||||
volume::update_volume(&default_input, &input_volume);
|
||||
Continue(true)
|
||||
}),
|
||||
);
|
||||
refresh_output_rx.attach(
|
||||
None,
|
||||
clone!(@weak outputs, @weak current_output => @default-return Continue(true), move |_| {
|
||||
clone!(@weak outputs, @weak current_output, @weak output_volume => @default-return Continue(true), move |_| {
|
||||
output::refresh_output_widgets(&outputs);
|
||||
output::refresh_default_input(¤t_output);
|
||||
let default_output = output::refresh_default_output(¤t_output);
|
||||
volume::update_volume(&default_output, &output_volume);
|
||||
Continue(true)
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ fn get_outputs() -> Vec<DeviceInfo> {
|
|||
.expect("failed to list output devices")
|
||||
}
|
||||
|
||||
pub fn refresh_default_input(label: &Label) {
|
||||
pub fn refresh_default_output(label: &Label) -> DeviceInfo {
|
||||
let default_output = SinkController::create()
|
||||
.expect("failed to create output controller")
|
||||
.get_default_device()
|
||||
|
|
@ -19,6 +19,7 @@ pub fn refresh_default_input(label: &Label) {
|
|||
Some(name) => name.as_str(),
|
||||
None => "Output Device",
|
||||
});
|
||||
default_output
|
||||
}
|
||||
|
||||
pub fn refresh_output_widgets(outputs: &ListBox) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue