GNOME Bugzilla – Bug 118959
GtkScale value '-0'
Last modified: 2016-06-08 03:07:46 UTC
If you have a hscale which has the range -100 to 100 (any neagtive to any
positive), then the value next to the scale is -0, when you move from the
right (negative) to the left. If you move the other way (from positive to
negative), then the value is 0.
It would be nice, if it didn't show that minus-sign in front of the zero.
I think the best thing to do is probably to simply
in _gtk_scale_format_value() check whether the outut
of g_strdup_printf("%0.*f") has a leading - sign
and no digits other than 0, and if so, strip the
leading - sign. (g_ascii_digit_value() probably
useful in the implementation)
Trying to avoid small negative values before formatting
is going to be less reliable and harder to implement.
Same issue for GtkSpinbutton in bug 139858
*** Bug 139858 has been marked as a duplicate of this bug. ***
Mass changing gtk+ bugs with target milestone of 2.4.2 to target 2.4.4, as
Matthias said he was trying to do himself on IRC and was asking for help with.
If you see this message, it means I was successful at fixing the borken-ness in
bugzilla :) Sorry for the spam; just query on this message and delete all
emails you get with this message, since there will probably be a lot.
I don't seem to be able to reproduce this with HEAD. Maybe ITFIXEDITSELF?
The core of the problem seem to be g_strdup_printf() which GtkScale uses in _gtk_scale_format_value. E.g:
gchar *s = g_strdup_printf ("%0.*f", 5, -0.0);
will create the string "-0.00000" on my machine. But the output is very much hardware and C library dependant, on Windows it is very likely to come out as "0.00000" without the minus sign. IEEE 754 defines negative zero as a valid number distinct from 0, but it isn't implemented like that on many platforms.
So I think the bug is in g_strdup_printf() that should string format negative zeroes as a normal, positive ones instead. Negative zeroes aren't very useful anyway and since they are platform dependant, we might as well skip them.