Class ProgressBar
- All Implemented Interfaces:
Proxy
,Accessible
,AccessibleRange
,Buildable
,ConstraintTarget
,Orientable
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.
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
setFraction(double)
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 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 AccessibleRole.PROGRESS_BAR
role.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
ProgressBar.Builder<B extends ProgressBar.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.Nested classes/interfaces inherited from class org.gnome.gtk.Widget
Widget.DestroyCallback, Widget.DirectionChangedCallback, Widget.HideCallback, Widget.KeynavFailedCallback, Widget.MapCallback, Widget.MnemonicActivateCallback, Widget.MoveFocusCallback, Widget.QueryTooltipCallback, Widget.RealizeCallback, Widget.ShowCallback, Widget.StateFlagsChangedCallback, Widget.UnmapCallback, Widget.UnrealizeCallback, Widget.WidgetClass, Widget.WidgetImpl
Nested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClass
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gtk.Accessible
Accessible.AccessibleImpl, Accessible.AccessibleInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.AccessibleRange
AccessibleRange.AccessibleRangeImpl, AccessibleRange.AccessibleRangeInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.BuildableIface, Buildable.BuildableImpl
Nested classes/interfaces inherited from interface org.gnome.gtk.ConstraintTarget
ConstraintTarget.ConstraintTargetImpl, ConstraintTarget.ConstraintTargetInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.Orientable
Orientable.OrientableIface, Orientable.OrientableImpl
-
Constructor Summary
ConstructorDescriptionCreates a newGtkProgressBar
.ProgressBar
(MemorySegment address) Create a ProgressBar proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected ProgressBar
asParent()
Returns this instance as if it were its parent type.static ProgressBar.Builder
<? extends ProgressBar.Builder> builder()
AProgressBar.Builder
object constructs aProgressBar
with the specified properties.Returns the ellipsizing position of the progress bar.double
Returns the current fraction of the task that’s been completed.boolean
Returns whether the progress bar is inverted.double
Retrieves the pulse step.boolean
Returns whether theGtkProgressBar
shows text.getText()
Retrieves the text that is displayed with the progress bar.static Type
getType()
Get the GType of the ProgressBar classvoid
pulse()
Indicates that some progress has been made, but you don’t know how much.void
setEllipsize
(EllipsizeMode 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 showText) Sets whether the progress bar will show text next to the bar.void
Causes the giventext
to appear next to the progress bar.Methods inherited from class org.gnome.gtk.Widget
actionSetEnabled, activateActionIfExists, activateDefault, activateWidget, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, cssChanged, directionChanged, disposeTemplate, dragCheckThreshold, emitDestroy, emitDirectionChanged, emitHide, emitKeynavFailed, emitMap, emitMnemonicActivate, emitMoveFocus, emitQueryTooltip, emitRealize, emitShow, emitStateFlagsChanged, emitUnmap, emitUnrealize, errorBell, focus, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBaseline, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, 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, getMemoryLayout, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, moveFocus, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, pick, queryTooltip, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, root, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, sizeAllocate, snapshot, snapshotChild, stateFlagsChanged, systemSettingChanged, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unroot, unsetStateFlags, unsetStateFlags
Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.gnome.gtk.Accessible
announce, getAccessibleParent, getAccessibleRole, getAtContext, getBounds, getFirstAccessibleChild, getNextAccessibleSibling, getPlatformState, resetProperty, resetRelation, resetState, setAccessibleParent, updateNextAccessibleSibling, updateProperty, updateRelation, updateState
Methods inherited from interface org.gnome.gtk.Buildable
getBuildableId
Methods inherited from interface org.gnome.gtk.Orientable
getOrientation, setOrientation
-
Constructor Details
-
ProgressBar
Create a ProgressBar proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
ProgressBar
public ProgressBar()Creates a newGtkProgressBar
.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
getEllipsize
Returns the ellipsizing position of the progress bar.- 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
setPulseStep(double)
.- Returns:
- a fraction from 0.0 to 1.0
-
getShowText
public boolean getShowText()Returns whether theGtkProgressBar
shows text.See
setShowText(boolean)
.- 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
pulse()
causes the block to move by a little bit (the amount of movement per pulse is determined bysetPulseStep(double)
). -
setEllipsize
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
- aPangoEllipsizeMode
-
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
pulse()
is called.- Parameters:
fraction
- fraction between 0.0 and 1.0
-
setShowText
public void setShowText(boolean showText) Sets whether the progress bar will show text next to the bar.The shown text is either the value of the
Gtk.ProgressBar:text
property or, if that isnull
, theGtk.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
Gtk.ProgressBar:show-text
totrue
andGtk.ProgressBar:text
to the empty string (notnull
).- Parameters:
showText
- whether to show text
-
setText
Causes the giventext
to appear next to the progress bar.If
text
isnull
andGtk.ProgressBar:show-text
istrue
, the current value ofGtk.ProgressBar:fraction
will be displayed as a percentage.If
text
is non-null
andGtk.ProgressBar:show-text
istrue
, the text will be displayed. In this case, it will not display the progress percentage. Iftext
is the empty string, the progress bar will still be styled and sized suitably for containing text, as long asGtk.ProgressBar:show-text
istrue
.- Parameters:
text
- a UTF-8 string
-
builder
AProgressBar.Builder
object constructs aProgressBar
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withProgressBar.Builder.build()
.
-