summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2022-08-03 10:29:54 +0200
committerraveit65 <[email protected]>2022-08-14 02:16:39 +0200
commit0ae3d7fdce73059fc124b969f27db11a6322a027 (patch)
tree09e2026b15343950cb6fab62e72f72d1c9e354b7
parent44df49d11121858b4235a427376410eb091c31c5 (diff)
downloadmate-media-0ae3d7fdce73059fc124b969f27db11a6322a027.tar.bz2
mate-media-0ae3d7fdce73059fc124b969f27db11a6322a027.tar.xz
gvc-stream-status-icon: fix a volume rounding error (101% -> 100%)
-rw-r--r--mate-volume-control/gvc-channel-bar.c9
-rw-r--r--mate-volume-control/gvc-stream-status-icon.c7
2 files changed, 6 insertions, 10 deletions
diff --git a/mate-volume-control/gvc-channel-bar.c b/mate-volume-control/gvc-channel-bar.c
index 7feb0dd..89fa3a5 100644
--- a/mate-volume-control/gvc-channel-bar.c
+++ b/mate-volume-control/gvc-channel-bar.c
@@ -401,18 +401,11 @@ update_adjustment_value (GvcChannelBar *bar)
else
value = mate_mixer_stream_control_get_volume (bar->priv->control);
- gdouble maximum = gtk_adjustment_get_upper (bar->priv->adjustment);
- gdouble minimum = gtk_adjustment_get_lower (bar->priv->adjustment);
- gdouble range = maximum - minimum;
-
- /* round value to nearest hundreth of the range */
- gdouble new_value = minimum + round (((value - minimum) / range) * 100) * (range / 100);
-
g_signal_handlers_block_by_func (G_OBJECT (bar->priv->adjustment),
on_adjustment_value_changed,
bar);
- gtk_adjustment_set_value (bar->priv->adjustment, new_value);
+ gtk_adjustment_set_value (bar->priv->adjustment, value);
g_signal_handlers_unblock_by_func (G_OBJECT (bar->priv->adjustment),
on_adjustment_value_changed,
diff --git a/mate-volume-control/gvc-stream-status-icon.c b/mate-volume-control/gvc-stream-status-icon.c
index ef1124a..0f7ee2b 100644
--- a/mate-volume-control/gvc-stream-status-icon.c
+++ b/mate-volume-control/gvc-stream-status-icon.c
@@ -381,6 +381,7 @@ static void
update_icon (GvcStreamStatusIcon *icon)
{
guint volume = 0;
+ guint volume_percent = 0;
gdouble decibel = 0;
guint normal = 0;
gboolean muted = FALSE;
@@ -408,7 +409,7 @@ update_icon (GvcStreamStatusIcon *icon)
/* Select an icon, they are expected to be sorted, the lowest index being
* the mute icon and the rest being volume increments */
- if (volume <= 0 || muted)
+ if (volume == 0 || muted)
n = 0;
else
n = CLAMP (3 * volume / normal + 1, 1, 3);
@@ -425,7 +426,9 @@ update_icon (GvcStreamStatusIcon *icon)
description = mate_mixer_stream_control_get_label (icon->priv->control);
- guint volume_percent = (guint) round (100.0 * volume / normal);
+ if (normal != 0)
+ volume_percent = (guint) (100.0 * ((double) volume) / ((double) normal));
+
if (muted) {
markup = g_strdup_printf ("<b>%s: %s %u%%</b>\n<small>%s</small>",
icon->priv->display_name,