Package: gtk

Class gtk-scale

Superclasses

gtk-range, gtk-widget, gtk-buildable, gtk-orientable, g-object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

None

Direct Slots

digits
The digits property of type :int (Read / Write)
The number of decimal places that are displayed in the value.
Allowed values: [-1, 64]
Default value: 1
draw-value
The draw-value property of type :boolean (Read / Write)
Whether the current value is displayed as a string next to the slider.
Default value: true
has-origin
The has-origin property of type :boolean (Read / Write)
Whether the scale has an origin.
Default value: true
value-pos
The value-pos property of type gtk-position-type (Read / Write)
The position in which the current value is displayed.
Default value: :top

Details

A gtk-scale widget is a slider control used to select a numeric value. To use it, you will probably want to investigate the methods on its base gtk-range class, in addition to the methods for the gtk-scale class itself. To set the value of a scale, you would normally use the gtk-range-value function. To detect changes to the value, you would normally use the "value-changed" signal.



Note that using the same upper and lower bounds for the gtk-scale widget, through the gtk-range methods, will hide the slider itself. This is useful for applications that want to show an undeterminate value on the scale, without changing the layout of the application, such as movie or music players.

GtkScale as GtkBuildable

The gtk-scale widget supports a custom <marks> element, which can contain multiple <mark> elements. The "value" and "position" attributes have the same meaning as the parameters of the gtk-scale-add-mark function of the same name. If the element is not empty, its content is taken as the markup to show at the mark. It can be translated with the usual "translatable" and "context" attributes.

CSS nodes

 scale[.fine-tune][.marks-before][.marks-after]
 ├── marks.top
 │   ├── mark
 │   ┊    ├── [label]
 │   ┊    ╰── indicator
 ┊   ┊
 │   ╰── mark
 ├── [value]
 ├── contents
 │   ╰── trough
 │       ├── slider
 │       ├── [highlight]
 │       ╰── [fill]
 ╰── marks.bottom
     ├── mark
     ┊    ├── indicator
     ┊    ╰── [label]
     ╰── mark    
The gtk-scale implementation has a main CSS node with name scale and a subnode for its contents, with subnodes named trough and slider. The main node gets the .fine-tune style class added when the scale is in 'fine-tuning' mode.

If the scale has an origin, see the gtk-scale-has-origin function, there is a subnode with name highlight below the trough node that is used for rendering the highlighted part of the trough.

If the scale is showing a fill level, see the gtk-range-show-fill-level function, there is a subnode with name fill below the trough node that is used for rendering the filled in part of the trough.

If marks are present, there is a marks subnode before or after the contents node, below which each mark gets a node with name mark. The marks nodes get either the .top or .bottom style class.

The mark node has a subnode named indicator. If the mark has text, it also has a subnode named label. When the mark is either above or left of the scale, the label subnode is the first when present. Otherwise, the indicator subnode is the first.

The main CSS node gets the marks-before and/or marks-after style classes added depending on what marks are present.

If the scale is displaying the value, see the draw-value property, there is subnode with name value.

Style Property Details

slider-length
The slider-length style property of type :int (Read)
Length of the slider of the scale.
Warning: The slider-length style property has been deprecated since version 3.20 and should not be used in newly written code. Use min-height/min-width CSS properties on the slider element instead. The value of this style property is ignored.
Allowed values: >= 0
Default value: 31
value-spacing
The value-spacing style property of type :int (Read)
Space between value text and the slider/trough area.
Warning: The value-spacing style property has been deprecated since version 3.20 and should not be used in newly written code. Use min-height/min-width CSS properties on the value element instead. The value of this style property is ignored.
Allowed values: >= 0
Default value: 2

Signal Details

The "format-value" signal
 lambda (scale value)    :run-last      
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. If no user provided handlers are installed, the value will be displayed on its own, rounded according to the value of the digits property. Here is 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);
}      
scale
The gtk-scale widget which received the signal.
value
A double float with the value to format.
Returns
String representing the value.
 

Slot Access Functions

Inherited Slot Access Functions

See also

*2021-12-27