make maximum digits compile time configurable via MAX_DIGITS and up to 20.
Wed Jun 20 05:32:05 2001 Tim Janik <timj@gtk.org> * 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.
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
Wed Jun 20 05:32:05 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* 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 <timj@gtk.org>
|
Wed Jun 20 04:28:24 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
|
* gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
|
||||||
|
|||||||
@ -1,3 +1,10 @@
|
|||||||
|
Wed Jun 20 05:32:05 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* 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 <timj@gtk.org>
|
Wed Jun 20 04:28:24 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
|
* gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
|
||||||
|
|||||||
@ -1,3 +1,10 @@
|
|||||||
|
Wed Jun 20 05:32:05 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* 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 <timj@gtk.org>
|
Wed Jun 20 04:28:24 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
|
* gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
|
||||||
|
|||||||
@ -1,3 +1,10 @@
|
|||||||
|
Wed Jun 20 05:32:05 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* 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 <timj@gtk.org>
|
Wed Jun 20 04:28:24 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
|
* gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
|
||||||
|
|||||||
@ -1,3 +1,10 @@
|
|||||||
|
Wed Jun 20 05:32:05 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* 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 <timj@gtk.org>
|
Wed Jun 20 04:28:24 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
|
* gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
|
||||||
|
|||||||
@ -1,3 +1,10 @@
|
|||||||
|
Wed Jun 20 05:32:05 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* 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 <timj@gtk.org>
|
Wed Jun 20 04:28:24 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
|
* gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
|
||||||
|
|||||||
@ -1,3 +1,10 @@
|
|||||||
|
Wed Jun 20 05:32:05 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* 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 <timj@gtk.org>
|
Wed Jun 20 04:28:24 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
|
* gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
|
||||||
|
|||||||
@ -43,9 +43,9 @@
|
|||||||
#define ARROW_SIZE 11
|
#define ARROW_SIZE 11
|
||||||
#define SPIN_BUTTON_INITIAL_TIMER_DELAY 200
|
#define SPIN_BUTTON_INITIAL_TIMER_DELAY 200
|
||||||
#define SPIN_BUTTON_TIMER_DELAY 20
|
#define SPIN_BUTTON_TIMER_DELAY 20
|
||||||
#define MAX_TEXT_LENGTH 256
|
|
||||||
#define MAX_TIMER_CALLS 5
|
#define MAX_TIMER_CALLS 5
|
||||||
#define EPSILON 1e-5
|
#define EPSILON 1e-5
|
||||||
|
#define MAX_DIGITS 20
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
@ -221,7 +221,7 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
|
|||||||
_("Digits"),
|
_("Digits"),
|
||||||
_("The number of decimal places to display"),
|
_("The number of decimal places to display"),
|
||||||
0,
|
0,
|
||||||
5,
|
MAX_DIGITS,
|
||||||
0,
|
0,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
@ -1451,11 +1451,11 @@ gtk_spin_button_default_input (GtkSpinButton *spin_button,
|
|||||||
static gint
|
static gint
|
||||||
gtk_spin_button_default_output (GtkSpinButton *spin_button)
|
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))))
|
if (strcmp (buf, gtk_entry_get_text (GTK_ENTRY (spin_button))))
|
||||||
gtk_entry_set_text (GTK_ENTRY (spin_button), buf);
|
gtk_entry_set_text (GTK_ENTRY (spin_button), buf);
|
||||||
|
g_free (buf);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1547,8 +1547,8 @@ gtk_spin_button_new_with_range (gdouble min,
|
|||||||
digits = 0;
|
digits = 0;
|
||||||
else {
|
else {
|
||||||
digits = abs ((gint) floor (log10 (fabs (step))));
|
digits = abs ((gint) floor (log10 (fabs (step))));
|
||||||
if (digits > 5)
|
if (digits > MAX_DIGITS)
|
||||||
digits = 5;
|
digits = MAX_DIGITS;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_spin_button_configure (spin, GTK_ADJUSTMENT (adj), step, 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
|
* @spin_button: a #GtkSpinButton
|
||||||
* @digits: the number of digits to be displayed for the spin button's value
|
* @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.
|
* is allowed.
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
|
|||||||
@ -93,7 +93,7 @@ struct _GtkSpinButton
|
|||||||
guint button : 2;
|
guint button : 2;
|
||||||
guint need_timer : 1;
|
guint need_timer : 1;
|
||||||
guint timer_calls : 3;
|
guint timer_calls : 3;
|
||||||
guint digits : 3;
|
guint digits : 10;
|
||||||
guint numeric : 1;
|
guint numeric : 1;
|
||||||
guint wrap : 1;
|
guint wrap : 1;
|
||||||
guint snap_to_ticks : 1;
|
guint snap_to_ticks : 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user