LevelBarProtocol
public protocol LevelBarProtocol : OrientableProtocol, WidgetProtocol
GtkLevelBar
is a 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 [methodGtk.LevelBar.set_value
] to set the current value, and
[methodGtk.LevelBar.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
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 [methodGtk.LevelBar.set_min_value
] and
[methodGtk.LevelBar.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 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
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.
Accessibility
GtkLevelBar
uses the GTK_ACCESSIBLE_ROLE_METER
role.
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.
-
Untyped pointer to the underlying
GtkLevelBar
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
level_bar_ptr
Default implementationTyped 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)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) 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 transformationtransform_to
ValueTransformer
to use for backwards transformationReturn 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:
Extension methodvalue: ) 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
-
connect(signal:
Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
LevelBarSignalName
signalDeclaration
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 byuserData
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(signal:
Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
LevelBarSignalName
signalDeclaration
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 byuserData
signalHandler
The C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
onOffsetChanged(flags:
Extension methodhandler: ) Emitted when an offset specified on the bar changes value.
This typically is the result of a [method
Gtk.LevelBar.add_offset_value
] call.The signal supports detailed connections; you can connect to the detailed signal “changed
x
” in order to only receive callbacks when the value of offset “x” changes.Note
This represents the underlyingoffset-changed
signalDeclaration
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 methodTyped
offset-changed
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var offsetChangedSignal: LevelBarSignalName { get }
-
onNotifyInverted(flags:
Extension methodhandler: ) 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 tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_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 underlyingnotify::inverted
signalDeclaration
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 methodTyped
notify::inverted
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyInvertedSignal: LevelBarSignalName { get }
-
onNotifyMaxValue(flags:
Extension methodhandler: ) 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 tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_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 underlyingnotify::max-value
signalDeclaration
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 methodTyped
notify::max-value
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyMaxValueSignal: LevelBarSignalName { get }
-
onNotifyMinValue(flags:
Extension methodhandler: ) 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 tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_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 underlyingnotify::min-value
signalDeclaration
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 methodTyped
notify::min-value
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyMinValueSignal: LevelBarSignalName { get }
-
onNotifyMode(flags:
Extension methodhandler: ) 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 tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_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 underlyingnotify::mode
signalDeclaration
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 methodTyped
notify::mode
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyModeSignal: LevelBarSignalName { get }
-
onNotifyValue(flags:
Extension methodhandler: ) 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 tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_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 underlyingnotify::value
signalDeclaration
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 methodTyped
notify::value
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyValueSignal: LevelBarSignalName { get }
-
addOffsetValue(name:
Extension methodvalue: ) Adds a new offset marker on
self
at the position specified byvalue
.When the bar value is in the interval topped by
value
(or betweenvalue
and [propertyGtk.LevelBar:max-value
] in case the offset is the last one on the bar) a style class namedlevel-
name
will be applied when rendering the level bar fill.If another offset marker named
name
exists, its value will be replaced byvalue
.Declaration
Swift
@inlinable func addOffsetValue(name: UnsafePointer<CChar>!, value: CDouble)
-
getInverted()
Extension methodReturns whether the levelbar is inverted.
Declaration
Swift
@inlinable func getInverted() -> Bool
-
getMaxValue()
Extension methodReturns the
max-value
of theGtkLevelBar
.Declaration
Swift
@inlinable func getMaxValue() -> CDouble
-
getMinValue()
Extension methodReturns the
min-value of the
GtkLevelBar`.Declaration
Swift
@inlinable func getMinValue() -> CDouble
-
getMode()
Extension methodReturns the
mode
of theGtkLevelBar
.Declaration
Swift
@inlinable func getMode() -> GtkLevelBarMode
-
getOffsetValue(name:
Extension methodvalue: ) Fetches the value specified for the offset marker
name
inself
.Declaration
Swift
@inlinable func getOffsetValue(name: UnsafePointer<CChar>? = nil, value: UnsafeMutablePointer<CDouble>!) -> Bool
-
getValue()
Extension methodReturns the
value
of theGtkLevelBar
.Declaration
Swift
@inlinable func getValue() -> CDouble
-
removeOffsetValue(name:
Extension method) Removes an offset marker from a
GtkLevelBar
.The marker must have been previously added with [method
Gtk.LevelBar.add_offset_value
].Declaration
Swift
@inlinable func removeOffsetValue(name: UnsafePointer<CChar>? = nil)
-
set(inverted:
Extension method) Sets whether the
GtkLevelBar
is inverted.Declaration
Swift
@inlinable func set(inverted: Bool)
-
setMax(value:
Extension method) Sets the
max-value
of theGtkLevelBar
.You probably want to update preexisting level offsets after calling this function.
Declaration
Swift
@inlinable func setMax(value: CDouble)
-
setMin(value:
Extension method) Sets the
min-value
of theGtkLevelBar
.You probably want to update preexisting level offsets after calling this function.
Declaration
Swift
@inlinable func setMin(value: CDouble)
-
set(mode:
Extension method) Sets the
mode
of theGtkLevelBar
.Declaration
Swift
@inlinable func set(mode: GtkLevelBarMode)
-
set(value:
Extension method) Sets the value of the
GtkLevelBar
.Declaration
Swift
@inlinable func set(value: CDouble)
-
inverted
Extension methodWhether the
GtkLeveBar
is inverted.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 methodReturns the
max-value
of theGtkLevelBar
.Declaration
Swift
@inlinable var maxValue: CDouble { get nonmutating set }
-
minValue
Extension methodReturns the
min-value of the
GtkLevelBar`.Declaration
Swift
@inlinable var minValue: CDouble { get nonmutating set }
-
mode
Extension methodDetermines 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 isGTK_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 [propertyGtk.LevelBar:min-value
] and [propertyGtk.LevelBar:max-value
].Declaration
Swift
@inlinable var mode: GtkLevelBarMode { get nonmutating set }
-
value
Extension methodDetermines the currently filled value of the level bar.
Declaration
Swift
@inlinable var value: CDouble { get nonmutating set }