diff options
author | Havoc Pennington <hp@redhat.com> | 2001-06-05 20:07:02 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2001-06-05 20:07:02 +0000 |
commit | b32e7c9bb82396e4930957bb649a2e1cd57f00c1 (patch) | |
tree | b95893653c899c31699a91803eebeb1e934e7f1e /gtk/gtkvscale.c | |
parent | 451b224324864047842dfe009834a0fe53728147 (diff) | |
download | gtk+-b32e7c9bb82396e4930957bb649a2e1cd57f00c1.tar.gz |
clamp the value to the range that was set
2001-06-05 Havoc Pennington <hp@redhat.com>
* gtk/gtkspinbutton.c (gtk_spin_button_set_range): clamp the value
to the range that was set
* gtk/gtkrange.c: add value_changed signal, primarily
intended for use with GtkScale
(gtk_range_set_increments): new function
(gtk_range_set_range): new function with weird name
(gtk_range_set_value): new function
(gtk_range_get_value): new function
* gtk/gtkspinbutton.c (gtk_spin_button_get_value): rename
from gtk_spin_button_get_value_as_float(). Compat #define
added for get_value_as_float.
* gtk/gtkhscale.c (gtk_hscale_new_with_range): new function
* gtk/gtkvscale.c (gtk_vscale_new_with_range): new function
2001-06-05 Havoc Pennington <hp@redhat.com>
* test-loaders.c (main): use putenv not setenv, reported by
Armin Theissen
Diffstat (limited to 'gtk/gtkvscale.c')
-rw-r--r-- | gtk/gtkvscale.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/gtk/gtkvscale.c b/gtk/gtkvscale.c index 9a60d5ad84..2dca2cc99e 100644 --- a/gtk/gtkvscale.c +++ b/gtk/gtkvscale.c @@ -103,6 +103,51 @@ gtk_vscale_new (GtkAdjustment *adjustment) return vscale; } + +/** + * gtk_vscale_new_with_range: + * @min: minimum value + * @max: maximum value + * @step: step increment (tick size) used with keyboard shortcuts + * + * Creates a new vertical scale widget that lets the user + * input a number between @min and @max with the increment @step. + * @step must be nonzero; it's the distance the slider moves when + * using the arrow keys to adjust the scale value. + * + * Return value: a new #GtkVScale + **/ +GtkWidget* +gtk_vscale_new_with_range (gdouble min, + gdouble max, + gdouble step) +{ + GtkObject *adj; + GtkScale *scale; + gint digits; + + g_return_val_if_fail (min < max, NULL); + g_return_val_if_fail (step != 0.0, NULL); + + adj = gtk_adjustment_new (min, min, max, step, 10 * step, step); + + scale = g_object_new (GTK_TYPE_VSCALE, + "adjustment", adj, + NULL); + + if (fabs (step) >= 1.0 || step == 0.0) + digits = 0; + else { + digits = abs ((gint) floor (log10 (fabs (step)))); + if (digits > 5) + digits = 5; + } + + gtk_scale_set_digits (scale, digits); + + return GTK_WIDGET (scale); +} + static gboolean gtk_vscale_expose (GtkWidget *widget, GdkEventExpose *event) |