Next: , Previous: GtkRange, Up: Top


135 GtkScale

Base class for GtkHScale and GtkVScale

135.1 Overview

A <gtk-scale> 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, <gtk-range>, in addition to the methods for <gtk-scale> 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.

The <gtk-scale> widget is an abstract class, used only for deriving the subclasses <gtk-hscale> and <gtk-vscale>. To create a scale widget, call gtk-hscale-new-with-range or gtk-vscale-new-with-range.

135.2 Usage

— Class: <gtk-scale>

Derives from <gtk-range>.

This class defines the following slots:

digits
The number of decimal places that are displayed in the value
draw-value
Whether the current value is displayed as a string next to the slider
value-pos
The position in which the current value is displayed
— Signal on <gtk-scale>: format-value (arg0 <gdouble>) ⇒ <gchararray>

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<–".

          
          static gchar*
          format_value_callback (GtkScale *scale,
                                 gdouble   value)
          {
            return g_strdup_printf ("-->%0.*g<--",
                                    gtk_scale_get_digits (scale), value);
          }
— Function: gtk-scale-set-digits (self <gtk-scale>) (digits int)
— Method: set-digits

Sets the number of decimal places that are displayed in the value. Also causes the value of the adjustment to be rounded off to this number of digits, so the retrieved value matches the value the user saw.

scale
a <gtk-scale>.
digits
the number of decimal places to display, e.g. use 1 to display 1.0, 2 to display 1.00 etc.
— Function: gtk-scale-set-draw-value (self <gtk-scale>) (draw_value bool)
— Method: set-draw-value

Specifies whether the current value is displayed as a string next to the slider.

scale
a <gtk-scale>.
draw-value
a boolean.
— Function: gtk-scale-set-value-pos (self <gtk-scale>) (pos <gtk-position-type>)
— Method: set-value-pos

Sets the position in which the current value is displayed.

scale
a <gtk-scale>.
pos
the position in which the current value is displayed.
— Function: gtk-scale-get-digits (self <gtk-scale>) ⇒  (ret int)
— Method: get-digits

Gets the number of decimal places that are displayed in the value.

scale
a <gtk-scale>.
ret
the number of decimal places that are displayed.
— Function: gtk-scale-get-draw-value (self <gtk-scale>) ⇒  (ret bool)
— Method: get-draw-value

Returns whether the current value is displayed as a string next to the slider.

scale
a <gtk-scale>.
ret
whether the current value is displayed as a string.
— Function: gtk-scale-get-value-pos (self <gtk-scale>) ⇒  (ret <gtk-position-type>)
— Method: get-value-pos

Gets the position in which the current value is displayed.

scale
a <gtk-scale>.
ret
the position in which the current value is displayed.
— Function: gtk-scale-get-layout (self <gtk-scale>) ⇒  (ret <pango-layout>)
— Method: get-layout

Gets the <pango-layout> used to display the scale. The returned object is owned by the scale so does not need to be freed by the caller.

scale
A <gtk-scale>
ret
the <pango-layout> for this scale, or ‘#f’ if the draw_value property is ‘#f’.

Since 2.4

— Function: gtk-scale-get-layout-offsets (self <gtk-scale>) ⇒  (int) (int)
— Method: get-layout-offsets

Obtains the coordinates where the scale will draw the <pango-layout> representing the text in the scale. Remember when using the <pango-layout> function you need to convert to and from pixels using pango-pixels or <pango-scale>.

If the draw_value property is ‘#f’, the return values are undefined.

scale
a <gtk-scale>
x
location to store X offset of layout, or ‘#f
y
location to store Y offset of layout, or ‘#f

Since 2.4