+ // Get value directly from current control text, just as
+ // gtk_spin_button_update() would do. Calling gtk_spin_button_update() causes
+ // a redraw, which causes an idle event, so if GetValue() is called from
+ // a UI update handler, you get a never ending sequence of idle events. It
+ // also forces the text into valid range, which wxMSW GetValue() does not do.
+ static unsigned sig_id;
+ if (sig_id == 0)
+ sig_id = g_signal_lookup("input", GTK_TYPE_SPIN_BUTTON);
+ double value;
+ int handled = 0;
+ g_signal_emit(m_widget, sig_id, 0, &value, &handled);
+ if (!handled)
+ value = g_strtod(gtk_entry_get_text(GTK_ENTRY(m_widget)), NULL);
+ const GtkAdjustment* adj =
+ gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(m_widget));
+ if (value < adj->lower)
+ value = adj->lower;
+ else if (value > adj->upper)
+ value = adj->upper;
+
+ return value;