Package ch.bailu.gtk.gtk
Class ProgressBar
- All Implemented Interfaces:
PointerInterface
`GtkProgressBar` is typically used to display the progress of a long
running operation.
It provides a visual clue that processing is underway. `GtkProgressBar`
can be used in two different modes: percentage mode and activity mode.
![An example GtkProgressBar](progressbar.png)
When an application can determine how much work needs to take place
(e.g. read a fixed number of bytes from a file) and can monitor its
progress, it can use the `GtkProgressBar` in percentage mode and the
user sees a growing bar indicating the percentage of the work that
has been completed. In this mode, the application is required to call
[method@Gtk.ProgressBar.set_fraction] periodically to update the progress bar.
When an application has no accurate way of knowing the amount of work
to do, it can use the `GtkProgressBar` in activity mode, which shows
activity by a block moving back and forth within the progress area. In
this mode, the application is required to call [method@Gtk.ProgressBar.pulse]
periodically to update the progress bar.
There is quite a bit of flexibility provided to control the appearance
of the `GtkProgressBar`. Functions are provided to control the orientation
of the bar, optional text can be displayed along with the bar, and the
step size used in activity mode can be set.
# CSS nodes
```
progressbar[.osd]
├── [text]
╰── trough[.empty][.full]
╰── progress[.pulse]
```
`GtkProgressBar` has a main CSS node with name progressbar and subnodes with
names text and trough, of which the latter has a subnode named progress. The
text subnode is only present if text is shown. The progress subnode has the
style class .pulse when in activity mode. It gets the style classes .left,
.right, .top or .bottom added when the progress 'touches' the corresponding
end of the GtkProgressBar. The .osd class on the progressbar node is for use
in overlays like the one Epiphany has for page loading progress.
# Accessibility
`GtkProgressBar` uses the %GTK_ACCESSIBLE_ROLE_PROGRESS_BAR role.
running operation.
It provides a visual clue that processing is underway. `GtkProgressBar`
can be used in two different modes: percentage mode and activity mode.
![An example GtkProgressBar](progressbar.png)
When an application can determine how much work needs to take place
(e.g. read a fixed number of bytes from a file) and can monitor its
progress, it can use the `GtkProgressBar` in percentage mode and the
user sees a growing bar indicating the percentage of the work that
has been completed. In this mode, the application is required to call
[method@Gtk.ProgressBar.set_fraction] periodically to update the progress bar.
When an application has no accurate way of knowing the amount of work
to do, it can use the `GtkProgressBar` in activity mode, which shows
activity by a block moving back and forth within the progress area. In
this mode, the application is required to call [method@Gtk.ProgressBar.pulse]
periodically to update the progress bar.
There is quite a bit of flexibility provided to control the appearance
of the `GtkProgressBar`. Functions are provided to control the orientation
of the bar, optional text can be displayed along with the bar, and the
step size used in activity mode can be set.
# CSS nodes
```
progressbar[.osd]
├── [text]
╰── trough[.empty][.full]
╰── progress[.pulse]
```
`GtkProgressBar` has a main CSS node with name progressbar and subnodes with
names text and trough, of which the latter has a subnode named progress. The
text subnode is only present if text is shown. The progress subnode has the
style class .pulse when in activity mode. It gets the style classes .left,
.right, .top or .bottom added when the progress 'touches' the corresponding
end of the GtkProgressBar. The .osd class on the progressbar node is for use
in overlays like the one Epiphany has for page loading progress.
# Accessibility
`GtkProgressBar` uses the %GTK_ACCESSIBLE_ROLE_PROGRESS_BAR role.
-
Nested Class Summary
Nested classes/interfaces inherited from class ch.bailu.gtk.gtk.Widget
Widget.OnDestroy, Widget.OnDestroyNotify, Widget.OnDirectionChanged, Widget.OnHide, Widget.OnKeynavFailed, Widget.OnMap, Widget.OnMnemonicActivate, Widget.OnMoveFocus, Widget.OnQueryTooltip, Widget.OnRealize, Widget.OnShow, Widget.OnStateFlagsChanged, Widget.OnTickCallback, Widget.OnUnmap, Widget.OnUnrealize
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gtk.Widget
SIGNAL_ON_DESTROY, SIGNAL_ON_DIRECTION_CHANGED, SIGNAL_ON_HIDE, SIGNAL_ON_KEYNAV_FAILED, SIGNAL_ON_MAP, SIGNAL_ON_MNEMONIC_ACTIVATE, SIGNAL_ON_MOVE_FOCUS, SIGNAL_ON_QUERY_TOOLTIP, SIGNAL_ON_REALIZE, SIGNAL_ON_SHOW, SIGNAL_ON_STATE_FLAGS_CHANGED, SIGNAL_ON_UNMAP, SIGNAL_ON_UNREALIZE
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionImplements interfaceAccessible
.Implements interfaceBuildable
.Implements interfaceConstraintTarget
.Implements interfaceOrientable
.static ClassHandler
int
Returns the ellipsizing position of the progress bar.double
Returns the current fraction of the task that’s been completed.static int
boolean
Returns whether the progress bar is inverted.static long
static TypeSystem.TypeSize
double
Retrieves the pulse step.boolean
Returns whether the `GtkProgressBar` shows text.getText()
Retrieves the text that is displayed with the progress bar.static long
static TypeSystem.TypeSize
void
pulse()
Indicates that some progress has been made, but you don’t know how much.void
setEllipsize
(int mode) Sets the mode used to ellipsize the text.void
setFraction
(double fraction) Causes the progress bar to “fill in” the given fraction
of the bar.void
setInverted
(boolean inverted) Sets whether the progress bar is inverted.void
setPulseStep
(double fraction) Sets the fraction of total progress bar length to move the
bouncing block.void
setShowText
(boolean show_text) Sets whether the progress bar will show text next to the bar.void
Causes the given @text to appear next to the progress bar.void
Causes the given @text to appear next to the progress bar.Methods inherited from class ch.bailu.gtk.gtk.Widget
actionSetEnabled, actionSetEnabled, activate, activateAction, activateAction, activateActionVariant, activateActionVariant, activateDefault, addController, addCssClass, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getCanFocus, getCanTarget, getChildVisible, getClipboard, getCssClasses, getCssName, getCursor, getDefaultDirection, getDirection, getDisplay, getFirstChild, getFocusable, getFocusChild, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeCssClass, removeMnemonicLabel, removeTickCallback, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipMarkup, setTooltipText, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, snapshotChild, triggerTooltipQuery, unmap, unparent, unrealize, unsetStateFlags
Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
ProgressBar
-
ProgressBar
public ProgressBar()Creates a new `GtkProgressBar`.
-
-
Method Details
-
getClassHandler
-
getEllipsize
public int getEllipsize()Returns the ellipsizing position of the progress bar.
See [method@Gtk.ProgressBar.set_ellipsize].- Returns:
- `PangoEllipsizeMode`
-
getFraction
public double getFraction()Returns the current fraction of the task that’s been completed.- Returns:
- a fraction from 0.0 to 1.0
-
getInverted
public boolean getInverted()Returns whether the progress bar is inverted.- Returns:
- %TRUE if the progress bar is inverted
-
getPulseStep
public double getPulseStep()Retrieves the pulse step.
See [method@Gtk.ProgressBar.set_pulse_step].- Returns:
- a fraction from 0.0 to 1.0
-
getShowText
public boolean getShowText()Returns whether the `GtkProgressBar` shows text.
See [method@Gtk.ProgressBar.set_show_text].- Returns:
- %TRUE if text is shown in the progress bar
-
getText
Retrieves the text that is displayed with the progress bar.
The return value is a reference to the text, not a copy of it,
so will become invalid if you change the text in the progress bar.- Returns:
- the text
-
pulse
public void pulse()Indicates that some progress has been made, but you don’t know how much.
Causes the progress bar to enter “activity mode,” where a block
bounces back and forth. Each call to [method@Gtk.ProgressBar.pulse]
causes the block to move by a little bit (the amount of movement
per pulse is determined by [method@Gtk.ProgressBar.set_pulse_step]). -
setEllipsize
public void setEllipsize(int mode) Sets the mode used to ellipsize the text.
The text is ellipsized if there is not enough space
to render the entire string.- Parameters:
mode
- a `PangoEllipsizeMode`
-
setFraction
public void setFraction(double fraction) Causes the progress bar to “fill in” the given fraction
of the bar.
The fraction should be between 0.0 and 1.0, inclusive.- Parameters:
fraction
- fraction of the task that’s been completed
-
setInverted
public void setInverted(boolean inverted) Sets whether the progress bar is inverted.
Progress bars normally grow from top to bottom or left to right.
Inverted progress bars grow in the opposite direction.- Parameters:
inverted
- %TRUE to invert the progress bar
-
setPulseStep
public void setPulseStep(double fraction) Sets the fraction of total progress bar length to move the
bouncing block.
The bouncing block is moved when [method@Gtk.ProgressBar.pulse]
is called.- Parameters:
fraction
- fraction between 0.0 and 1.0
-
setShowText
public void setShowText(boolean show_text) Sets whether the progress bar will show text next to the bar.
The shown text is either the value of the [property@Gtk.ProgressBar:text]
property or, if that is %NULL, the [property@Gtk.ProgressBar:fraction] value,
as a percentage.
To make a progress bar that is styled and sized suitably for containing
text (even if the actual text is blank), set [property@Gtk.ProgressBar:show-text]
to %TRUE and [property@Gtk.ProgressBar:text] to the empty string (not %NULL).- Parameters:
show_text
- whether to show text
-
setText
Causes the given @text to appear next to the progress bar.
If @text is %NULL and [property@Gtk.ProgressBar:show-text] is %TRUE,
the current value of [property@Gtk.ProgressBar:fraction] will be displayed
as a percentage.
If @text is non-%NULL and [property@Gtk.ProgressBar:show-text] is %TRUE,
the text will be displayed. In this case, it will not display the progress
percentage. If @text is the empty string, the progress bar will still
be styled and sized suitably for containing text, as long as
[property@Gtk.ProgressBar:show-text] is %TRUE.- Parameters:
text
- a UTF-8 string
-
setText
Causes the given @text to appear next to the progress bar.
If @text is %NULL and [property@Gtk.ProgressBar:show-text] is %TRUE,
the current value of [property@Gtk.ProgressBar:fraction] will be displayed
as a percentage.
If @text is non-%NULL and [property@Gtk.ProgressBar:show-text] is %TRUE,
the text will be displayed. In this case, it will not display the progress
percentage. If @text is the empty string, the progress bar will still
be styled and sized suitably for containing text, as long as
[property@Gtk.ProgressBar:show-text] is %TRUE.- Parameters:
text
- a UTF-8 string
-
asAccessible
Implements interfaceAccessible
. Call this to get access to interface functions.- Overrides:
asAccessible
in classWidget
- Returns:
Accessible
-
asBuildable
Implements interfaceBuildable
. Call this to get access to interface functions.- Overrides:
asBuildable
in classWidget
- Returns:
Buildable
-
asConstraintTarget
Implements interfaceConstraintTarget
. Call this to get access to interface functions.- Overrides:
asConstraintTarget
in classWidget
- Returns:
ConstraintTarget
-
asOrientable
Implements interfaceOrientable
. Call this to get access to interface functions.- Returns:
Orientable
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-