From 1a6b944537b1b5dd7648b458b7e6b03166a406f4 Mon Sep 17 00:00:00 2001 From: zWolfrost Date: Wed, 17 Apr 2024 21:03:14 +0200 Subject: [PATCH] fix volume reset when unmuting by clicking the slider --- src/meter/base_meter.rs | 4 ++-- src/meter/sink_meter.rs | 2 +- src/meter/source_meter.rs | 2 +- src/meter/stream_meter.rs | 2 +- src/pulse.rs | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/meter/base_meter.rs b/src/meter/base_meter.rs index b0210c5..3d460a3 100644 --- a/src/meter/base_meter.rs +++ b/src/meter/base_meter.rs @@ -165,7 +165,7 @@ impl dyn Meter { let pulse = pulse.borrow_mut(); pulse.set_volume(t, index, volumes); - if volumes.max().0 > 0 { pulse.set_muted(t, index, false); } + if volumes.max().0 > 0 { pulse.set_muted(t, index, false, false); } gtk::Inhibit(false) }); @@ -182,7 +182,7 @@ impl dyn Meter { volumes.set(channels, Volume(value as u32)); let pulse = pulse.borrow_mut(); pulse.set_volume(t, index, volumes); - if volumes.max().0 > 0 { pulse.set_muted(t, index, false); } + if volumes.max().0 > 0 { pulse.set_muted(t, index, false, false); } gtk::Inhibit(false) }); scales_box.pack_start(&scale, false, false, 0); diff --git a/src/meter/sink_meter.rs b/src/meter/sink_meter.rs index f7473fd..11f636e 100644 --- a/src/meter/sink_meter.rs +++ b/src/meter/sink_meter.rs @@ -69,7 +69,7 @@ impl SinkMeter { if self.s_id.is_some() { self.widgets.status.disconnect(glib::signal::SignalHandlerId::from_glib(self.s_id.as_ref().unwrap().to_glib())) } self.s_id = Some(self.widgets.status.connect_clicked(move |status| { pulse.borrow_mut().set_muted(t, index, - !status.get_style_context().has_class("muted")); + !status.get_style_context().has_class("muted"), true); })); let pulse = self.pulse.clone(); diff --git a/src/meter/source_meter.rs b/src/meter/source_meter.rs index e779cea..a551857 100644 --- a/src/meter/source_meter.rs +++ b/src/meter/source_meter.rs @@ -71,7 +71,7 @@ impl SourceMeter { glib::signal::SignalHandlerId::from_glib(self.s_id.as_ref().unwrap().to_glib())) } self.s_id = Some(self.widgets.status.connect_clicked(move |status| { pulse.borrow_mut().set_muted(t, index, - !status.get_style_context().has_class("muted")); + !status.get_style_context().has_class("muted"), true); })); let pulse = self.pulse.clone(); diff --git a/src/meter/stream_meter.rs b/src/meter/stream_meter.rs index f22b895..2d64544 100644 --- a/src/meter/stream_meter.rs +++ b/src/meter/stream_meter.rs @@ -67,7 +67,7 @@ impl StreamMeter { if self.b_id.is_some() { self.widgets.status.disconnect(glib::signal::SignalHandlerId::from_glib(self.b_id.as_ref().unwrap().to_glib())) } self.b_id = Some(self.widgets.status.connect_clicked(move |status| { - pulse.borrow_mut().set_muted(t, index, !status.get_style_context().has_class("muted")); + pulse.borrow_mut().set_muted(t, index, !status.get_style_context().has_class("muted"), true); })); } diff --git a/src/pulse.rs b/src/pulse.rs index 57bbfe8..4140354 100644 --- a/src/pulse.rs +++ b/src/pulse.rs @@ -290,9 +290,9 @@ impl Pulse { * * `mute` - Whether the stream should be muted or not. */ - pub fn set_muted(&self, t: StreamType, index: u32, mute: bool) { + pub fn set_muted(&self, t: StreamType, index: u32, mute: bool, zero_volume_reset: bool) { // If unmuting a stream that has been set to 0 volume, it should be reset to full. - if !mute { + if !mute && zero_volume_reset { let entry = match t { StreamType::Sink => self.sinks.get(&index), StreamType::SinkInput => self.sink_inputs.get(&index),