From 7c9e5aab04ae9511588a9de6373406f1e82609bc Mon Sep 17 00:00:00 2001 From: Eric Koegel Date: Sun, 11 Mar 2012 18:38:08 +0300 Subject: [PATCH] Toggle mute of mixer track when the volume is low. (Bug 8291) When the volume of the selected mixer track in the panel app is low, as currently defined at 4%, the selected track will be muted. Anytime the volume is changed to a value larger than 4% the mixer track will be unmuted. This patch only does this for the active mixer track (the button that's displayed in the panel). --- panel-plugin/xfce-volume-button.c | 18 +++++++++++++++++- 1 files changed, 17 insertions(+), 1 deletions(-) diff --git a/panel-plugin/xfce-volume-button.c b/panel-plugin/xfce-volume-button.c index d09f56e..12f3d45 100644 --- a/panel-plugin/xfce-volume-button.c +++ b/panel-plugin/xfce-volume-button.c @@ -37,6 +37,10 @@ +#define MUTE_VOLUME 0.04f + + + /* Signal identifiers */ enum { @@ -441,7 +445,18 @@ static void xfce_volume_button_volume_changed (XfceVolumeButton *button, gdouble volume) { - /* Do nothing */ + /* Mute if below MUTE_VOLUME and auto-unmute for any + * volume change above MUTE_VOLUME */ + if (volume < MUTE_VOLUME && !button->is_muted) + { + xfce_volume_button_set_muted (button, TRUE); + g_signal_emit(button, button_signals[MUTE_TOGGLED], 0, TRUE); + } + else if (volume > MUTE_VOLUME && button->is_muted) + { + xfce_volume_button_set_muted (button, FALSE); + g_signal_emit(button, button_signals[MUTE_TOGGLED], 0, FALSE); + } } @@ -472,6 +487,7 @@ xfce_volume_button_set_volume (XfceVolumeButton *button, /* Update the state of the button */ xfce_volume_button_update (button); + xfce_volume_button_volume_changed (button, volume); } -- 1.7.5.4