GTK+ 3 Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties | Style Properties |
#include <gtk/gtk.h> struct GtkProgressBar; GtkWidget * gtk_progress_bar_new (void
); void gtk_progress_bar_pulse (GtkProgressBar *pbar
); void gtk_progress_bar_set_fraction (GtkProgressBar *pbar
,gdouble fraction
); gdouble gtk_progress_bar_get_fraction (GtkProgressBar *pbar
); void gtk_progress_bar_set_inverted (GtkProgressBar *pbar
,gboolean inverted
); gboolean gtk_progress_bar_get_inverted (GtkProgressBar *pbar
); void gtk_progress_bar_set_show_text (GtkProgressBar *pbar
,gboolean show_text
); gboolean gtk_progress_bar_get_show_text (GtkProgressBar *pbar
); void gtk_progress_bar_set_text (GtkProgressBar *pbar
,const gchar *text
); const gchar * gtk_progress_bar_get_text (GtkProgressBar *pbar
); void gtk_progress_bar_set_ellipsize (GtkProgressBar *pbar
,PangoEllipsizeMode mode
); PangoEllipsizeMode gtk_progress_bar_get_ellipsize (GtkProgressBar *pbar
); void gtk_progress_bar_set_pulse_step (GtkProgressBar *pbar
,gdouble fraction
); gdouble gtk_progress_bar_get_pulse_step (GtkProgressBar *pbar
);
GtkProgressBar implements AtkImplementorIface, GtkBuildable and GtkOrientable.
"ellipsize" PangoEllipsizeMode : Read / Write "fraction" gdouble : Read / Write "inverted" gboolean : Read / Write "pulse-step" gdouble : Read / Write "show-text" gboolean : Read / Write "text" gchar* : Read / Write
"min-horizontal-bar-height" gint : Read / Write "min-horizontal-bar-width" gint : Read / Write "min-vertical-bar-height" gint : Read / Write "min-vertical-bar-width" gint : Read / Write "xspacing" gint : Read / Write "yspacing" gint : Read / Write
The GtkProgressBar is typically used to display the progress of a long running operation. It provides a visual clue that processing is underway. The 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
gtk_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 gtk_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.
GtkWidget * gtk_progress_bar_new (void
);
Creates a new GtkProgressBar.
Returns : |
a GtkProgressBar. |
void gtk_progress_bar_pulse (GtkProgressBar *pbar
);
Indicates that some progress is 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 gtk_progress_bar_pulse()
causes the block to move by a little bit (the amount of movement
per pulse is determined by gtk_progress_bar_set_pulse_step()
).
|
a GtkProgressBar |
void gtk_progress_bar_set_fraction (GtkProgressBar *pbar
,gdouble 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.
|
a GtkProgressBar |
|
fraction of the task that's been completed |
gdouble gtk_progress_bar_get_fraction (GtkProgressBar *pbar
);
Returns the current fraction of the task that's been completed.
|
a GtkProgressBar |
Returns : |
a fraction from 0.0 to 1.0 |
void gtk_progress_bar_set_inverted (GtkProgressBar *pbar
,gboolean inverted
);
Progress bars normally grow from top to bottom or left to right. Inverted progress bars grow in the opposite direction.
|
a GtkProgressBar |
|
TRUE to invert the progress bar |
gboolean gtk_progress_bar_get_inverted (GtkProgressBar *pbar
);
Gets the value set by gtk_progress_bar_set_inverted()
|
a GtkProgressBar |
Returns : |
TRUE if the progress bar is inverted |
void gtk_progress_bar_set_show_text (GtkProgressBar *pbar
,gboolean show_text
);
Sets whether the progressbar will show text superimposed
over the bar. The shown text is either the value of
the "text" property or, if that is NULL
,
the "fraction" value, as a percentage.
|
a GtkProgressBar |
|
whether to show superimposed text |
Since 3.0
gboolean gtk_progress_bar_get_show_text (GtkProgressBar *pbar
);
Gets the value of the "show-text" property.
See gtk_progress_bar_set_show_text()
.
|
a GtkProgressBar |
Returns : |
TRUE if text is shown in the progress bar |
Since 3.0
void gtk_progress_bar_set_text (GtkProgressBar *pbar
,const gchar *text
);
Causes the given text
to appear superimposed on the progress bar.
|
a GtkProgressBar |
|
a UTF-8 string, or NULL . [allow-none]
|
const gchar * gtk_progress_bar_get_text (GtkProgressBar *pbar
);
Retrieves the text displayed superimposed on the progress bar,
if any, otherwise NULL
. 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.
|
a GtkProgressBar |
Returns : |
text, or NULL ; this string is owned by the widget
and should not be modified or freed. |
void gtk_progress_bar_set_ellipsize (GtkProgressBar *pbar
,PangoEllipsizeMode mode
);
Sets the mode used to ellipsize (add an ellipsis: "...") the text if there is not enough space to render the entire string.
|
a GtkProgressBar |
|
a PangoEllipsizeMode |
Since 2.6
PangoEllipsizeMode gtk_progress_bar_get_ellipsize (GtkProgressBar *pbar
);
Returns the ellipsizing position of the progressbar.
See gtk_progress_bar_set_ellipsize()
.
|
a GtkProgressBar |
Returns : |
PangoEllipsizeMode |
Since 2.6
void gtk_progress_bar_set_pulse_step (GtkProgressBar *pbar
,gdouble fraction
);
Sets the fraction of total progress bar length to move the
bouncing block for each call to gtk_progress_bar_pulse()
.
|
a GtkProgressBar |
|
fraction between 0.0 and 1.0 |
gdouble gtk_progress_bar_get_pulse_step (GtkProgressBar *pbar
);
Retrieves the pulse step set with gtk_progress_bar_set_pulse_step()
|
a GtkProgressBar |
Returns : |
a fraction from 0.0 to 1.0 |
"ellipsize"
property"ellipsize" PangoEllipsizeMode : Read / Write
The preferred place to ellipsize the string, if the progressbar does not have enough room to display the entire string, specified as a PangoEllisizeMode.
Note that setting this property to a value other than
PANGO_ELLIPSIZE_NONE
has the side-effect that the progressbar requests
only enough space to display the ellipsis "...". Another means to set a
progressbar's width is gtk_widget_set_size_request()
.
Default value: PANGO_ELLIPSIZE_NONE
Since 2.6
"fraction"
property"fraction" gdouble : Read / Write
The fraction of total work that has been completed.
Allowed values: [0,1]
Default value: 0
"inverted"
property"inverted" gboolean : Read / Write
Invert the direction in which the progress bar grows.
Default value: FALSE
"pulse-step"
property"pulse-step" gdouble : Read / Write
The fraction of total progress to move the bouncing block when pulsed.
Allowed values: [0,1]
Default value: 0.1
"show-text"
property"show-text" gboolean : Read / Write
Whether the progress is shown as text.
Default value: FALSE
"text"
property"text" gchar* : Read / Write
Text to be displayed in the progress bar.
Default value: NULL
"min-horizontal-bar-height"
style property"min-horizontal-bar-height" gint : Read / Write
Minimum horizontal height of the progress bar.
Allowed values: >= 1
Default value: 20
Since 2.14
"min-horizontal-bar-width"
style property"min-horizontal-bar-width" gint : Read / Write
The minimum horizontal width of the progress bar.
Allowed values: >= 1
Default value: 150
Since 2.14
"min-vertical-bar-height"
style property"min-vertical-bar-height" gint : Read / Write
The minimum vertical height of the progress bar.
Allowed values: >= 1
Default value: 80
Since 2.14
"min-vertical-bar-width"
style property"min-vertical-bar-width" gint : Read / Write
The minimum vertical width of the progress bar.
Allowed values: >= 1
Default value: 22
Since 2.14
"xspacing"
style property"xspacing" gint : Read / Write
Extra spacing applied to the width of a progress bar.
Allowed values: >= 0
Default value: 7
"yspacing"
style property"yspacing" gint : Read / Write
Extra spacing applied to the height of a progress bar.
Allowed values: >= 0
Default value: 7