Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix volume reset when unmuting by clicking the slider #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/meter/base_meter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});

Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/meter/sink_meter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/meter/source_meter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/meter/stream_meter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}));
}

Expand Down
4 changes: 2 additions & 2 deletions src/pulse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Loading