Package: gtk

Class gtk-level-bar

Superclasses

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

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 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 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 gtk-level-bar widget interprets the value properties to draw the level fill area. Specifically, when the value is :continuous, the gtk-level-bar widget 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 min-value and max-value.
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 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.



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

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, i.e. 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 bar level 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 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.

Example

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

Style Property Details

min-block-height
The min-block-height style property of type :int (Read / Write)
The style property determines the minimum height for blocks filling the gtk-level-bar widget.
Warning: The min-block-height style property has been deprecated since version 3.20 and should not be used in newly written code. Use the standard min-width/min-height CSS properties on the block elements. The value of this style property is ignored.
Allowed values: >= 1
Default value: 3
min-block-width
The min-block-width style property of type :int (Read / Write)
The style property determines the minimum width for blocks filling the gtk-level-bar widget.
Warning: The min-block-height style property has been deprecated since version 3.20 and should not be used in newly written code. Use the standard min-width/min-height CSS properties on the block elements. The value of this style property is ignored.
Allowed values: >= 1
Default value: 3

Signal Details

The "offset-changed" signal
 lambda (levelbar name)    :detailed      
Emitted when an offset specified on the 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.
levelbar
The gtk-level-bar widget which received the signal.
name
A string with the name of the offset that changed value.
 

Slot Access Functions

Inherited Slot Access Functions

See also

*2021-12-22