Copyright | Will Thompson, Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
The LevelBar
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 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-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 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 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 code
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.
- newtype LevelBar = LevelBar (ManagedPtr LevelBar)
- class GObject o => IsLevelBar o
- toLevelBar :: IsLevelBar o => o -> IO LevelBar
- noLevelBar :: Maybe LevelBar
- data LevelBarAddOffsetValueMethodInfo
- levelBarAddOffsetValue :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> Text -> Double -> m ()
- data LevelBarGetInvertedMethodInfo
- levelBarGetInverted :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> m Bool
- data LevelBarGetMaxValueMethodInfo
- levelBarGetMaxValue :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> m Double
- data LevelBarGetMinValueMethodInfo
- levelBarGetMinValue :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> m Double
- data LevelBarGetModeMethodInfo
- levelBarGetMode :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> m LevelBarMode
- data LevelBarGetOffsetValueMethodInfo
- levelBarGetOffsetValue :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> Maybe Text -> m (Bool, Double)
- data LevelBarGetValueMethodInfo
- levelBarGetValue :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> m Double
- levelBarNew :: (HasCallStack, MonadIO m) => m LevelBar
- levelBarNewForInterval :: (HasCallStack, MonadIO m) => Double -> Double -> m LevelBar
- data LevelBarRemoveOffsetValueMethodInfo
- levelBarRemoveOffsetValue :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> Maybe Text -> m ()
- data LevelBarSetInvertedMethodInfo
- levelBarSetInverted :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> Bool -> m ()
- data LevelBarSetMaxValueMethodInfo
- levelBarSetMaxValue :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> Double -> m ()
- data LevelBarSetMinValueMethodInfo
- levelBarSetMinValue :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> Double -> m ()
- data LevelBarSetModeMethodInfo
- levelBarSetMode :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> LevelBarMode -> m ()
- data LevelBarSetValueMethodInfo
- levelBarSetValue :: (HasCallStack, MonadIO m, IsLevelBar a) => a -> Double -> m ()
- data LevelBarInvertedPropertyInfo
- constructLevelBarInverted :: IsLevelBar o => Bool -> IO (GValueConstruct o)
- getLevelBarInverted :: (MonadIO m, IsLevelBar o) => o -> m Bool
- levelBarInverted :: AttrLabelProxy "inverted"
- setLevelBarInverted :: (MonadIO m, IsLevelBar o) => o -> Bool -> m ()
- data LevelBarMaxValuePropertyInfo
- constructLevelBarMaxValue :: IsLevelBar o => Double -> IO (GValueConstruct o)
- getLevelBarMaxValue :: (MonadIO m, IsLevelBar o) => o -> m Double
- levelBarMaxValue :: AttrLabelProxy "maxValue"
- setLevelBarMaxValue :: (MonadIO m, IsLevelBar o) => o -> Double -> m ()
- data LevelBarMinValuePropertyInfo
- constructLevelBarMinValue :: IsLevelBar o => Double -> IO (GValueConstruct o)
- getLevelBarMinValue :: (MonadIO m, IsLevelBar o) => o -> m Double
- levelBarMinValue :: AttrLabelProxy "minValue"
- setLevelBarMinValue :: (MonadIO m, IsLevelBar o) => o -> Double -> m ()
- data LevelBarModePropertyInfo
- constructLevelBarMode :: IsLevelBar o => LevelBarMode -> IO (GValueConstruct o)
- getLevelBarMode :: (MonadIO m, IsLevelBar o) => o -> m LevelBarMode
- levelBarMode :: AttrLabelProxy "mode"
- setLevelBarMode :: (MonadIO m, IsLevelBar o) => o -> LevelBarMode -> m ()
- data LevelBarValuePropertyInfo
- constructLevelBarValue :: IsLevelBar o => Double -> IO (GValueConstruct o)
- getLevelBarValue :: (MonadIO m, IsLevelBar o) => o -> m Double
- levelBarValue :: AttrLabelProxy "value"
- setLevelBarValue :: (MonadIO m, IsLevelBar o) => o -> Double -> m ()
- type C_LevelBarOffsetChangedCallback = Ptr () -> CString -> Ptr () -> IO ()
- type LevelBarOffsetChangedCallback = Text -> IO ()
- data LevelBarOffsetChangedSignalInfo
- afterLevelBarOffsetChanged :: (GObject a, MonadIO m) => a -> LevelBarOffsetChangedCallback -> m SignalHandlerId
- genClosure_LevelBarOffsetChanged :: LevelBarOffsetChangedCallback -> IO Closure
- mk_LevelBarOffsetChangedCallback :: C_LevelBarOffsetChangedCallback -> IO (FunPtr C_LevelBarOffsetChangedCallback)
- noLevelBarOffsetChangedCallback :: Maybe LevelBarOffsetChangedCallback
- onLevelBarOffsetChanged :: (GObject a, MonadIO m) => a -> LevelBarOffsetChangedCallback -> m SignalHandlerId
- wrap_LevelBarOffsetChangedCallback :: LevelBarOffsetChangedCallback -> Ptr () -> CString -> Ptr () -> IO ()
Exported types
GObject LevelBar Source # | |
IsImplementorIface LevelBar Source # | |
IsObject LevelBar Source # | |
IsWidget LevelBar Source # | |
IsOrientable LevelBar Source # | |
IsBuildable LevelBar Source # | |
IsLevelBar LevelBar Source # | |
((~) * info (ResolveLevelBarMethod t LevelBar), MethodInfo * info LevelBar p) => IsLabel t (LevelBar -> p) Source # | |
((~) * info (ResolveLevelBarMethod t LevelBar), MethodInfo * info LevelBar p) => IsLabelProxy t (LevelBar -> p) Source # | |
HasAttributeList * LevelBar Source # | |
type AttributeList LevelBar Source # | |
type SignalList LevelBar Source # | |
class GObject o => IsLevelBar o Source #
(GObject a, UnknownAncestorError Constraint LevelBar a) => IsLevelBar a Source # | |
IsLevelBar LevelBar Source # | |
toLevelBar :: IsLevelBar o => o -> IO LevelBar Source #
Methods
addOffsetValue
data LevelBarAddOffsetValueMethodInfo Source #
((~) * signature (Text -> Double -> m ()), MonadIO m, IsLevelBar a) => MethodInfo * LevelBarAddOffsetValueMethodInfo a signature Source # | |
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
: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
.
Since: 3.6
getInverted
data LevelBarGetInvertedMethodInfo Source #
((~) * signature (m Bool), MonadIO m, IsLevelBar a) => MethodInfo * LevelBarGetInvertedMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> m Bool | Returns: |
Return the value of the LevelBar
:inverted
property.
Since: 3.8
getMaxValue
data LevelBarGetMaxValueMethodInfo Source #
((~) * signature (m Double), MonadIO m, IsLevelBar a) => MethodInfo * LevelBarGetMaxValueMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> m Double | Returns: a positive value |
Returns the value of the LevelBar
:max-value
property.
Since: 3.6
getMinValue
data LevelBarGetMinValueMethodInfo Source #
((~) * signature (m Double), MonadIO m, IsLevelBar a) => MethodInfo * LevelBarGetMinValueMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> m Double | Returns: a positive value |
Returns the value of the LevelBar
:min-value
property.
Since: 3.6
getMode
data LevelBarGetModeMethodInfo Source #
((~) * signature (m LevelBarMode), MonadIO m, IsLevelBar a) => MethodInfo * LevelBarGetModeMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> m LevelBarMode | Returns: a |
Returns the value of the LevelBar
:mode
property.
Since: 3.6
getOffsetValue
data LevelBarGetOffsetValueMethodInfo Source #
((~) * signature (Maybe Text -> m (Bool, Double)), MonadIO m, IsLevelBar a) => MethodInfo * LevelBarGetOffsetValueMethodInfo a signature Source # | |
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
,
returning True
in case an offset named name
was found.
Since: 3.6
getValue
data LevelBarGetValueMethodInfo Source #
((~) * signature (m Double), MonadIO m, IsLevelBar a) => MethodInfo * LevelBarGetValueMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> m Double | Returns: a value in the interval between
|
Returns the value of the LevelBar
:value
property.
Since: 3.6
new
:: (HasCallStack, MonadIO m) | |
=> m LevelBar | Returns: a |
Creates a new LevelBar
.
Since: 3.6
newForInterval
levelBarNewForInterval Source #
:: (HasCallStack, MonadIO m) | |
=> Double |
|
-> Double |
|
-> m LevelBar | Returns: a |
Utility constructor that creates a new LevelBar
for the specified
interval.
Since: 3.6
removeOffsetValue
data LevelBarRemoveOffsetValueMethodInfo Source #
((~) * signature (Maybe Text -> m ()), MonadIO m, IsLevelBar a) => MethodInfo * LevelBarRemoveOffsetValueMethodInfo a signature Source # | |
levelBarRemoveOffsetValue Source #
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> Maybe Text |
|
-> m () |
Removes an offset marker previously added with
levelBarAddOffsetValue
.
Since: 3.6
setInverted
data LevelBarSetInvertedMethodInfo Source #
((~) * signature (Bool -> m ()), MonadIO m, IsLevelBar a) => MethodInfo * LevelBarSetInvertedMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> Bool |
|
-> m () |
Sets the value of the LevelBar
:inverted
property.
Since: 3.8
setMaxValue
data LevelBarSetMaxValueMethodInfo Source #
((~) * signature (Double -> m ()), MonadIO m, IsLevelBar a) => MethodInfo * LevelBarSetMaxValueMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> Double |
|
-> m () |
Sets the value of the LevelBar
:max-value
property.
You probably want to update preexisting level offsets after calling this function.
Since: 3.6
setMinValue
data LevelBarSetMinValueMethodInfo Source #
((~) * signature (Double -> m ()), MonadIO m, IsLevelBar a) => MethodInfo * LevelBarSetMinValueMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> Double |
|
-> m () |
Sets the value of the LevelBar
:min-value
property.
You probably want to update preexisting level offsets after calling this function.
Since: 3.6
setMode
data LevelBarSetModeMethodInfo Source #
((~) * signature (LevelBarMode -> m ()), MonadIO m, IsLevelBar a) => MethodInfo * LevelBarSetModeMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> LevelBarMode |
|
-> m () |
Sets the value of the LevelBar
:mode
property.
Since: 3.6
setValue
data LevelBarSetValueMethodInfo Source #
((~) * signature (Double -> m ()), MonadIO m, IsLevelBar a) => MethodInfo * LevelBarSetValueMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsLevelBar a) | |
=> a |
|
-> Double |
|
-> m () |
Sets the value of the LevelBar
:value
property.
Since: 3.6
Properties
inverted
data LevelBarInvertedPropertyInfo Source #
constructLevelBarInverted :: IsLevelBar o => Bool -> IO (GValueConstruct o) Source #
getLevelBarInverted :: (MonadIO m, IsLevelBar o) => o -> m Bool Source #
levelBarInverted :: AttrLabelProxy "inverted" Source #
setLevelBarInverted :: (MonadIO m, IsLevelBar o) => o -> Bool -> m () Source #
maxValue
data LevelBarMaxValuePropertyInfo Source #
constructLevelBarMaxValue :: IsLevelBar o => Double -> IO (GValueConstruct o) Source #
getLevelBarMaxValue :: (MonadIO m, IsLevelBar o) => o -> m Double Source #
levelBarMaxValue :: AttrLabelProxy "maxValue" Source #
setLevelBarMaxValue :: (MonadIO m, IsLevelBar o) => o -> Double -> m () Source #
minValue
data LevelBarMinValuePropertyInfo Source #
constructLevelBarMinValue :: IsLevelBar o => Double -> IO (GValueConstruct o) Source #
getLevelBarMinValue :: (MonadIO m, IsLevelBar o) => o -> m Double Source #
levelBarMinValue :: AttrLabelProxy "minValue" Source #
setLevelBarMinValue :: (MonadIO m, IsLevelBar o) => o -> Double -> m () Source #
mode
data LevelBarModePropertyInfo Source #
constructLevelBarMode :: IsLevelBar o => LevelBarMode -> IO (GValueConstruct o) Source #
getLevelBarMode :: (MonadIO m, IsLevelBar o) => o -> m LevelBarMode Source #
levelBarMode :: AttrLabelProxy "mode" Source #
setLevelBarMode :: (MonadIO m, IsLevelBar o) => o -> LevelBarMode -> m () Source #
value
data LevelBarValuePropertyInfo Source #
constructLevelBarValue :: IsLevelBar o => Double -> IO (GValueConstruct o) Source #
getLevelBarValue :: (MonadIO m, IsLevelBar o) => o -> m Double Source #
levelBarValue :: AttrLabelProxy "value" Source #
setLevelBarValue :: (MonadIO m, IsLevelBar o) => o -> Double -> m () Source #
Signals
offsetChanged
type LevelBarOffsetChangedCallback = Text -> IO () Source #
afterLevelBarOffsetChanged :: (GObject a, MonadIO m) => a -> LevelBarOffsetChangedCallback -> m SignalHandlerId Source #
mk_LevelBarOffsetChangedCallback :: C_LevelBarOffsetChangedCallback -> IO (FunPtr C_LevelBarOffsetChangedCallback) Source #
onLevelBarOffsetChanged :: (GObject a, MonadIO m) => a -> LevelBarOffsetChangedCallback -> m SignalHandlerId Source #
wrap_LevelBarOffsetChangedCallback :: LevelBarOffsetChangedCallback -> Ptr () -> CString -> Ptr () -> IO () Source #