mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-29 15:22:11 +02:00
clapper-gtk/extra-menu: Fixed speed being forced to the lowest value
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" <sp1rit@disroot.org>
This commit is contained in:
@@ -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'))
|
||||
|
Reference in New Issue
Block a user