diff --git a/ChangeLog b/ChangeLog index 7106a7ea5a..f5ca6c9107 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Jun 20 05:32:05 2001 Tim Janik + + * gtk/gtkspinbutton.c: make maximum digits compile time configurable + via MAX_DIGITS and up to 20. 5 was just ridiculously small. + don't use automatic fixed size buffer for printf-ing floats, doubles + can expand to really _huge_ strings, use g_strdup_printf() instead. + Wed Jun 20 04:28:24 2001 Tim Janik * gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 7106a7ea5a..f5ca6c9107 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,10 @@ +Wed Jun 20 05:32:05 2001 Tim Janik + + * gtk/gtkspinbutton.c: make maximum digits compile time configurable + via MAX_DIGITS and up to 20. 5 was just ridiculously small. + don't use automatic fixed size buffer for printf-ing floats, doubles + can expand to really _huge_ strings, use g_strdup_printf() instead. + Wed Jun 20 04:28:24 2001 Tim Janik * gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 7106a7ea5a..f5ca6c9107 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +Wed Jun 20 05:32:05 2001 Tim Janik + + * gtk/gtkspinbutton.c: make maximum digits compile time configurable + via MAX_DIGITS and up to 20. 5 was just ridiculously small. + don't use automatic fixed size buffer for printf-ing floats, doubles + can expand to really _huge_ strings, use g_strdup_printf() instead. + Wed Jun 20 04:28:24 2001 Tim Janik * gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 7106a7ea5a..f5ca6c9107 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,10 @@ +Wed Jun 20 05:32:05 2001 Tim Janik + + * gtk/gtkspinbutton.c: make maximum digits compile time configurable + via MAX_DIGITS and up to 20. 5 was just ridiculously small. + don't use automatic fixed size buffer for printf-ing floats, doubles + can expand to really _huge_ strings, use g_strdup_printf() instead. + Wed Jun 20 04:28:24 2001 Tim Janik * gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 7106a7ea5a..f5ca6c9107 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,10 @@ +Wed Jun 20 05:32:05 2001 Tim Janik + + * gtk/gtkspinbutton.c: make maximum digits compile time configurable + via MAX_DIGITS and up to 20. 5 was just ridiculously small. + don't use automatic fixed size buffer for printf-ing floats, doubles + can expand to really _huge_ strings, use g_strdup_printf() instead. + Wed Jun 20 04:28:24 2001 Tim Janik * gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 7106a7ea5a..f5ca6c9107 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,10 @@ +Wed Jun 20 05:32:05 2001 Tim Janik + + * gtk/gtkspinbutton.c: make maximum digits compile time configurable + via MAX_DIGITS and up to 20. 5 was just ridiculously small. + don't use automatic fixed size buffer for printf-ing floats, doubles + can expand to really _huge_ strings, use g_strdup_printf() instead. + Wed Jun 20 04:28:24 2001 Tim Janik * gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 7106a7ea5a..f5ca6c9107 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +Wed Jun 20 05:32:05 2001 Tim Janik + + * gtk/gtkspinbutton.c: make maximum digits compile time configurable + via MAX_DIGITS and up to 20. 5 was just ridiculously small. + don't use automatic fixed size buffer for printf-ing floats, doubles + can expand to really _huge_ strings, use g_strdup_printf() instead. + Wed Jun 20 04:28:24 2001 Tim Janik * gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index 90bc385115..73816e7771 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -43,9 +43,9 @@ #define ARROW_SIZE 11 #define SPIN_BUTTON_INITIAL_TIMER_DELAY 200 #define SPIN_BUTTON_TIMER_DELAY 20 -#define MAX_TEXT_LENGTH 256 #define MAX_TIMER_CALLS 5 #define EPSILON 1e-5 +#define MAX_DIGITS 20 enum { PROP_0, @@ -221,7 +221,7 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class) _("Digits"), _("The number of decimal places to display"), 0, - 5, + MAX_DIGITS, 0, G_PARAM_READWRITE)); @@ -1451,11 +1451,11 @@ gtk_spin_button_default_input (GtkSpinButton *spin_button, static gint gtk_spin_button_default_output (GtkSpinButton *spin_button) { - gchar buf[MAX_TEXT_LENGTH]; + gchar *buf = g_strdup_printf ("%0.*f", spin_button->digits, spin_button->adjustment->value); - sprintf (buf, "%0.*f", spin_button->digits, spin_button->adjustment->value); if (strcmp (buf, gtk_entry_get_text (GTK_ENTRY (spin_button)))) gtk_entry_set_text (GTK_ENTRY (spin_button), buf); + g_free (buf); return FALSE; } @@ -1547,8 +1547,8 @@ gtk_spin_button_new_with_range (gdouble min, digits = 0; else { digits = abs ((gint) floor (log10 (fabs (step)))); - if (digits > 5) - digits = 5; + if (digits > MAX_DIGITS) + digits = MAX_DIGITS; } gtk_spin_button_configure (spin, GTK_ADJUSTMENT (adj), step, digits); @@ -1632,7 +1632,7 @@ gtk_spin_button_get_adjustment (GtkSpinButton *spin_button) * @spin_button: a #GtkSpinButton * @digits: the number of digits to be displayed for the spin button's value * - * Set the precision to be displayed by @spin_button. Up to 5 digit precision + * Set the precision to be displayed by @spin_button. Up to 20 digit precision * is allowed. **/ void diff --git a/gtk/gtkspinbutton.h b/gtk/gtkspinbutton.h index 1686ea27ad..b152ec3c38 100644 --- a/gtk/gtkspinbutton.h +++ b/gtk/gtkspinbutton.h @@ -93,7 +93,7 @@ struct _GtkSpinButton guint button : 2; guint need_timer : 1; guint timer_calls : 3; - guint digits : 3; + guint digits : 10; guint numeric : 1; guint wrap : 1; guint snap_to_ticks : 1;