diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2013-08-07 13:00:25 +0200 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2013-08-07 14:02:43 +0200 |
commit | 0a070ef023538e5b6a51d6168c92b5ea744f192f (patch) | |
tree | b07d1c07e5f6ef0d9c27cbd82adb69427df0261f | |
parent | 385ab2939c05b6d783df2012a4c02af843442342 (diff) | |
download | glade-0a070ef023538e5b6a51d6168c92b5ea744f192f.tar.gz |
Fixed sporadic behaviour of spin buttons.
There may be more issues, but now selecting the entry text and inserting
new text will not have any 0 appended.
This regression (fixed by this patch) was introduced by
commit 84990bcaec39109be3c53b1a13ba31ca5d865970
-rw-r--r-- | gladeui/glade-editor-property.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/gladeui/glade-editor-property.c b/gladeui/glade-editor-property.c index 2037931b..87844501 100644 --- a/gladeui/glade-editor-property.c +++ b/gladeui/glade-editor-property.c @@ -805,7 +805,21 @@ static void glade_eprop_numeric_force_update (GtkSpinButton *spin, GladeEditorProperty *eprop) { - gtk_spin_button_update (spin); + const gchar *txt; + + txt = gtk_entry_get_text (GTK_ENTRY (spin)); + + /* Here we only force an update if there is actually text + * to force an update with. + * + * If we unconditionally update the spin button whenever + * the entry changes we get bogus results (notably, the + * updating the spin button will insert 0 whenever text + * is removed, so selecting and inserting text will have + * an appended 0). + */ + if (txt && txt[0]) + gtk_spin_button_update (spin); } static GtkWidget * @@ -834,6 +848,10 @@ glade_eprop_numeric_create_input (GladeEditorProperty *eprop) if (gtk_adjustment_get_upper (adjustment) > 9999999999999999.0) gtk_entry_set_width_chars (GTK_ENTRY (eprop_numeric->spin), 16); + /* The force update callback is here to ensure that whenever the value + * is modified, it's committed immediately without requiring entry activation + * (this avoids lost modifications when modifying a value and navigating away) + */ g_signal_connect (G_OBJECT (eprop_numeric->spin), "changed", G_CALLBACK (glade_eprop_numeric_force_update), eprop); |