]> saetta.ns0.it Git - libgtkform/commitdiff
Bugfixes to work with GtkSpinButton.
authorAndrea Zagli <azagli@libero.it>
Sun, 2 Oct 2011 08:19:16 +0000 (10:19 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 2 Oct 2011 08:19:16 +0000 (10:19 +0200)
libgtkform/fieldfloat.c
libgtkform/fieldinteger.c

index b4e82d839bb53a8b6735e030d4c1288034f64683..b42a1909910eb12a59b0414f07bea3f06f84ad92 100644 (file)
@@ -372,7 +372,26 @@ gtk_form_field_float_is_valid (GtkFormField *field)
 
                        if (str_value != NULL && g_strcmp0 (g_strstrip (str_value), "") != 0)
                                {
-                                       str_format = g_strdup_printf ("%%0%dd", 6 - (str_comma != NULL ? strlen (str_comma) - 1 : 0));
+                                       if (str_comma == NULL)
+                                               {
+                                                       str_format = g_strdup ("%%06d");
+                                               }
+                                       else
+                                               {
+                                                       if (strlen (str_comma) < 6)
+                                                               {
+                                                                       str_format = g_strdup_printf ("%%0%dd", 6 - strlen (str_comma) - 1);
+                                                               }
+                                                       else
+                                                               {
+                                                                       if (strlen (str_comma) > 6)
+                                                                               {
+                                                                                       str_value = g_strndup (str_value, strlen (str_value) - strlen (str_comma) + 7);
+                                                                               }
+                                                                       str_format = NULL;
+                                                               }
+                                               }
+
                                        if (g_strcmp0 (g_strdup_printf ("%f", dbl_value), g_strdup_printf (g_strconcat ("%s", (str_comma == NULL ? "," : ""), str_format, NULL), str_value, 0)) != 0)
                                                {
                                                        g_free (str_value);
index 0d3519a5c036733e56db90ead232eff563a565b1..f9b18f34e01f3d97b0acc9c393dda52df89c7512 100644 (file)
@@ -23,6 +23,7 @@
 #include <glib/gi18n-lib.h>
 
 #include "widget.h"
+#include "widgetspin.h"
 #include "fieldinteger.h"
 
 enum
@@ -314,7 +315,9 @@ gtk_form_field_integer_is_valid (GtkFormField *field)
 
                        if (str_value != NULL && g_strcmp0 (g_strstrip (str_value), "") != 0)
                                {
-                                       if (g_strcmp0 (g_strdup_printf ("%d", value), str_value) != 0)
+                                       if (g_strcmp0 (g_strconcat (g_strdup_printf ("%d", value),
+                                                                   IS_GTK_FORM_WIDGET_SPIN (fw) ? g_strdup_printf (",%06d", 0) : "", NULL), 
+                                                      str_value) != 0)
                                                {
                                                        g_free (str_value);
                                                        return FALSE;