Skip to content

Commit

Permalink
Reorganize levelbar
Browse files Browse the repository at this point in the history
  • Loading branch information
saivert committed Oct 31, 2024
1 parent a3eff33 commit b80c286
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/ui/streambox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
30 changes: 19 additions & 11 deletions src/ui/volumebox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
}),
)));
}
}
}
}

Expand Down

0 comments on commit b80c286

Please sign in to comment.