Commit 5c7c11ce authored by Havoc Pennington's avatar Havoc Pennington Committed by Havoc Pennington

Get rid of stupid g_return_if_fail on digits greater than 6. If there

2001-06-04  Havoc Pennington  <hp@redhat.com>

	* gtk/gtkspinbutton.c: Get rid of stupid g_return_if_fail on
	digits greater than 6. If there actually are limits (which there
	likely aren't), should clamp to them not warn.
	(gtk_spin_button_new_with_range): don't take log of 0
	(gtk_spin_button_size_request): use digits to compute size
	request, rather than step increment.

	* tests/testgtk.c (create_spins): test larger values of digits

	* gtk/gtkfontsel.c (gtk_font_selection_init): scroll to selected
	font on map not expose, so we don't get weirdness during scrolling
parent 2d1f353a
2001-06-04 Havoc Pennington <hp@redhat.com>
* gtk/gtkspinbutton.c: Get rid of stupid g_return_if_fail on
digits greater than 6. If there actually are limits (which there
likely aren't), should clamp to them not warn.
(gtk_spin_button_new_with_range): don't take log of 0
(gtk_spin_button_size_request): use digits to compute size
request, rather than step increment.
* tests/testgtk.c (create_spins): test larger values of digits
* gtk/gtkfontsel.c (gtk_font_selection_init): scroll to selected
font on map not expose, so we don't get weirdness during scrolling
2001-06-04 Havoc Pennington <hp@redhat.com>
* gtk/gtkclist.c (vadjustment_value_changed): Apply fix from
......
2001-06-04 Havoc Pennington <hp@redhat.com>
* gtk/gtkspinbutton.c: Get rid of stupid g_return_if_fail on
digits greater than 6. If there actually are limits (which there
likely aren't), should clamp to them not warn.
(gtk_spin_button_new_with_range): don't take log of 0
(gtk_spin_button_size_request): use digits to compute size
request, rather than step increment.
* tests/testgtk.c (create_spins): test larger values of digits
* gtk/gtkfontsel.c (gtk_font_selection_init): scroll to selected
font on map not expose, so we don't get weirdness during scrolling
2001-06-04 Havoc Pennington <hp@redhat.com>
* gtk/gtkclist.c (vadjustment_value_changed): Apply fix from
......
2001-06-04 Havoc Pennington <hp@redhat.com>
* gtk/gtkspinbutton.c: Get rid of stupid g_return_if_fail on
digits greater than 6. If there actually are limits (which there
likely aren't), should clamp to them not warn.
(gtk_spin_button_new_with_range): don't take log of 0
(gtk_spin_button_size_request): use digits to compute size
request, rather than step increment.
* tests/testgtk.c (create_spins): test larger values of digits
* gtk/gtkfontsel.c (gtk_font_selection_init): scroll to selected
font on map not expose, so we don't get weirdness during scrolling
2001-06-04 Havoc Pennington <hp@redhat.com>
* gtk/gtkclist.c (vadjustment_value_changed): Apply fix from
......
2001-06-04 Havoc Pennington <hp@redhat.com>
* gtk/gtkspinbutton.c: Get rid of stupid g_return_if_fail on
digits greater than 6. If there actually are limits (which there
likely aren't), should clamp to them not warn.
(gtk_spin_button_new_with_range): don't take log of 0
(gtk_spin_button_size_request): use digits to compute size
request, rather than step increment.
* tests/testgtk.c (create_spins): test larger values of digits
* gtk/gtkfontsel.c (gtk_font_selection_init): scroll to selected
font on map not expose, so we don't get weirdness during scrolling
2001-06-04 Havoc Pennington <hp@redhat.com>
* gtk/gtkclist.c (vadjustment_value_changed): Apply fix from
......
2001-06-04 Havoc Pennington <hp@redhat.com>
* gtk/gtkspinbutton.c: Get rid of stupid g_return_if_fail on
digits greater than 6. If there actually are limits (which there
likely aren't), should clamp to them not warn.
(gtk_spin_button_new_with_range): don't take log of 0
(gtk_spin_button_size_request): use digits to compute size
request, rather than step increment.
* tests/testgtk.c (create_spins): test larger values of digits
* gtk/gtkfontsel.c (gtk_font_selection_init): scroll to selected
font on map not expose, so we don't get weirdness during scrolling
2001-06-04 Havoc Pennington <hp@redhat.com>
* gtk/gtkclist.c (vadjustment_value_changed): Apply fix from
......
2001-06-04 Havoc Pennington <hp@redhat.com>
* gtk/gtkspinbutton.c: Get rid of stupid g_return_if_fail on
digits greater than 6. If there actually are limits (which there
likely aren't), should clamp to them not warn.
(gtk_spin_button_new_with_range): don't take log of 0
(gtk_spin_button_size_request): use digits to compute size
request, rather than step increment.
* tests/testgtk.c (create_spins): test larger values of digits
* gtk/gtkfontsel.c (gtk_font_selection_init): scroll to selected
font on map not expose, so we don't get weirdness during scrolling
2001-06-04 Havoc Pennington <hp@redhat.com>
* gtk/gtkclist.c (vadjustment_value_changed): Apply fix from
......
2001-06-04 Havoc Pennington <hp@redhat.com>
* gtk/gtkspinbutton.c: Get rid of stupid g_return_if_fail on
digits greater than 6. If there actually are limits (which there
likely aren't), should clamp to them not warn.
(gtk_spin_button_new_with_range): don't take log of 0
(gtk_spin_button_size_request): use digits to compute size
request, rather than step increment.
* tests/testgtk.c (create_spins): test larger values of digits
* gtk/gtkfontsel.c (gtk_font_selection_init): scroll to selected
font on map not expose, so we don't get weirdness during scrolling
2001-06-04 Havoc Pennington <hp@redhat.com>
* gtk/gtkclist.c (vadjustment_value_changed): Apply fix from
......
......@@ -122,8 +122,7 @@ static void gtk_font_selection_select_size (GtkWidget *w,
GdkEventButton *bevent,
gpointer data);
static void gtk_font_selection_expose_list (GtkWidget *w,
GdkEventExpose *event,
static void gtk_font_selection_scroll_on_map (GtkWidget *w,
gpointer data);
static void gtk_font_selection_preview_changed (GtkWidget *entry,
......@@ -370,8 +369,8 @@ gtk_font_selection_init(GtkFontSelection *fontsel)
fontsel);
GTK_WIDGET_SET_FLAGS (fontsel->font_clist, GTK_CAN_FOCUS);
gtk_signal_connect_after (GTK_OBJECT (fontsel->font_clist), "expose_event",
GTK_SIGNAL_FUNC(gtk_font_selection_expose_list),
gtk_signal_connect_after (GTK_OBJECT (fontsel->font_clist), "map",
GTK_SIGNAL_FUNC(gtk_font_selection_scroll_on_map),
fontsel);
gtk_font_selection_show_available_styles (fontsel);
......@@ -449,12 +448,11 @@ gtk_font_selection_preview_changed (GtkWidget *entry,
g_object_notify (G_OBJECT (fontsel), "preview_text");
}
/* This is called when the clist is exposed. Here we scroll to the current
/* This is called when the clist is mapped. Here we scroll to the current
font if necessary. */
static void
gtk_font_selection_expose_list (GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
gtk_font_selection_scroll_on_map (GtkWidget *widget,
gpointer data)
{
GtkFontSelection *fontsel;
GList *selection;
......
......@@ -527,30 +527,26 @@ gtk_spin_button_unrealize (GtkWidget *widget)
}
static int
compute_double_length (double val, double step)
compute_double_length (double val, int digits)
{
int a, b;
int a;
int extra;
a = 1;
if (fabs (val) > 1.0)
a = floor (log10 (fabs (val))) + 1;
b = 0;
if (fabs (step) < 1.0 && step != 0.0)
b = ceil (-log10 (fabs (step)));
a = floor (log10 (fabs (val))) + 1;
extra = 0;
/* The dot: */
if (b > 0)
if (digits > 0)
extra++;
/* The sign: */
if (val < 0)
extra++;
return a + b + extra;
return a + digits + extra;
}
static void
......@@ -591,7 +587,7 @@ gtk_spin_button_size_request (GtkWidget *widget,
width = MIN_SPIN_BUTTON_WIDTH;
string_len = compute_double_length (spin_button->adjustment->upper,
spin_button->adjustment->step_increment);
spin_button->digits);
w = MIN (string_len, 10) * PANGO_PIXELS (metrics.approximate_digit_width);
width = MAX (width, w);
string_len = compute_double_length (spin_button->adjustment->lower,
......@@ -1479,7 +1475,6 @@ gtk_spin_button_configure (GtkSpinButton *spin_button,
{
g_return_if_fail (spin_button != NULL);
g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
g_return_if_fail (digits < 6);
if (adjustment)
gtk_spin_button_set_adjustment (spin_button, adjustment);
......@@ -1510,7 +1505,6 @@ gtk_spin_button_new (GtkAdjustment *adjustment,
if (adjustment)
g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), NULL);
g_return_val_if_fail (digits < 6, NULL);
spin = gtk_type_new (GTK_TYPE_SPIN_BUTTON);
......@@ -1549,7 +1543,7 @@ gtk_spin_button_new_with_range (gdouble min,
adj = gtk_adjustment_new (min, min, max, step, 10 * step, step);
if (fabs (step) >= 1.0)
if (fabs (step) >= 1.0 || step == 0.0)
digits = 0;
else {
digits = abs ((gint) floor (log10 (fabs (step))));
......@@ -1646,7 +1640,6 @@ gtk_spin_button_set_digits (GtkSpinButton *spin_button,
guint digits)
{
g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
g_return_if_fail (digits < 6);
if (spin_button->digits != digits)
{
......
......@@ -4093,7 +4093,7 @@ create_spins (void)
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new (2, 1, 5, 1, 1, 0);
adj = (GtkAdjustment *) gtk_adjustment_new (2, 1, 15, 1, 1, 0);
spinner2 = gtk_spin_button_new (adj, 0.0, 0);
gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
GTK_SIGNAL_FUNC (change_digits),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment