Package: gtk

Class gtk:level-bar

Superclasses

Documented Subclasses

None

Direct Slots

inverted
The inverted property of type :boolean (Read / Write)
Level bars normally grow from top to bottom or left to right. Inverted level bars grow in the opposite direction.
Default value: false
max-value
The max-value property of type :double (Read / Write)
The property determines the maximum value of the interval that can be displayed by the level bar.
Allowed values: >= 0.0d0
Default value: 1.0d0
min-value
The min-value property of type :double (Read / Write)
The property determines the minimum value of the interval that can be displayed by the level bar.
Allowed values: >= 0.0d0
Default value: 0.0d0
mode
The mode property of type gtk:level-bar-mode (Read / Write)
The property determines the way a level bar interprets the value properties to draw the level fill area. Specifically, when the value is :continuous, the level bar will draw a single block representing the current value in that area. When the value is :discrete, the widget will draw a succession of separate blocks filling the draw area, with the number of blocks being equal to the units separating the integral roundings of the min-value and max-value values.
Default value: :continuous
value
The value property of type :double (Read / Write)
The property determines the currently filled value of the level bar.
Allowed values: >= 0.0d0
Default value: 0.0d0

Details

The gtk:level-bar widget is a level bar widget that can be used as a level indicator. Typical use cases are displaying the strength of a password, or showing the charge level of a battery.

Figure: GtkLevelBar

Use the gtk:level-bar-value function to set the current value, and the gtk:level-bar-add-offset-value function to set the value offsets at which the level bar will be considered in a different state. GTK will add a few offsets by default on the level bar: "low", "high" and "full", with values 0.25, 0.75 and 1.0 respectively.

Note that it is your responsibility to update preexisting offsets when changing the minimum or maximum value. GTK will simply clamp them to the new range.

Adding a custom offset on the bar
The default interval of values is between zero and one, but it is possible to modify the interval using the gtk:level-bar-min-value and gtk:level-bar-max-value functions. The value will be always drawn in proportion to the admissible interval, that is, a value of 15 with a specified interval between 10 and 20 is equivalent to a value of 0.5 with an interval between 0 and 1. When the :discrete level bar mode is used, the level bar is rendered as a finite number of separated blocks instead of a single one. The number of blocks that will be rendered is equal to the number of units specified by the admissible interval.

For instance, to build a lever bar rendered with five blocks, it is sufficient to set the minimum value to 0 and the maximum value to 5 after changing the indicator mode to discrete.

GtkLevelBar as GtkBuildable

The gtk:level-bar implementation of the gtk:buildable interface supports a custom <offsets> element, which can contain any number of <offset> elements, each of which must have name and value attributes.

CSS nodes

levelbar[.discrete]
╰── trough
    ├── block.filled.level-name
    ┊
    ├── block.empty
    ┊    
The gtk:level-bar implementation has a main CSS node with name levelbar and one of the .discrete or .continuous style classes and a subnode with name trough. Below the trough node are a number of nodes with name block and .filled or .empty style class. In continuous mode, there is exactly one node of each, in discrete mode, the number of filled and unfilled nodes corresponds to blocks that are drawn. The block.filled nodes also get a .level-name style class corresponding to the level for the current value.

In horizontal orientation, the nodes are always arranged from left to right, regardless of text direction.

Examples

Adding a custom offset on the bar.
(defun create-level-bar (orientation)
  (let* ((levelbar (make-instance 'gtk:level-bar
                                  :orientation orientation)))
    ;; This changes the value of the default low offset
    (gtk:level-bar-add-offset-value levelbar "low" 0.10d0)
    ;; This adds a new offset to the bar. The application will
    ;; be able to change its color CSS like this:
    ;;
    ;; levelbar block.my-offset {
    ;;   background-color: magenta;
    ;;   border-style: solid;
    ;;   border-color: black;
    ;;   border-style: 1px;
    ;; }
    (gtk:level-bar-add-offset-value levelbar "my-offset" 0.60d0)
    ;; Return the new level bar
    levelbar))    

Accessibility

The gtk:level-bar implementation uses the :meter role of the gtk:accessible-role enumeration

Signal Details

The "offset-changed" signal
lambda (levelbar name)    :detailed      
levelbar
The gtk:level-bar widget which received the signal.
name
The string with the name of the offset that changed value.
Emitted when an offset specified on the level bar changes value as an effect to the gtk:level-bar-add-offset-value function being called. The signal supports detailed connections. You can connect to the "changed::x" detailed signal in order to only receive callbacks when the value of "x" offset changes.
 

Returned by

Slot Access Functions

Inherited Slot Access Functions

See also

2024-10-31