GtkSpinButton - emits "value_changed" twice sometimes
Submitted by Damon Chaplin
Link to original bug (#316771)
Description
If you set the step increment of a spin button with more precision than the number of digits shown, it emits "value_changed" twice for each click on the up/down arrows. (It seems to round the value first, then add the increment.)
Here's a test app:
/*
* Compile with:
*
* gcc `pkg-config --cflags --libs gtk+-2.0` test-gtk.c
*/
#include <gtk/gtk.h>
void
on_spinbutton1_value_changed (GtkSpinButton *spin)
{
g_print ("%f\n", gtk_spin_button_get_value (spin));
}
int
main(int argc, char **argv)
{
GtkWidget *window1;
GtkObject *spinbutton1_adj;
GtkWidget *spinbutton1;
gtk_init (&argc, &argv);
window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
/* Note that we use 3 decimal places here, but only 2 are shown in the
spinbutton. */
spinbutton1_adj = gtk_adjustment_new (1, 0, 100, 0.123, 10, 10);
spinbutton1 = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton1_adj), 1, 2);
gtk_widget_show (spinbutton1);
gtk_container_add (GTK_CONTAINER (window1), spinbutton1);
g_signal_connect ((gpointer) spinbutton1, "value_changed",
G_CALLBACK (on_spinbutton1_value_changed),
NULL);
gtk_widget_show (window1);
gtk_main ();
return 0;
}
Version: 3.22.x