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
This commit is contained in:
Havoc Pennington 2001-06-05 20:07:02 +00:00 committed by Havoc Pennington
parent 451b224324
commit b32e7c9bb8
23 changed files with 493 additions and 32 deletions

View File

@ -1,3 +1,23 @@
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
Tue Jun 5 14:57:18 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_get_size): Fix bug #55573

View File

@ -1,3 +1,23 @@
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
Tue Jun 5 14:57:18 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_get_size): Fix bug #55573

View File

@ -1,3 +1,23 @@
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
Tue Jun 5 14:57:18 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_get_size): Fix bug #55573

View File

@ -1,3 +1,23 @@
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
Tue Jun 5 14:57:18 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_get_size): Fix bug #55573

View File

@ -1,3 +1,23 @@
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
Tue Jun 5 14:57:18 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_get_size): Fix bug #55573

View File

@ -1,3 +1,23 @@
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
Tue Jun 5 14:57:18 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_get_size): Fix bug #55573

View File

@ -1,3 +1,23 @@
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
Tue Jun 5 14:57:18 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_get_size): Fix bug #55573

View File

@ -1,3 +1,7 @@
2001-06-05 Havoc Pennington <hp@redhat.com>
* gtk/tmpl/gtkscale.sgml: more docs
Tue Jun 5 10:54:48 2001 Owen Taylor <otaylor@redhat.com>
* gtk/tmpl/gtkenums.sgml: Improve docs for GtkStateType.

View File

@ -7,9 +7,8 @@ a horizontal slider widget for selecting a value from a range.
<!-- ##### SECTION Long_Description ##### -->
<para>
The #GtkHScale widget is used to allow the user to select a value using
a horizontal slider.
A #GtkAdjustment is used to set the initial value, the lower
and upper bounds, and the step and page increments.
a horizontal slider. To create one, use
gtk_hscale_new_with_range().
</para>
<para>
The position to show the current value, and the number of decimal places

View File

@ -67,14 +67,21 @@ GtkRange
<!-- ##### SIGNAL GtkRange::move-slider ##### -->
<para>
Virtual function that moves the slider. Used for keybindings.
</para>
@range: the object which received the signal.
@arg1:
@range: the #GtkRange
@step: how to move the slider
<!-- # Unused Parameters # -->
@arg2:
<!-- ##### SIGNAL GtkRange::value-changed ##### -->
<para>
Emitted when the range value changes.
</para>
@range: the #GtkRange
<!-- ##### ARG GtkRange:update-policy ##### -->
<para>

View File

@ -6,8 +6,17 @@ a base class for #GtkHScale and #GtkVScale.
<!-- ##### SECTION Long_Description ##### -->
<para>
A #GtkScale is a slider control used to select a numeric value.
To use it, you'll probably want to investigate the methods on
its base class, #GtkRange, in addition to the methods for #GtkScale itself.
To set the value of a scale, you would normally use gtk_range_set_value().
To detect changes to the value, you would normally use the "value_changed"
signal.
</para>
<para>
The #GtkScale widget is an abstract class, used only for deriving the
subclasses #GtkHScale and #GtkVScale.
subclasses #GtkHScale and #GtkVScale. To create a scale widget,
call gtk_hscale_new_with_range() or gtk_vscale_new_with_range().
</para>
<!-- ##### SECTION See_Also ##### -->
@ -74,12 +83,25 @@ Sets the position in which the current value is displayed.
<!-- ##### SIGNAL GtkScale::format-value ##### -->
<para>
Signal which allows you to change how the scale value is displayed. Connect a
signal handler which returns an allocated string representing @value.
That string will then be used to display the scale's value.
Here's an example signal handler which displays a value 1.0 as
with "-->1.0<--".
<programlisting>
static gchar*
format_value_callback (GtkScale *scale,
gdouble value)
{
return g_strdup_printf ("-->%0.*g<--",
gtk_scale_get_digits (scale), value);
}
</programlisting>
</para>
@scale: the object which received the signal.
@arg1:
@Returns:
@value: value to format
@Returns: allocated string representing @value
<!-- ##### ARG GtkScale:digits ##### -->
<para>

View File

@ -230,13 +230,14 @@ Creates a new #GtkSpinButton.
@max:
<!-- ##### FUNCTION gtk_spin_button_get_value_as_float ##### -->
<!-- ##### MACRO gtk_spin_button_get_value_as_float ##### -->
<para>
</para>
@spin_button:
@Returns:
<!-- # Unused Parameters # -->
@spin_button:
<!-- ##### FUNCTION gtk_spin_button_get_value_as_int ##### -->

View File

@ -8,8 +8,7 @@ a vertical slider widget for selecting a value from a range.
<para>
The #GtkVScale widget is used to allow the user to select a value using
a vertical slider.
A #GtkAdjustment is used to set the initial value, the lower
and upper bounds, and the step and page increments.
To create one, use gtk_hscale_new_with_range().
</para>
<para>
The position to show the current value, and the number of decimal places

View File

@ -1,3 +1,8 @@
2001-06-05 Havoc Pennington <hp@redhat.com>
* test-loaders.c (main): use putenv not setenv, reported by
Armin Theissen
2001-05-08 Havoc Pennington <hp@redhat.com>
* gdk-pixbuf-util.c (gdk_pixbuf_add_alpha): docs fixup,

View File

@ -373,7 +373,7 @@ main (int argc, char **argv)
g_type_init (G_TYPE_DEBUG_NONE);
g_log_set_fatal_mask (NULL, G_LOG_LEVEL_WARNING | G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
setenv ("GDK_PIXBUF_MODULEDIR", BUILT_MODULES_DIR, TRUE);
putenv ("GDK_PIXBUF_MODULEDIR="BUILT_MODULES_DIR);
TEST (valid_gif_test, TRUE);
TEST (gif_test_1, FALSE);

View File

@ -102,6 +102,50 @@ gtk_hscale_new (GtkAdjustment *adjustment)
return hscale;
}
/**
* gtk_hscale_new_with_range:
* @min: minimum value
* @max: maximum value
* @step: step increment (tick size) used with keyboard shortcuts
*
* Creates a new horizontal 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 #GtkHScale
**/
GtkWidget*
gtk_hscale_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_HSCALE,
"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_hscale_expose (GtkWidget *widget,
GdkEventExpose *event)

View File

@ -59,8 +59,11 @@ struct _GtkHScaleClass
};
GtkType gtk_hscale_get_type (void) G_GNUC_CONST;
GtkWidget* gtk_hscale_new (GtkAdjustment *adjustment);
GtkType gtk_hscale_get_type (void) G_GNUC_CONST;
GtkWidget* gtk_hscale_new (GtkAdjustment *adjustment);
GtkWidget* gtk_hscale_new_with_range (gdouble min,
gdouble max,
gdouble step);
#ifdef __cplusplus

View File

@ -43,6 +43,7 @@ enum {
};
enum {
VALUE_CHANGED,
MOVE_SLIDER,
LAST_SIGNAL
};
@ -222,6 +223,15 @@ gtk_range_class_init (GtkRangeClass *class)
class->slider_detail = "slider";
class->stepper_detail = "stepper";
signals[VALUE_CHANGED] =
g_signal_newc ("value_changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkRangeClass, value_changed),
NULL, NULL,
gtk_marshal_NONE__NONE,
G_TYPE_NONE, 0);
signals[MOVE_SLIDER] =
g_signal_newc ("move_slider",
@ -353,6 +363,17 @@ gtk_range_init (GtkRange *range)
range->timer = NULL;
}
/**
* gtk_range_get_adjustment:
* @range: a #GtkRange
*
* Get the #GtkAdjustment which is the "model" object for #GtkRange.
* See gtk_range_set_adjustment() for details.
* The return value does not have a reference added, so should not
* be unreferenced.
*
* Return value: a #GtkAdjustment
**/
GtkAdjustment*
gtk_range_get_adjustment (GtkRange *range)
{
@ -365,6 +386,21 @@ gtk_range_get_adjustment (GtkRange *range)
return range->adjustment;
}
/**
* gtk_range_set_update_policy:
* @range: a #GtkRange
* @policy: update policy
*
* Sets the update policy for the range. #GTK_UPDATE_CONTINUOUS means that
* anytime the range slider is moved, the range value will change and the
* value_changed signal will be emitted. #GTK_UPDATE_DELAYED means that
* the value will be updated after a brief timeout where no slider motion
* occurs, so updates are spaced by a short time rather than
* continuous. #GTK_UPDATE_DISCONTINUOUS means that the value will only
* be updated when the user releases the button and ends the slider
* drag operation.
*
**/
void
gtk_range_set_update_policy (GtkRange *range,
GtkUpdateType policy)
@ -379,6 +415,20 @@ gtk_range_set_update_policy (GtkRange *range,
}
}
/**
* gtk_range_set_adjustment:
* @range: a #GtkRange
* @adjustment: a #GtkAdjustment
*
* Sets the adjustment to be used as the "model" object for this range
* widget. The adjustment indicates the current range value, the
* minimum and maximum range values, the step/page increments used
* for keybindings and scrolling, and the page size. The page size
* is normally 0 for #GtkScale and nonzero for #GtkScrollbar, and
* indicates the size of the visible area of the widget being scrolled.
* The page size affects the size of the scrollbar slider.
*
**/
void
gtk_range_set_adjustment (GtkRange *range,
GtkAdjustment *adjustment)
@ -420,6 +470,17 @@ gtk_range_set_adjustment (GtkRange *range,
}
}
/**
* gtk_range_set_inverted:
* @range: a #GtkRange
* @setting: %TRUE to invert the range
*
* Ranges normally move from lower to higher values as the
* slider moves from top to bottom or left to right. Inverted
* ranges have higher values at the top or on the right rather than
* on the bottom or left.
*
**/
void
gtk_range_set_inverted (GtkRange *range,
gboolean setting)
@ -435,6 +496,14 @@ gtk_range_set_inverted (GtkRange *range,
}
}
/**
* gtk_range_get_inverted:
* @range: a #GtkRange
*
* Gets the value set by gtk_range_set_inverted().
*
* Return value: %TRUE if the range is inverted
**/
gboolean
gtk_range_get_inverted (GtkRange *range)
{
@ -443,6 +512,99 @@ gtk_range_get_inverted (GtkRange *range)
return range->inverted;
}
/**
* gtk_range_set_increments:
* @range: a #GtkRange
* @step: step size
* @page: page size
*
* Sets the step and page sizes for the range.
* The step size is used when the user clicks the #GtkScrollbar
* arrows or moves #GtkScale via arrow keys. The page size
* is used for example when moving via Page Up or Page Down keys.
*
**/
void
gtk_range_set_increments (GtkRange *range,
gdouble step,
gdouble page)
{
g_return_if_fail (GTK_IS_RANGE (range));
range->adjustment->step_increment = step;
range->adjustment->page_increment = page;
gtk_adjustment_changed (range->adjustment);
}
/**
* gtk_range_set_range:
* @range: a #GtkRange
* @min: minimum range value
* @max: maximum range value
*
* Sets the allowable values in the #GtkRange, and clamps the range
* value to be between min and max.
**/
void
gtk_range_set_range (GtkRange *range,
gdouble min,
gdouble max)
{
gdouble value;
g_return_if_fail (GTK_IS_RANGE (range));
g_return_if_fail (min < max);
range->adjustment->lower = min;
range->adjustment->upper = max;
value = CLAMP (range->adjustment->value,
range->adjustment->lower,
(range->adjustment->upper - range->adjustment->page_size));
gtk_adjustment_changed (range->adjustment);
}
/**
* gtk_range_set_value:
* @range: a #GtkRange
* @value: new value of the range
*
* Sets the current value of the range; if the value is outside the
* minimum or maximum range values, it will be clamped to fit inside
* them. The range emits the "value_changed" signal if the value
* changes.
*
**/
void
gtk_range_set_value (GtkRange *range,
gdouble value)
{
g_return_if_fail (GTK_IS_RANGE (range));
value = CLAMP (value, range->adjustment->lower,
(range->adjustment->upper - range->adjustment->page_size));
gtk_adjustment_set_value (range->adjustment, value);
}
/**
* gtk_range_get_value:
* @range: a #GtkRange
*
* Gets the current value of the range.
*
* Return value: current value of the range.
**/
gdouble
gtk_range_get_value (GtkRange *range)
{
g_return_val_if_fail (GTK_IS_RANGE (range), 0.0);
return range->adjustment->value;
}
static gboolean
should_invert (GtkRange *range)
{
@ -1184,6 +1346,8 @@ gtk_range_adjustment_value_changed (GtkAdjustment *adjustment,
* can input into the adjustment, not a filter that the GtkRange
* will enforce on the adjustment.
*/
g_signal_emit (G_OBJECT (range), signals[VALUE_CHANGED], 0);
}
static void

View File

@ -106,6 +106,8 @@ struct _GtkRangeClass
/* what detail to pass to GTK drawing functions */
gchar *slider_detail;
gchar *stepper_detail;
void (* value_changed) (GtkRange *range);
/* action signals for keybindings */
void (* move_slider) (GtkRange *range,
@ -119,16 +121,24 @@ struct _GtkRangeClass
GtkType gtk_range_get_type (void) G_GNUC_CONST;
void gtk_range_set_update_policy (GtkRange *range,
GtkUpdateType policy);
void gtk_range_set_update_policy (GtkRange *range,
GtkUpdateType policy);
void gtk_range_set_adjustment (GtkRange *range,
GtkAdjustment *adjustment);
GtkAdjustment* gtk_range_get_adjustment (GtkRange *range);
void gtk_range_set_inverted (GtkRange *range,
gboolean setting);
gboolean gtk_range_get_inverted (GtkRange *range);
void gtk_range_set_increments (GtkRange *range,
gdouble step,
gdouble page);
void gtk_range_set_range (GtkRange *range,
gdouble min,
gdouble max);
void gtk_range_set_value (GtkRange *range,
gdouble value);
gdouble gtk_range_get_value (GtkRange *range);
void gtk_range_set_adjustment (GtkRange *range,
GtkAdjustment *adjustment);
GtkAdjustment* gtk_range_get_adjustment (GtkRange *range);
void gtk_range_set_inverted (GtkRange *range,
gboolean setting);
gboolean gtk_range_get_inverted (GtkRange *range);
#ifdef __cplusplus
}

View File

@ -1685,22 +1685,33 @@ gtk_spin_button_set_range (GtkSpinButton *spin_button,
gdouble min,
gdouble max)
{
gdouble value;
g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
spin_button->adjustment->lower = min;
spin_button->adjustment->upper = max;
value = CLAMP (spin_button->adjustment->value,
spin_button->adjustment->lower,
(spin_button->adjustment->upper - spin_button->adjustment->page_size));
if (value != spin_button->adjustment->value)
gtk_spin_button_set_value (spin_button, value);
gtk_adjustment_changed (spin_button->adjustment);
}
/**
* gtk_spin_button_get_value_as_float:
* gtk_spin_button_get_value:
* @spin_button: a #GtkSpinButton
*
* Get the value @spin_button represented as a floating point number.
* Get the value in the @spin_button.
*
* Return value: the value of @spin_button
**/
gdouble
gtk_spin_button_get_value_as_float (GtkSpinButton *spin_button)
gtk_spin_button_get_value (GtkSpinButton *spin_button)
{
g_return_val_if_fail (GTK_IS_SPIN_BUTTON (spin_button), 0.0);

View File

@ -141,7 +141,7 @@ void gtk_spin_button_set_range (GtkSpinButton *spin_button,
gdouble min,
gdouble max);
gdouble gtk_spin_button_get_value_as_float (GtkSpinButton *spin_button);
gdouble gtk_spin_button_get_value (GtkSpinButton *spin_button);
gint gtk_spin_button_get_value_as_int (GtkSpinButton *spin_button);
@ -166,6 +166,9 @@ void gtk_spin_button_set_snap_to_ticks (GtkSpinButton *spin_button,
void gtk_spin_button_update (GtkSpinButton *spin_button);
#ifndef GTK_DISABLE_DEPRECATED
#define gtk_spin_button_get_value_as_float gtk_spin_button_get_value
#endif
#ifdef __cplusplus
}

View File

@ -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)

View File

@ -59,8 +59,12 @@ struct _GtkVScaleClass
};
GtkType gtk_vscale_get_type (void) G_GNUC_CONST;
GtkWidget* gtk_vscale_new (GtkAdjustment *adjustment);
GtkType gtk_vscale_get_type (void) G_GNUC_CONST;
GtkWidget* gtk_vscale_new (GtkAdjustment *adjustment);
GtkWidget* gtk_vscale_new_with_range (gdouble min,
gdouble max,
gdouble step);
#ifdef __cplusplus