diff options
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) |