From a63d92601f5065be3098b29183745ec0143f21ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20=22sp1rit=22=E2=80=8B?= Date: Wed, 10 Apr 2024 12:08:23 +0200 Subject: [PATCH] clapper-gtk/extra-menu: Fixed speed being forced to the lowest value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As the SpinButton input callback attempted to parse the value inserted as a string by printf using g_ascii_strtod, only if the language also used . (full stop / u002E) as decimal seperator worked correctly. Otherwise, parsing would fail and result (after a few iterations) in the lowest value being set. The usually correct approach is to use g_ascii_dtostr / g_ascii_formatd instead of printf to format a decimal number, but given that this number is actually presented to the user, going with g_strtod seems like a better choice (I've decided against just using the stdlib strtod as to allow the SpinButton to also recognize manual user input containing the full stop instead of their languages native decimal seperator (not that that'll ever happen, given the user can't focus the SpinButton entry while media is running). I've also fixed this for the volume SpinButton too, but it wasn't really affected in the first place as it appearently always gets rounded up to a number without decimal places. Signed-off-by: Florian "sp1rit"​ --- src/lib/clapper-gtk/clapper-gtk-extra-menu-button.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/clapper-gtk/clapper-gtk-extra-menu-button.c b/src/lib/clapper-gtk/clapper-gtk-extra-menu-button.c index 69723806..922e1efd 100644 --- a/src/lib/clapper-gtk/clapper-gtk-extra-menu-button.c +++ b/src/lib/clapper-gtk/clapper-gtk-extra-menu-button.c @@ -129,7 +129,7 @@ volume_spin_input_cb (GtkSpinButton *spin_button, gdouble *value, ClapperGtkExtr { const gchar *text = gtk_editable_get_text (GTK_EDITABLE (spin_button)); gchar *sign = NULL; - gdouble volume = g_ascii_strtod (text, &sign); + gdouble volume = g_strtod (text, &sign); if (volume < 0 || volume > 200 || (sign && sign[0] != '\0' && sign[0] != '%')) @@ -174,7 +174,7 @@ speed_spin_input_cb (GtkSpinButton *spin_button, gdouble *value, ClapperGtkExtra { const gchar *text = gtk_editable_get_text (GTK_EDITABLE (spin_button)); gchar *sign = NULL; - gdouble speed = g_ascii_strtod (text, &sign); + gdouble speed = g_strtod (text, &sign); if (speed < 0.05 || speed > 2.0 || (sign && sign[0] != '\0' && sign[0] != 'x'))