LevelBarProtocol

public protocol LevelBarProtocol : OrientableProtocol, WidgetProtocol

The GtkLevelBar 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 gtk_level_bar_set_value() to set the current value, and gtk_level_bar_add_offset_value() 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: GTK_LEVEL_BAR_OFFSET_LOW, GTK_LEVEL_BAR_OFFSET_HIGH and GTK_LEVEL_BAR_OFFSET_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

(C Language Example):


static GtkWidget *
create_level_bar (void)
{
  GtkWidget *widget;
  GtkLevelBar *bar;

  widget = gtk_level_bar_new ();
  bar = GTK_LEVEL_BAR (widget);

  // This changes the value of the default low offset

  gtk_level_bar_add_offset_value (bar,
                                  GTK_LEVEL_BAR_OFFSET_LOW,
                                  0.10);

  // 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 (bar, "my-offset", 0.60);

  return widget;
}

The default interval of values is between zero and one, but it’s possible to modify the interval using gtk_level_bar_set_min_value() and gtk_level_bar_set_max_value(). 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 GTK_LEVEL_BAR_MODE_DISCRETE 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’s sufficient to set the minimum value to 0 and the maximum value to 5 after changing the indicator mode to discrete.

GtkLevelBar was introduced in GTK+ 3.6.

GtkLevelBar as GtkBuildable

The GtkLevelBar implementation of the GtkBuildable 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

(plain Language Example):

levelbar[.discrete]
╰── trough
    ├── block.filled.level-name
    ┊
    ├── block.empty
    ┊

GtkLevelBar has a main CSS node with name levelbar and one of the style classes .discrete or .continuous and a subnode with name trough. Below the trough node are a number of nodes with name block and style class .filled or .empty. 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 style class .level-name corresponding to the level for the current value.

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

The LevelBarProtocol protocol exposes the methods and properties of an underlying GtkLevelBar instance. The default implementation of these can be found in the protocol extension below. For a concrete class that implements these methods and properties, see LevelBar. Alternatively, use LevelBarRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying GtkLevelBar instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • level_bar_ptr Default implementation

    Typed pointer to the underlying GtkLevelBar instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GtkLevelBar instance.

    Declaration

    Swift

    var level_bar_ptr: UnsafeMutablePointer<GtkLevelBar>! { get }
  • Required Initialiser for types conforming to LevelBarProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

LevelBar Class

  • Bind a LevelBarPropertyName source property to a given target object.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: LevelBarPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol

    Parameters

    source_property

    the source property to bind

    target

    the target object to bind to

    target_property

    the target property to bind to

    flags

    the flags to pass to the Binding

    transform_from

    ValueTransformer to use for forward transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return Value

    binding reference or nil in case of an error

  • get(property:) Extension method

    Get the value of a LevelBar property

    Declaration

    Swift

    @inlinable
    func get(property: LevelBarPropertyName) -> GLibObject.Value

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

  • set(property:value:) Extension method

    Set the value of a LevelBar property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

    @inlinable
    func set(property: LevelBarPropertyName, value v: GLibObject.Value)

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

LevelBar signals

  • Connect a Swift signal handler to the given, typed LevelBarSignalName signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func connect(signal s: LevelBarSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int

    Parameters

    signal

    The signal to connect

    flags

    The connection flags to use

    data

    A pointer to user data to provide to the callback

    destroyData

    A GClosureNotify C function to destroy the data pointed to by userData

    handler

    The Swift signal handler (function or callback) to invoke on the given signal

    Return Value

    The signal handler ID (always greater than 0 for successful connections)

  • Connect a C signal handler to the given, typed LevelBarSignalName signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func connect(signal s: LevelBarSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int

    Parameters

    signal

    The signal to connect

    flags

    The connection flags to use

    data

    A pointer to user data to provide to the callback

    destroyData

    A GClosureNotify C function to destroy the data pointed to by userData

    signalHandler

    The C function to be called on the given signal

    Return Value

    The signal handler ID (always greater than 0 for successful connections)

  • Emitted when an offset specified on the bar changes value as an effect to gtk_level_bar_add_offset_value() being called.

    The signal supports detailed connections; you can connect to the detailed signal “changedx” in order to only receive callbacks when the value of offset “x” changes.

    Note

    This represents the underlying offset-changed signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onOffsetChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: LevelBarRef, _ name: String) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    name

    the name of the offset that changed value

    handler

    The signal handler to call Run the given callback whenever the offsetChanged signal is emitted

  • offsetChangedSignal Extension method

    Typed offset-changed signal for using the connect(signal:) methods

    Declaration

    Swift

    static var offsetChangedSignal: LevelBarSignalName { get }
  • The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

    (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::inverted signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyInverted(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: LevelBarRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifyInverted signal is emitted

  • notifyInvertedSignal Extension method

    Typed notify::inverted signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyInvertedSignal: LevelBarSignalName { get }
  • The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

    (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::max-value signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyMaxValue(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: LevelBarRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifyMaxValue signal is emitted

  • notifyMaxValueSignal Extension method

    Typed notify::max-value signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyMaxValueSignal: LevelBarSignalName { get }
  • The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

    (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::min-value signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyMinValue(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: LevelBarRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifyMinValue signal is emitted

  • notifyMinValueSignal Extension method

    Typed notify::min-value signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyMinValueSignal: LevelBarSignalName { get }
  • onNotifyMode(flags:handler:) Extension method

    The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

    (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::mode signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyMode(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: LevelBarRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifyMode signal is emitted

  • notifyModeSignal Extension method

    Typed notify::mode signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyModeSignal: LevelBarSignalName { get }
  • The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

    (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::value signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyValue(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: LevelBarRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifyValue signal is emitted

  • notifyValueSignal Extension method

    Typed notify::value signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyValueSignal: LevelBarSignalName { get }

LevelBar Class: LevelBarProtocol extension (methods and fields)

  • addOffsetValue(name:value:) Extension method

    Adds a new offset marker on self at the position specified by value. When the bar value is in the interval topped by value (or between value and GtkLevelBar:max-value in case the offset is the last one on the bar) a style class named level-name will be applied when rendering the level bar fill. If another offset marker named name exists, its value will be replaced by value.

    Declaration

    Swift

    @inlinable
    func addOffsetValue(name: UnsafePointer<gchar>!, value: Double)
  • getInverted() Extension method

    Return the value of the GtkLevelBar:inverted property.

    Declaration

    Swift

    @inlinable
    func getInverted() -> Bool
  • getMaxValue() Extension method

    Returns the value of the GtkLevelBar:max-value property.

    Declaration

    Swift

    @inlinable
    func getMaxValue() -> Double
  • getMinValue() Extension method

    Returns the value of the GtkLevelBar:min-value property.

    Declaration

    Swift

    @inlinable
    func getMinValue() -> Double
  • getMode() Extension method

    Returns the value of the GtkLevelBar:mode property.

    Declaration

    Swift

    @inlinable
    func getMode() -> GtkLevelBarMode
  • getOffsetValue(name:value:) Extension method

    Fetches the value specified for the offset marker name in self, returning true in case an offset named name was found.

    Declaration

    Swift

    @inlinable
    func getOffsetValue(name: UnsafePointer<gchar>? = nil, value: UnsafeMutablePointer<gdouble>!) -> Bool
  • getValue() Extension method

    Returns the value of the GtkLevelBar:value property.

    Declaration

    Swift

    @inlinable
    func getValue() -> Double
  • removeOffsetValue(name:) Extension method

    Removes an offset marker previously added with gtk_level_bar_add_offset_value().

    Declaration

    Swift

    @inlinable
    func removeOffsetValue(name: UnsafePointer<gchar>? = nil)
  • set(inverted:) Extension method

    Sets the value of the GtkLevelBar:inverted property.

    Declaration

    Swift

    @inlinable
    func set(inverted: Bool)
  • setMax(value:) Extension method

    Sets the value of the GtkLevelBar:max-value property.

    You probably want to update preexisting level offsets after calling this function.

    Declaration

    Swift

    @inlinable
    func setMax(value: Double)
  • setMin(value:) Extension method

    Sets the value of the GtkLevelBar:min-value property.

    You probably want to update preexisting level offsets after calling this function.

    Declaration

    Swift

    @inlinable
    func setMin(value: Double)
  • set(mode:) Extension method

    Sets the value of the GtkLevelBar:mode property.

    Declaration

    Swift

    @inlinable
    func set(mode: GtkLevelBarMode)
  • set(value:) Extension method

    Sets the value of the GtkLevelBar:value property.

    Declaration

    Swift

    @inlinable
    func set(value: Double)
  • inverted Extension method

    Level bars normally grow from top to bottom or left to right. Inverted level bars grow in the opposite direction.

    Declaration

    Swift

    @inlinable
    var inverted: Bool { get nonmutating set }
  • maxValue Extension method

    Returns the value of the GtkLevelBar:max-value property.

    Declaration

    Swift

    @inlinable
    var maxValue: Double { get nonmutating set }
  • minValue Extension method

    Returns the value of the GtkLevelBar:min-value property.

    Declaration

    Swift

    @inlinable
    var minValue: Double { get nonmutating set }
  • mode Extension method

    The GtkLevelBar:mode property determines the way GtkLevelBar interprets the value properties to draw the level fill area. Specifically, when the value is GTK_LEVEL_BAR_MODE_CONTINUOUS, GtkLevelBar will draw a single block representing the current value in that area; when the value is GTK_LEVEL_BAR_MODE_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 GtkLevelBar:min-value and GtkLevelBar:max-value.

    Declaration

    Swift

    @inlinable
    var mode: GtkLevelBarMode { get nonmutating set }
  • value Extension method

    The GtkLevelBar:value property determines the currently filled value of the level bar.

    Declaration

    Swift

    @inlinable
    var value: Double { get nonmutating set }