Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
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 levelBarSetValue
to set the current value, and
levelBarAddOffsetValue
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: LEVEL_BAR_OFFSET_LOW
,
LEVEL_BAR_OFFSET_HIGH
and 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 code
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-width: 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 levelBarSetMinValue
and
levelBarSetMaxValue
. 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 LevelBarModeDiscrete
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 AccessibleRoleMeter
role.
Synopsis
- newtype LevelBar = LevelBar (ManagedPtr LevelBar)
- class (GObject o, IsDescendantOf LevelBar o) => IsLevelBar o
- toLevelBar :: (MonadIO m, IsLevelBar o) => o -> m LevelBar
- levelBarAddOffsetValue :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> Text -> Double -> m ()
- levelBarGetInverted :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> m Bool
- levelBarGetMaxValue :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> m Double
- levelBarGetMinValue :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> m Double
- levelBarGetMode :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> m LevelBarMode
- levelBarGetOffsetValue :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> Maybe Text -> m (Bool, Double)
- levelBarGetValue :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> m Double
- levelBarNew :: (HasCallStack, MonadIO m) => m LevelBar
- levelBarNewForInterval :: (HasCallStack, MonadIO m) => Double -> Double -> m LevelBar
- levelBarRemoveOffsetValue :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> Maybe Text -> m ()
- levelBarSetInverted :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> Bool -> m ()
- levelBarSetMaxValue :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> Double -> m ()
- levelBarSetMinValue :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> Double -> m ()
- levelBarSetMode :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> LevelBarMode -> m ()
- levelBarSetValue :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> Double -> m ()
- constructLevelBarInverted :: (IsLevelBar o, MonadIO m) => Bool -> m (GValueConstruct o)
- getLevelBarInverted :: (MonadIO m, IsLevelBar o) => o -> m Bool
- setLevelBarInverted :: (MonadIO m, IsLevelBar o) => o -> Bool -> m ()
- constructLevelBarMaxValue :: (IsLevelBar o, MonadIO m) => Double -> m (GValueConstruct o)
- getLevelBarMaxValue :: (MonadIO m, IsLevelBar o) => o -> m Double
- setLevelBarMaxValue :: (MonadIO m, IsLevelBar o) => o -> Double -> m ()
- constructLevelBarMinValue :: (IsLevelBar o, MonadIO m) => Double -> m (GValueConstruct o)
- getLevelBarMinValue :: (MonadIO m, IsLevelBar o) => o -> m Double
- setLevelBarMinValue :: (MonadIO m, IsLevelBar o) => o -> Double -> m ()
- constructLevelBarMode :: (IsLevelBar o, MonadIO m) => LevelBarMode -> m (GValueConstruct o)
- getLevelBarMode :: (MonadIO m, IsLevelBar o) => o -> m LevelBarMode
- setLevelBarMode :: (MonadIO m, IsLevelBar o) => o -> LevelBarMode -> m ()
- constructLevelBarValue :: (IsLevelBar o, MonadIO m) => Double -> m (GValueConstruct o)
- getLevelBarValue :: (MonadIO m, IsLevelBar o) => o -> m Double
- setLevelBarValue :: (MonadIO m, IsLevelBar o) => o -> Double -> m ()
- type LevelBarOffsetChangedCallback = Text -> IO ()
- afterLevelBarOffsetChanged :: (IsLevelBar a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => LevelBarOffsetChangedCallback) -> m SignalHandlerId
- onLevelBarOffsetChanged :: (IsLevelBar a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => LevelBarOffsetChangedCallback) -> m SignalHandlerId
Exported types
Memory-managed wrapper type.
Instances
Eq LevelBar Source # | |
GObject LevelBar Source # | |
Defined in GI.Gtk.Objects.LevelBar | |
ManagedPtrNewtype LevelBar Source # | |
Defined in GI.Gtk.Objects.LevelBar toManagedPtr :: LevelBar -> ManagedPtr LevelBar # | |
TypedObject LevelBar Source # | |
Defined in GI.Gtk.Objects.LevelBar | |
HasParentTypes LevelBar Source # | |
Defined in GI.Gtk.Objects.LevelBar | |
IsGValue (Maybe LevelBar) Source # | Convert |
Defined in GI.Gtk.Objects.LevelBar | |
type ParentTypes LevelBar Source # | |
Defined in GI.Gtk.Objects.LevelBar type ParentTypes LevelBar = '[Widget, Object, Accessible, AccessibleRange, Buildable, ConstraintTarget, Orientable] |
class (GObject o, IsDescendantOf LevelBar o) => IsLevelBar o Source #
Type class for types which can be safely cast to LevelBar
, for instance with toLevelBar
.
Instances
(GObject o, IsDescendantOf LevelBar o) => IsLevelBar o Source # | |
Defined in GI.Gtk.Objects.LevelBar |
toLevelBar :: (MonadIO m, IsLevelBar o) => o -> m LevelBar Source #
Methods
Click to display all available methods, including inherited ones
Methods
actionSetEnabled, activate, activateAction, activateDefault, addController, addCssClass, addMnemonicLabel, addOffsetValue, addTickCallback, allocate, announce, bindProperty, bindPropertyFull, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, forceFloating, freezeNotify, getv, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFloating, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, notify, notifyByPspec, observeChildren, observeControllers, pick, queueAllocate, queueDraw, queueResize, realize, ref, refSink, removeController, removeCssClass, removeMnemonicLabel, removeOffsetValue, removeTickCallback, resetProperty, resetRelation, resetState, runDispose, shouldLayout, show, sizeAllocate, snapshotChild, stealData, stealQdata, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unsetStateFlags, updateNextAccessibleSibling, updateProperty, updateRelation, updateState, watchClosure.
Getters
getAccessibleParent, getAccessibleRole, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getAtContext, getBaseline, getBounds, getBuildableId, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getData, getDirection, getDisplay, getFirstAccessibleChild, getFirstChild, getFocusChild, getFocusOnClick, getFocusable, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getInverted, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getMaxValue, getMinValue, getMode, getName, getNative, getNextAccessibleSibling, getNextSibling, getOffsetValue, getOpacity, getOrientation, getOverflow, getPangoContext, getParent, getPlatformState, getPreferredSize, getPrevSibling, getPrimaryClipboard, getProperty, getQdata, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getValue, getVexpand, getVexpandSet, getVisible, getWidth.
Setters
setAccessibleParent, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setData, setDataFull, setDirection, setFocusChild, setFocusOnClick, setFocusable, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setInverted, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setMaxValue, setMinValue, setMode, setName, setOpacity, setOrientation, setOverflow, setParent, setProperty, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setValue, setVexpand, setVexpandSet, setVisible.
addOffsetValue
levelBarAddOffsetValue Source #
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> Text |
|
-> Double |
|
-> m () |
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 LevelBar:maxValue 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
.
getInverted
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> m Bool | Returns: |
Returns whether the levelbar is inverted.
getMaxValue
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> m Double | Returns: a positive value |
Returns the max-value
of the GtkLevelBar
.
getMinValue
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> m Double | Returns: a positive value |
Returns the min-value
of the GtkLevelBar
.
getMode
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> m LevelBarMode | Returns: a |
Returns the mode
of the GtkLevelBar
.
getOffsetValue
levelBarGetOffsetValue Source #
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> Maybe Text |
|
-> m (Bool, Double) | Returns: |
Fetches the value specified for the offset marker name
in self
.
getValue
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> m Double | Returns: a value in the interval between LevelBar:minValue and LevelBar:maxValue |
Returns the value
of the GtkLevelBar
.
new
:: (HasCallStack, MonadIO m) | |
=> m LevelBar | Returns: a |
Creates a new GtkLevelBar
.
newForInterval
levelBarNewForInterval Source #
:: (HasCallStack, MonadIO m) | |
=> Double |
|
-> Double |
|
-> m LevelBar | Returns: a |
Creates a new GtkLevelBar
for the specified interval.
removeOffsetValue
levelBarRemoveOffsetValue Source #
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> Maybe Text |
|
-> m () |
Removes an offset marker from a GtkLevelBar
.
The marker must have been previously added with
levelBarAddOffsetValue
.
setInverted
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> Bool |
|
-> m () |
Sets whether the GtkLevelBar
is inverted.
setMaxValue
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> Double |
|
-> m () |
Sets the max-value
of the GtkLevelBar
.
You probably want to update preexisting level offsets after calling this function.
setMinValue
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> Double |
|
-> m () |
Sets the min-value
of the GtkLevelBar
.
You probably want to update preexisting level offsets after calling this function.
setMode
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> LevelBarMode |
|
-> m () |
Sets the mode
of the GtkLevelBar
.
setValue
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> Double |
|
-> m () |
Sets the value of the GtkLevelBar
.
Properties
inverted
Whether the GtkLeveBar
is inverted.
Level bars normally grow from top to bottom or left to right. Inverted level bars grow in the opposite direction.
constructLevelBarInverted :: (IsLevelBar o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “inverted
” property. This is rarely needed directly, but it is used by new
.
getLevelBarInverted :: (MonadIO m, IsLevelBar o) => o -> m Bool Source #
Get the value of the “inverted
” property.
When overloading is enabled, this is equivalent to
get
levelBar #inverted
setLevelBarInverted :: (MonadIO m, IsLevelBar o) => o -> Bool -> m () Source #
Set the value of the “inverted
” property.
When overloading is enabled, this is equivalent to
set
levelBar [ #inverted:=
value ]
maxValue
Determines the maximum value of the interval that can be displayed by the bar.
constructLevelBarMaxValue :: (IsLevelBar o, MonadIO m) => Double -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “max-value
” property. This is rarely needed directly, but it is used by new
.
getLevelBarMaxValue :: (MonadIO m, IsLevelBar o) => o -> m Double Source #
Get the value of the “max-value
” property.
When overloading is enabled, this is equivalent to
get
levelBar #maxValue
setLevelBarMaxValue :: (MonadIO m, IsLevelBar o) => o -> Double -> m () Source #
Set the value of the “max-value
” property.
When overloading is enabled, this is equivalent to
set
levelBar [ #maxValue:=
value ]
minValue
Determines the minimum value of the interval that can be displayed by the bar.
constructLevelBarMinValue :: (IsLevelBar o, MonadIO m) => Double -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “min-value
” property. This is rarely needed directly, but it is used by new
.
getLevelBarMinValue :: (MonadIO m, IsLevelBar o) => o -> m Double Source #
Get the value of the “min-value
” property.
When overloading is enabled, this is equivalent to
get
levelBar #minValue
setLevelBarMinValue :: (MonadIO m, IsLevelBar o) => o -> Double -> m () Source #
Set the value of the “min-value
” property.
When overloading is enabled, this is equivalent to
set
levelBar [ #minValue:=
value ]
mode
Determines the way GtkLevelBar
interprets the value properties to draw the
level fill area.
Specifically, when the value is LevelBarModeContinuous
,
GtkLevelBar
will draw a single block representing the current value in
that area; when the value is LevelBarModeDiscrete
,
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 LevelBar:minValue and
LevelBar:maxValue.
constructLevelBarMode :: (IsLevelBar o, MonadIO m) => LevelBarMode -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “mode
” property. This is rarely needed directly, but it is used by new
.
getLevelBarMode :: (MonadIO m, IsLevelBar o) => o -> m LevelBarMode Source #
Get the value of the “mode
” property.
When overloading is enabled, this is equivalent to
get
levelBar #mode
setLevelBarMode :: (MonadIO m, IsLevelBar o) => o -> LevelBarMode -> m () Source #
Set the value of the “mode
” property.
When overloading is enabled, this is equivalent to
set
levelBar [ #mode:=
value ]
value
Determines the currently filled value of the level bar.
constructLevelBarValue :: (IsLevelBar o, MonadIO m) => Double -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “value
” property. This is rarely needed directly, but it is used by new
.
getLevelBarValue :: (MonadIO m, IsLevelBar o) => o -> m Double Source #
Get the value of the “value
” property.
When overloading is enabled, this is equivalent to
get
levelBar #value
setLevelBarValue :: (MonadIO m, IsLevelBar o) => o -> Double -> m () Source #
Set the value of the “value
” property.
When overloading is enabled, this is equivalent to
set
levelBar [ #value:=
value ]
Signals
offsetChanged
type LevelBarOffsetChangedCallback Source #
Emitted when an offset specified on the bar changes value.
This typically is the result of a levelBarAddOffsetValue
call.
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.
afterLevelBarOffsetChanged :: (IsLevelBar a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => LevelBarOffsetChangedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the offsetChanged signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
levelBar #offsetChanged callback
This signal admits a optional parameter detail
.
If it's not Nothing
, we will connect to “offset-changed::detail
” instead.
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onLevelBarOffsetChanged :: (IsLevelBar a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => LevelBarOffsetChangedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the offsetChanged signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
levelBar #offsetChanged callback
This signal admits a optional parameter detail
.
If it's not Nothing
, we will connect to “offset-changed::detail
” instead.