summaryrefslogtreecommitdiff
path: root/mate-volume-control
diff options
context:
space:
mode:
authorgm10 <[email protected]>2019-07-25 21:14:55 +0200
committerraveit65 <[email protected]>2019-07-27 12:58:15 +0200
commit74f5181315401e5a2bb1a635ef3bc2ca9e51328a (patch)
tree98b62330ba17f5221dc84bfe384a8f2a198025ac /mate-volume-control
parent5c1f718e74110bf08901bd76bc4106d0f044289f (diff)
downloadmate-media-74f5181315401e5a2bb1a635ef3bc2ca9e51328a.tar.bz2
mate-media-74f5181315401e5a2bb1a635ef3bc2ca9e51328a.tar.xz
Scroll volume in configurable steps same as media-keys
and don't hardcode default value
Diffstat (limited to 'mate-volume-control')
-rw-r--r--mate-volume-control/gvc-channel-bar.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/mate-volume-control/gvc-channel-bar.c b/mate-volume-control/gvc-channel-bar.c
index ad05abf..72ec40b 100644
--- a/mate-volume-control/gvc-channel-bar.c
+++ b/mate-volume-control/gvc-channel-bar.c
@@ -21,6 +21,8 @@
#include "config.h"
+#include <sys/param.h>
+
#include <glib.h>
#include <glib/gi18n.h>
#include <glib-object.h>
@@ -817,6 +819,7 @@ gvc_channel_bar_scroll (GvcChannelBar *bar, GdkScrollDirection direction)
gdouble minimum;
gdouble maximum;
gdouble scrollstep;
+ GSettings *settings;
g_return_val_if_fail (GVC_IS_CHANNEL_BAR (bar), FALSE);
@@ -843,18 +846,23 @@ gvc_channel_bar_scroll (GvcChannelBar *bar, GdkScrollDirection direction)
minimum = gtk_adjustment_get_lower (bar->priv->adjustment);
maximum = gtk_adjustment_get_upper (bar->priv->adjustment);
- scrollstep = maximum / 100.0 * 5.0;
+ /* Use the same setting for `scrollstep` as used by the media keys plugin */
+ settings = g_settings_new ("org.mate.SettingsDaemon.plugins.media-keys");
+ scrollstep = g_settings_get_int (settings, "volume-step");
+ if (scrollstep <= 0 || scrollstep > 100) {
+ GVariant *variant = g_settings_get_default_value (settings, "volume-step");
+ scrollstep = g_variant_get_int32 (variant);
+ g_variant_unref (variant);
+ }
+ g_object_unref (settings);
+
+ /* Scale the volume step size accordingly to the range used by the control */
+ scrollstep = (maximum - minimum) * scrollstep / 100;
if (direction == GDK_SCROLL_UP) {
- if (value + scrollstep > maximum)
- value = maximum;
- else
- value = value + scrollstep;
+ value = MIN (value + scrollstep, maximum);
} else if (direction == GDK_SCROLL_DOWN) {
- if (value - scrollstep < minimum)
- value = minimum;
- else
- value = value - scrollstep;
+ value = MAX (value - scrollstep, minimum);
}
gtk_adjustment_set_value (bar->priv->adjustment, value);