gi-gtk-3.0.37: Gtk bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Gtk.Objects.LevelBar

Description

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.

Synopsis

Exported types

newtype LevelBar Source #

Memory-managed wrapper type.

Constructors

LevelBar (ManagedPtr LevelBar) 

Instances

Instances details
Eq LevelBar Source # 
Instance details

Defined in GI.Gtk.Objects.LevelBar

GObject LevelBar Source # 
Instance details

Defined in GI.Gtk.Objects.LevelBar

ManagedPtrNewtype LevelBar Source # 
Instance details

Defined in GI.Gtk.Objects.LevelBar

Methods

toManagedPtr :: LevelBar -> ManagedPtr LevelBar

TypedObject LevelBar Source # 
Instance details

Defined in GI.Gtk.Objects.LevelBar

Methods

glibType :: IO GType

HasParentTypes LevelBar Source # 
Instance details

Defined in GI.Gtk.Objects.LevelBar

IsGValue (Maybe LevelBar) Source #

Convert LevelBar to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Gtk.Objects.LevelBar

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe LevelBar -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe LevelBar)

type ParentTypes LevelBar Source # 
Instance details

Defined in GI.Gtk.Objects.LevelBar

type ParentTypes LevelBar = '[Widget, Object, ImplementorIface, Buildable, 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

Instances details
(GObject o, IsDescendantOf LevelBar o) => IsLevelBar o Source # 
Instance details

Defined in GI.Gtk.Objects.LevelBar

toLevelBar :: (MonadIO m, IsLevelBar o) => o -> m LevelBar Source #

Cast to LevelBar, for types for which this is known to be safe. For general casts, use castTo.

Methods

Click to display all available methods, including inherited ones

Expand

Methods

activate, addAccelerator, addChild, addDeviceEvents, addEvents, addMnemonicLabel, addOffsetValue, addTickCallback, bindProperty, bindPropertyFull, canActivateAccel, childFocus, childNotify, classPath, computeExpand, constructChild, createPangoContext, createPangoLayout, customFinished, customTagEnd, customTagStart, destroy, destroyed, deviceIsShadowed, dragBegin, dragBeginWithCoordinates, dragCheckThreshold, dragDestAddImageTargets, dragDestAddTextTargets, dragDestAddUriTargets, dragDestFindTarget, dragDestGetTargetList, dragDestGetTrackMotion, dragDestSet, dragDestSetProxy, dragDestSetTargetList, dragDestSetTrackMotion, dragDestUnset, dragGetData, dragHighlight, dragSourceAddImageTargets, dragSourceAddTextTargets, dragSourceAddUriTargets, dragSourceGetTargetList, dragSourceSet, dragSourceSetIconGicon, dragSourceSetIconName, dragSourceSetIconPixbuf, dragSourceSetIconStock, dragSourceSetTargetList, dragSourceUnset, dragUnhighlight, draw, ensureStyle, errorBell, event, forceFloating, freezeChildNotify, freezeNotify, getv, grabAdd, grabDefault, grabFocus, grabRemove, hasDefault, hasFocus, hasGrab, hasRcStyle, hasScreen, hasVisibleFocus, hide, hideOnDelete, inDestruction, initTemplate, inputShapeCombineRegion, insertActionGroup, intersect, isAncestor, isComposited, isDrawable, isFloating, isFocus, isSensitive, isToplevel, isVisible, keynavFailed, listAccelClosures, listActionPrefixes, listMnemonicLabels, map, mnemonicActivate, modifyBase, modifyBg, modifyCursor, modifyFg, modifyFont, modifyStyle, modifyText, notify, notifyByPspec, overrideBackgroundColor, overrideColor, overrideCursor, overrideFont, overrideSymbolicColor, parserFinished, path, queueAllocate, queueComputeExpand, queueDraw, queueDrawArea, queueDrawRegion, queueResize, queueResizeNoRedraw, realize, ref, refSink, regionIntersect, registerWindow, removeAccelerator, removeMnemonicLabel, removeOffsetValue, removeTickCallback, renderIcon, renderIconPixbuf, reparent, resetRcStyles, resetStyle, runDispose, sendExpose, sendFocusChange, shapeCombineRegion, show, showAll, showNow, sizeAllocate, sizeAllocateWithBaseline, sizeRequest, stealData, stealQdata, styleAttach, styleGetProperty, thawChildNotify, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unregisterWindow, unsetStateFlags, watchClosure.

Getters

getAccessible, getActionGroup, getAllocatedBaseline, getAllocatedHeight, getAllocatedSize, getAllocatedWidth, getAllocation, getAncestor, getAppPaintable, getCanDefault, getCanFocus, getChildRequisition, getChildVisible, getClip, getClipboard, getCompositeName, getData, getDeviceEnabled, getDeviceEvents, getDirection, getDisplay, getDoubleBuffered, getEvents, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHasWindow, getHexpand, getHexpandSet, getInternalChild, getInverted, getMapped, getMarginBottom, getMarginEnd, getMarginLeft, getMarginRight, getMarginStart, getMarginTop, getMaxValue, getMinValue, getMode, getModifierMask, getModifierStyle, getName, getNoShowAll, getOffsetValue, getOpacity, getOrientation, getPangoContext, getParent, getParentWindow, getPath, getPointer, getPreferredHeight, getPreferredHeightAndBaselineForWidth, getPreferredHeightForWidth, getPreferredSize, getPreferredWidth, getPreferredWidthForHeight, getProperty, getQdata, getRealized, getReceivesDefault, getRequestMode, getRequisition, getRootWindow, getScaleFactor, getScreen, getSensitive, getSettings, getSizeRequest, getState, getStateFlags, getStyle, getStyleContext, getSupportMultidevice, getTemplateChild, getTooltipMarkup, getTooltipText, getTooltipWindow, getToplevel, getValign, getValignWithBaseline, getValue, getVexpand, getVexpandSet, getVisible, getVisual, getWindow.

Setters

setAccelPath, setAllocation, setAppPaintable, setBuildableProperty, setCanDefault, setCanFocus, setChildVisible, setClip, setCompositeName, setData, setDataFull, setDeviceEnabled, setDeviceEvents, setDirection, setDoubleBuffered, setEvents, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHasWindow, setHexpand, setHexpandSet, setInverted, setMapped, setMarginBottom, setMarginEnd, setMarginLeft, setMarginRight, setMarginStart, setMarginTop, setMaxValue, setMinValue, setMode, setName, setNoShowAll, setOpacity, setOrientation, setParent, setParentWindow, setProperty, setRealized, setReceivesDefault, setRedrawOnAllocate, setSensitive, setSizeRequest, setState, setStateFlags, setStyle, setSupportMultidevice, setTooltipMarkup, setTooltipText, setTooltipWindow, setValign, setValue, setVexpand, setVexpandSet, setVisible, setVisual, setWindow.

addOffsetValue

levelBarAddOffsetValue Source #

Arguments

:: (HasCallStack, MonadIO m, IsLevelBar a) 
=> a

self: a LevelBar

-> Text

name: the name of the new offset

-> Double

value: the value for the new offset

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

levelBarGetInverted Source #

Arguments

:: (HasCallStack, MonadIO m, IsLevelBar a) 
=> a

self: a LevelBar

-> m Bool

Returns: True if the level bar is inverted

Return the value of the LevelBar:inverted property.

Since: 3.8

getMaxValue

levelBarGetMaxValue Source #

Arguments

:: (HasCallStack, MonadIO m, IsLevelBar a) 
=> a

self: a LevelBar

-> m Double

Returns: a positive value

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

Since: 3.6

getMinValue

levelBarGetMinValue Source #

Arguments

:: (HasCallStack, MonadIO m, IsLevelBar a) 
=> a

self: a LevelBar

-> m Double

Returns: a positive value

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

Since: 3.6

getMode

levelBarGetMode Source #

Arguments

:: (HasCallStack, MonadIO m, IsLevelBar a) 
=> a

self: a LevelBar

-> m LevelBarMode

Returns: a LevelBarMode

Returns the value of the LevelBar:mode property.

Since: 3.6

getOffsetValue

levelBarGetOffsetValue Source #

Arguments

:: (HasCallStack, MonadIO m, IsLevelBar a) 
=> a

self: a LevelBar

-> Maybe Text

name: the name of an offset in the bar

-> m (Bool, Double)

Returns: True if the specified offset is found

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

levelBarGetValue Source #

Arguments

:: (HasCallStack, MonadIO m, IsLevelBar a) 
=> a

self: a LevelBar

-> m Double

Returns: a value in the interval between LevelBar:min-value and LevelBar:max-value

Returns the value of the LevelBar:value property.

Since: 3.6

new

levelBarNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m LevelBar

Returns: a LevelBar.

Creates a new LevelBar.

Since: 3.6

newForInterval

levelBarNewForInterval Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Double

minValue: a positive value

-> Double

maxValue: a positive value

-> m LevelBar

Returns: a LevelBar

Utility constructor that creates a new LevelBar for the specified interval.

Since: 3.6

removeOffsetValue

levelBarRemoveOffsetValue Source #

Arguments

:: (HasCallStack, MonadIO m, IsLevelBar a) 
=> a

self: a LevelBar

-> Maybe Text

name: the name of an offset in the bar

-> m () 

Removes an offset marker previously added with levelBarAddOffsetValue.

Since: 3.6

setInverted

levelBarSetInverted Source #

Arguments

:: (HasCallStack, MonadIO m, IsLevelBar a) 
=> a

self: a LevelBar

-> Bool

inverted: True to invert the level bar

-> m () 

Sets the value of the LevelBar:inverted property.

Since: 3.8

setMaxValue

levelBarSetMaxValue Source #

Arguments

:: (HasCallStack, MonadIO m, IsLevelBar a) 
=> a

self: a LevelBar

-> Double

value: a positive value

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

levelBarSetMinValue Source #

Arguments

:: (HasCallStack, MonadIO m, IsLevelBar a) 
=> a

self: a LevelBar

-> Double

value: a positive value

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

levelBarSetMode Source #

Arguments

:: (HasCallStack, MonadIO m, IsLevelBar a) 
=> a

self: a LevelBar

-> LevelBarMode

mode: a LevelBarMode

-> m () 

Sets the value of the LevelBar:mode property.

Since: 3.6

setValue

levelBarSetValue Source #

Arguments

:: (HasCallStack, MonadIO m, IsLevelBar a) 
=> a

self: a LevelBar

-> Double

value: a value in the interval between LevelBar:min-value and LevelBar:max-value

-> m () 

Sets the value of the LevelBar:value property.

Since: 3.6

Properties

inverted

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

Since: 3.8

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

The LevelBar:max-value property determaxes the maximum value of the interval that can be displayed by the bar.

Since: 3.6

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

The LevelBar:min-value property determines the minimum value of the interval that can be displayed by the bar.

Since: 3.6

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

The LevelBar:mode property determines the way LevelBar interprets the value properties to draw the level fill area. Specifically, when the value is GTK_LEVEL_BAR_MODE_CONTINUOUS, LevelBar 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 LevelBar:min-value and LevelBar:max-value.

Since: 3.6

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

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

Since: 3.6

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 C_LevelBarOffsetChangedCallback = Ptr () -> CString -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type LevelBarOffsetChangedCallback Source #

Arguments

 = Text

name: the name of the offset that changed value

-> IO () 

Emitted when an offset specified on the bar changes value as an effect to levelBarAddOffsetValue being called.

The signal supports detailed connections; you can connect to the detailed signal "changed[x](#g:signal:x)" in order to only receive callbacks when the value of offset "x" changes.

Since: 3.6

afterLevelBarOffsetChanged :: (IsLevelBar a, MonadIO m) => a -> Maybe Text -> 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.

onLevelBarOffsetChanged :: (IsLevelBar a, MonadIO m) => a -> Maybe Text -> 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.