[glade/glade-3-18] Fixed bug in numeric property editors



commit 5f10a02793fb6f5eee93fd6cd0a708e58b397497
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date:   Wed Mar 26 16:58:24 2014 -0300

    Fixed bug in numeric property editors

 gladeui/glade-editor-property.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/gladeui/glade-editor-property.c b/gladeui/glade-editor-property.c
index 790eff1..326a546 100644
--- a/gladeui/glade-editor-property.c
+++ b/gladeui/glade-editor-property.c
@@ -816,9 +816,17 @@ glade_eprop_numeric_force_update (GtkSpinButton       *spin,
   gdouble value;
   gchar *text;
 
-  val = glade_property_inline_value (prop);
   text = gtk_editable_get_chars (GTK_EDITABLE (spin), 0, -1);
 
+  /*
+   * Skip empty strings, otherwise if 0 is out of range the spin will get a
+   * bogus update.
+   */
+  if (text && *text == '\0')
+    return;
+  
+  val = glade_property_inline_value (prop);
+
   g_value_init (&newval, G_VALUE_TYPE (val));
   value = g_strtod (text, NULL);
   glade_eprop_numeric_value_set (&newval, value);
@@ -890,9 +898,6 @@ glade_eprop_numeric_create_input (GladeEditorProperty *eprop)
   /* 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)
-   *
-   * FIXME: GtkSpinButton update its value on focus-out, why is not that enough?
-   * Could it be because this callback was used before using spins?
    */
   g_signal_connect (G_OBJECT (eprop_numeric->spin), "changed",
                     G_CALLBACK (glade_eprop_numeric_force_update), eprop);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]