diff --git a/src/ui/streambox.rs b/src/ui/streambox.rs index 055a013..be74d0b 100644 --- a/src/ui/streambox.rs +++ b/src/ui/streambox.rs @@ -103,7 +103,7 @@ impl PwStreamBox { let id = self.default_node(); // The following is just so this string gets picked up by xgettext, since it doesn't handle rust macros yet. - #[cfg(_disabled_)] + #[cfg(debug_assertions)] gettextrs::gettext("Default ({})"); let string = if let Some(node) = manager.get_node_by_id(id) { diff --git a/src/ui/volumebox.rs b/src/ui/volumebox.rs index 08f2083..22012d2 100644 --- a/src/ui/volumebox.rs +++ b/src/ui/volumebox.rs @@ -162,17 +162,7 @@ mod imp { // Monitoring ourselves cause an infinite loop. if item.name() != "pwvucontrol-peak-detect" { - if let Ok(provider) = LevelbarProvider::new(&self.obj(), item.boundid()) { - self.levelbarprovider.set(provider).expect("Provider not set already"); - - self.timeoutid.set(Some(glib::timeout_add_local( - std::time::Duration::from_millis(25), - clone!(@weak self as obj => @default-panic, move || { - obj.level_bar.set_value(obj.level.get() as f64); - ControlFlow::Continue - }), - ))); - } + self.setuplevelbar(); } else { self.level_bar.set_visible(false); } @@ -215,6 +205,24 @@ mod imp { fn invert_bool(&self, value: bool) -> bool { !value } + + fn setuplevelbar(&self) { + let item = self.node_object.borrow(); + let item = item.as_ref().cloned().unwrap(); + + if let Ok(provider) = LevelbarProvider::new(&self.obj(), item.boundid()) { + self.levelbarprovider.set(provider).expect("Provider not set already"); + + let obj = self.obj(); + self.timeoutid.set(Some(glib::timeout_add_local( + std::time::Duration::from_millis(25), + clone!(@strong obj => @default-panic, move || { + obj.imp().level_bar.set_value(obj.imp().level.get() as f64); + ControlFlow::Continue + }), + ))); + } + } } }