From 474b7ff95f176c0d1a12df3107c1b21b129b138d Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Thu, 20 Feb 2014 18:22:01 +0100 Subject: Clamp volume when in the action's change_state handler --- src/service.vala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/service.vala b/src/service.vala index 3a64cb2..87e8b8b 100644 --- a/src/service.vala +++ b/src/service.vala @@ -240,7 +240,8 @@ public class IndicatorSound.Service: Object { var volume_action = new SimpleAction.stateful ("volume", VariantType.INT32, new Variant.double (volume)); volume_action.change_state.connect ( (action, val) => { - volume_control.set_volume (val.get_double () * this.max_volume); + double v = val.get_double () * this.max_volume; + volume_control.set_volume (v.clamp (0.0, this.max_volume)); }); /* activating this action changes the volume by the amount given in the parameter */ -- cgit v1.2.3