1.159 <GtkProgressBar>

Class: <GtkProgressBar>

It derives from <GtkWidget>.

Displays the progress of a long-running operation.

<GtkProgressBar> provides a visual clue that processing is underway. It 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 progress-bar: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 progress-bar: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.AccessibleRole.progress_bar role and sets the Gtk.AccessibleProperty.value_min, Gtk.AccessibleProperty.value_max and Gtk.AccessibleProperty.value_now properties to reflect the progress.

Properties

Property: progress-bar:ellipsize self

The preferred place to ellipsize the string.

The text will be ellipsized if the progress bar does not have enough room to display the entire string, specified as a <PangoEllipsizeMode>.

Note that setting this property to a value other than none has the side-effect that the progress bar requests only enough space to display the ellipsis ("..."). Another means to set a progress bar’s width is widget:set-size-request.

Its value is a <PangoEllipsizeMode> (or, to set it, one of its symbols).

Set it with (set! (progress-bar:ellipsize self) value).

Property: progress-bar:fraction self

The fraction of total work that has been completed.

Its value is a real number.

Set it with (set! (progress-bar:fraction self) value).

Property: progress-bar:inverted self

Invert the direction in which the progress bar grows.

Its value is a boolean.

Set it with (set! (progress-bar:inverted self) value).

Property: progress-bar:pulse-step self

The fraction of total progress to move the bounding block when pulsed.

Its value is a real number.

Set it with (set! (progress-bar:pulse-step self) value).

Property: progress-bar:show-text self

Sets whether the progress bar will show a text in addition to the bar itself.

The shown text is either the value of the progress-bar:text property or, if that is #f, the progress-bar:fraction value, as a percentage.

To make a progress bar that is styled and sized suitably for showing text (even if the actual text is blank), set progress-bar:show-text to #t and progress-bar:text to the empty string (not #f).

Its value is a boolean.

Set it with (set! (progress-bar:show-text self) value).

Property: progress-bar:text self

Text to be displayed in the progress bar.

Its value is a string, or #f.

Set it with (set! (progress-bar:text self) value).

Procedures

Method: progress-bar:get-ellipsize self ⇒ %return
Method: get-ellipsize self ⇒ %return

Returns the ellipsizing position of the progress bar.

See progress-bar:set-ellipsize.

self

Passed: a <GtkProgressBar>.

a <GtkProgressBar>

%return

Returned: a <PangoEllipsizeMode>.

<PangoEllipsizeMode>

Method: progress-bar:get-fraction self ⇒ %return
Method: get-fraction self ⇒ %return

Returns the current fraction of the task that’s been completed.

self

Passed: a <GtkProgressBar>.

a <GtkProgressBar>

%return

Returned: a real number.

a fraction from 0.0 to 1.0

Method: progress-bar:get-inverted? self ⇒ %return
Method: get-inverted? self ⇒ %return

Returns whether the progress bar is inverted.

self

Passed: a <GtkProgressBar>.

a <GtkProgressBar>

%return

Returned: a boolean.

#t if the progress bar is inverted

Method: progress-bar:get-pulse-step self ⇒ %return
Method: get-pulse-step self ⇒ %return

Retrieves the pulse step.

See progress-bar:set-pulse-step.

self

Passed: a <GtkProgressBar>.

a <GtkProgressBar>

%return

Returned: a real number.

a fraction from 0.0 to 1.0

Method: progress-bar:get-show-text? self ⇒ %return
Method: get-show-text? self ⇒ %return

Returns whether the <GtkProgressBar> shows text.

See progress-bar:set-show-text.

self

Passed: a <GtkProgressBar>.

a <GtkProgressBar>

%return

Returned: a boolean.

#t if text is shown in the progress bar

Method: progress-bar:get-text self ⇒ %return
Method: get-text self ⇒ %return

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.

self

Passed: a <GtkProgressBar>.

a <GtkProgressBar>

%return

Returned: a string, or #f.

the text

Procedure: progress-bar:new ⇒ %return

Creates a new <GtkProgressBar>.

%return

Returned: a <GtkWidget>.

a <GtkProgressBar>.

Method: progress-bar:pulse self
Method: pulse self

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 progress-bar:pulse causes the block to move by a little bit (the amount of movement per pulse is determined by progress-bar:set-pulse-step).

self

Passed: a <GtkProgressBar>.

a <GtkProgressBar>

Method: progress-bar:set-ellipsize self mode
Method: set-ellipsize self mode

Sets the mode used to ellipsize the text.

The text is ellipsized if there is not enough space to render the entire string.

self

Passed: a <GtkProgressBar>.

a <GtkProgressBar>

mode

Passed: a <PangoEllipsizeMode>, or one of its symbols.

a <PangoEllipsizeMode>

Method: progress-bar:set-fraction self fraction
Method: set-fraction self 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.

self

Passed: a <GtkProgressBar>.

a <GtkProgressBar>

fraction

Passed: a real number.

fraction of the task that’s been completed

Method: progress-bar:set-inverted self inverted
Method: set-inverted self 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.

self

Passed: a <GtkProgressBar>.

a <GtkProgressBar>

inverted

Passed: a boolean.

#t to invert the progress bar

Method: progress-bar:set-pulse-step self fraction
Method: set-pulse-step self fraction

Sets the fraction of total progress bar length to move the bouncing block.

The bouncing block is moved when progress-bar:pulse is called.

self

Passed: a <GtkProgressBar>.

a <GtkProgressBar>

fraction

Passed: a real number.

fraction between 0.0 and 1.0

Method: progress-bar:set-show-text self show-text
Method: set-show-text self show-text

Sets whether the progress bar will show text next to the bar.

The shown text is either the value of the progress-bar:text property or, if that is #f, the progress-bar: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 progress-bar:show-text to #t and progress-bar:text to the empty string (not #f).

self

Passed: a <GtkProgressBar>.

a <GtkProgressBar>

show-text

Passed: a boolean.

whether to show text

Method: progress-bar:set-text self [text]
Method: set-text self [text]

Causes the given text to appear next to the progress bar.

If text is #f and progress-bar:show-text is #t, the current value of progress-bar:fraction will be displayed as a percentage.

If text is non-#f and progress-bar:show-text is #t, 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 progress-bar:show-text is #t.

self

Passed: a <GtkProgressBar>.

a <GtkProgressBar>

text

Passed, or left out: a string, or #f.

a UTF-8 string