gtk4/auto/
progress_bar.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5#[cfg(feature = "v4_10")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
7use crate::AccessibleRange;
8use crate::{
9    ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Orientable,
10    Orientation, Overflow, Widget,
11};
12use glib::{
13    prelude::*,
14    signal::{connect_raw, SignalHandlerId},
15    translate::*,
16};
17use std::boxed::Box as Box_;
18
19#[cfg(feature = "v4_10")]
20#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
21glib::wrapper! {
22    /// [`ProgressBar`][crate::ProgressBar] is typically used to display the progress of a long
23    /// running operation.
24    ///
25    /// It provides a visual clue that processing is underway. [`ProgressBar`][crate::ProgressBar]
26    /// can be used in two different modes: percentage mode and activity mode.
27    ///
28    /// ![An example GtkProgressBar](progressbar.png)
29    ///
30    /// When an application can determine how much work needs to take place
31    /// (e.g. read a fixed number of bytes from a file) and can monitor its
32    /// progress, it can use the [`ProgressBar`][crate::ProgressBar] in percentage mode and the
33    /// user sees a growing bar indicating the percentage of the work that
34    /// has been completed. In this mode, the application is required to call
35    /// [`set_fraction()`][Self::set_fraction()] periodically to update the progress bar.
36    ///
37    /// When an application has no accurate way of knowing the amount of work
38    /// to do, it can use the [`ProgressBar`][crate::ProgressBar] in activity mode, which shows
39    /// activity by a block moving back and forth within the progress area. In
40    /// this mode, the application is required to call [`pulse()`][Self::pulse()]
41    /// periodically to update the progress bar.
42    ///
43    /// There is quite a bit of flexibility provided to control the appearance
44    /// of the [`ProgressBar`][crate::ProgressBar]. Functions are provided to control the orientation
45    /// of the bar, optional text can be displayed along with the bar, and the
46    /// step size used in activity mode can be set.
47    ///
48    /// # CSS nodes
49    ///
50    /// ```text
51    /// progressbar[.osd]
52    /// ├── [text]
53    /// ╰── trough[.empty][.full]
54    ///     ╰── progress[.pulse]
55    /// ```
56    ///
57    /// [`ProgressBar`][crate::ProgressBar] has a main CSS node with name progressbar and subnodes with
58    /// names text and trough, of which the latter has a subnode named progress. The
59    /// text subnode is only present if text is shown. The progress subnode has the
60    /// style class .pulse when in activity mode. It gets the style classes .left,
61    /// .right, .top or .bottom added when the progress 'touches' the corresponding
62    /// end of the GtkProgressBar. The .osd class on the progressbar node is for use
63    /// in overlays like the one Epiphany has for page loading progress.
64    ///
65    /// # Accessibility
66    ///
67    /// [`ProgressBar`][crate::ProgressBar] uses the [`AccessibleRole::ProgressBar`][crate::AccessibleRole::ProgressBar] role.
68    ///
69    /// ## Properties
70    ///
71    ///
72    /// #### `ellipsize`
73    ///  The preferred place to ellipsize the string.
74    ///
75    /// The text will be ellipsized if the progress bar does not have enough room
76    /// to display the entire string, specified as a [`pango::EllipsizeMode`][crate::pango::EllipsizeMode].
77    ///
78    /// Note that setting this property to a value other than
79    /// [`pango::EllipsizeMode::None`][crate::pango::EllipsizeMode::None] has the side-effect that the progress bar requests
80    /// only enough space to display the ellipsis ("..."). Another means to set a
81    /// progress bar's width is [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()].
82    ///
83    /// Readable | Writeable
84    ///
85    ///
86    /// #### `fraction`
87    ///  The fraction of total work that has been completed.
88    ///
89    /// Readable | Writeable
90    ///
91    ///
92    /// #### `inverted`
93    ///  Invert the direction in which the progress bar grows.
94    ///
95    /// Readable | Writeable
96    ///
97    ///
98    /// #### `pulse-step`
99    ///  The fraction of total progress to move the bounding block when pulsed.
100    ///
101    /// Readable | Writeable
102    ///
103    ///
104    /// #### `show-text`
105    ///  Sets whether the progress bar will show a text in addition
106    /// to the bar itself.
107    ///
108    /// The shown text is either the value of the [`text`][struct@crate::ProgressBar#text]
109    /// property or, if that is [`None`], the [`fraction`][struct@crate::ProgressBar#fraction]
110    /// value, as a percentage.
111    ///
112    /// To make a progress bar that is styled and sized suitably for showing text
113    /// (even if the actual text is blank), set [`show-text`][struct@crate::ProgressBar#show-text]
114    /// to [`true`] and [`text`][struct@crate::ProgressBar#text] to the empty string (not [`None`]).
115    ///
116    /// Readable | Writeable
117    ///
118    ///
119    /// #### `text`
120    ///  Text to be displayed in the progress bar.
121    ///
122    /// Readable | Writeable
123    /// <details><summary><h4>Widget</h4></summary>
124    ///
125    ///
126    /// #### `can-focus`
127    ///  Whether the widget or any of its descendents can accept
128    /// the input focus.
129    ///
130    /// This property is meant to be set by widget implementations,
131    /// typically in their instance init function.
132    ///
133    /// Readable | Writeable
134    ///
135    ///
136    /// #### `can-target`
137    ///  Whether the widget can receive pointer events.
138    ///
139    /// Readable | Writeable
140    ///
141    ///
142    /// #### `css-classes`
143    ///  A list of css classes applied to this widget.
144    ///
145    /// Readable | Writeable
146    ///
147    ///
148    /// #### `css-name`
149    ///  The name of this widget in the CSS tree.
150    ///
151    /// This property is meant to be set by widget implementations,
152    /// typically in their instance init function.
153    ///
154    /// Readable | Writeable | Construct Only
155    ///
156    ///
157    /// #### `cursor`
158    ///  The cursor used by @widget.
159    ///
160    /// Readable | Writeable
161    ///
162    ///
163    /// #### `focus-on-click`
164    ///  Whether the widget should grab focus when it is clicked with the mouse.
165    ///
166    /// This property is only relevant for widgets that can take focus.
167    ///
168    /// Readable | Writeable
169    ///
170    ///
171    /// #### `focusable`
172    ///  Whether this widget itself will accept the input focus.
173    ///
174    /// Readable | Writeable
175    ///
176    ///
177    /// #### `halign`
178    ///  How to distribute horizontal space if widget gets extra space.
179    ///
180    /// Readable | Writeable
181    ///
182    ///
183    /// #### `has-default`
184    ///  Whether the widget is the default widget.
185    ///
186    /// Readable
187    ///
188    ///
189    /// #### `has-focus`
190    ///  Whether the widget has the input focus.
191    ///
192    /// Readable
193    ///
194    ///
195    /// #### `has-tooltip`
196    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
197    /// signal on @widget.
198    ///
199    /// A true value indicates that @widget can have a tooltip, in this case
200    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
201    /// determine whether it will provide a tooltip or not.
202    ///
203    /// Readable | Writeable
204    ///
205    ///
206    /// #### `height-request`
207    ///  Overrides for height request of the widget.
208    ///
209    /// If this is -1, the natural request will be used.
210    ///
211    /// Readable | Writeable
212    ///
213    ///
214    /// #### `hexpand`
215    ///  Whether to expand horizontally.
216    ///
217    /// Readable | Writeable
218    ///
219    ///
220    /// #### `hexpand-set`
221    ///  Whether to use the `hexpand` property.
222    ///
223    /// Readable | Writeable
224    ///
225    ///
226    /// #### `layout-manager`
227    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
228    /// the preferred size of the widget, and allocate its children.
229    ///
230    /// This property is meant to be set by widget implementations,
231    /// typically in their instance init function.
232    ///
233    /// Readable | Writeable
234    ///
235    ///
236    /// #### `limit-events`
237    ///  Makes this widget act like a modal dialog, with respect to
238    /// event delivery.
239    ///
240    /// Global event controllers will not handle events with targets
241    /// inside the widget, unless they are set up to ignore propagation
242    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
243    ///
244    /// Readable | Writeable
245    ///
246    ///
247    /// #### `margin-bottom`
248    ///  Margin on bottom side of widget.
249    ///
250    /// This property adds margin outside of the widget's normal size
251    /// request, the margin will be added in addition to the size from
252    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
253    ///
254    /// Readable | Writeable
255    ///
256    ///
257    /// #### `margin-end`
258    ///  Margin on end of widget, horizontally.
259    ///
260    /// This property supports left-to-right and right-to-left text
261    /// directions.
262    ///
263    /// This property adds margin outside of the widget's normal size
264    /// request, the margin will be added in addition to the size from
265    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
266    ///
267    /// Readable | Writeable
268    ///
269    ///
270    /// #### `margin-start`
271    ///  Margin on start of widget, horizontally.
272    ///
273    /// This property supports left-to-right and right-to-left text
274    /// directions.
275    ///
276    /// This property adds margin outside of the widget's normal size
277    /// request, the margin will be added in addition to the size from
278    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
279    ///
280    /// Readable | Writeable
281    ///
282    ///
283    /// #### `margin-top`
284    ///  Margin on top side of widget.
285    ///
286    /// This property adds margin outside of the widget's normal size
287    /// request, the margin will be added in addition to the size from
288    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
289    ///
290    /// Readable | Writeable
291    ///
292    ///
293    /// #### `name`
294    ///  The name of the widget.
295    ///
296    /// Readable | Writeable
297    ///
298    ///
299    /// #### `opacity`
300    ///  The requested opacity of the widget.
301    ///
302    /// Readable | Writeable
303    ///
304    ///
305    /// #### `overflow`
306    ///  How content outside the widget's content area is treated.
307    ///
308    /// This property is meant to be set by widget implementations,
309    /// typically in their instance init function.
310    ///
311    /// Readable | Writeable
312    ///
313    ///
314    /// #### `parent`
315    ///  The parent widget of this widget.
316    ///
317    /// Readable
318    ///
319    ///
320    /// #### `receives-default`
321    ///  Whether the widget will receive the default action when it is focused.
322    ///
323    /// Readable | Writeable
324    ///
325    ///
326    /// #### `root`
327    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
328    ///
329    /// This will be `NULL` if the widget is not contained in a root widget.
330    ///
331    /// Readable
332    ///
333    ///
334    /// #### `scale-factor`
335    ///  The scale factor of the widget.
336    ///
337    /// Readable
338    ///
339    ///
340    /// #### `sensitive`
341    ///  Whether the widget responds to input.
342    ///
343    /// Readable | Writeable
344    ///
345    ///
346    /// #### `tooltip-markup`
347    ///  Sets the text of tooltip to be the given string, which is marked up
348    /// with Pango markup.
349    ///
350    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
351    ///
352    /// This is a convenience property which will take care of getting the
353    /// tooltip shown if the given string is not `NULL`:
354    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
355    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
356    /// the default signal handler.
357    ///
358    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
359    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
360    ///
361    /// Readable | Writeable
362    ///
363    ///
364    /// #### `tooltip-text`
365    ///  Sets the text of tooltip to be the given string.
366    ///
367    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
368    ///
369    /// This is a convenience property which will take care of getting the
370    /// tooltip shown if the given string is not `NULL`:
371    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
372    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
373    /// the default signal handler.
374    ///
375    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
376    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
377    ///
378    /// Readable | Writeable
379    ///
380    ///
381    /// #### `valign`
382    ///  How to distribute vertical space if widget gets extra space.
383    ///
384    /// Readable | Writeable
385    ///
386    ///
387    /// #### `vexpand`
388    ///  Whether to expand vertically.
389    ///
390    /// Readable | Writeable
391    ///
392    ///
393    /// #### `vexpand-set`
394    ///  Whether to use the `vexpand` property.
395    ///
396    /// Readable | Writeable
397    ///
398    ///
399    /// #### `visible`
400    ///  Whether the widget is visible.
401    ///
402    /// Readable | Writeable
403    ///
404    ///
405    /// #### `width-request`
406    ///  Overrides for width request of the widget.
407    ///
408    /// If this is -1, the natural request will be used.
409    ///
410    /// Readable | Writeable
411    /// </details>
412    /// <details><summary><h4>Accessible</h4></summary>
413    ///
414    ///
415    /// #### `accessible-role`
416    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
417    ///
418    /// The accessible role cannot be changed once set.
419    ///
420    /// Readable | Writeable
421    /// </details>
422    /// <details><summary><h4>Orientable</h4></summary>
423    ///
424    ///
425    /// #### `orientation`
426    ///  The orientation of the orientable.
427    ///
428    /// Readable | Writeable
429    /// </details>
430    ///
431    /// # Implements
432    ///
433    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`AccessibleRangeExt`][trait@crate::prelude::AccessibleRangeExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
434    #[doc(alias = "GtkProgressBar")]
435    pub struct ProgressBar(Object<ffi::GtkProgressBar>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, AccessibleRange, Orientable;
436
437    match fn {
438        type_ => || ffi::gtk_progress_bar_get_type(),
439    }
440}
441
442#[cfg(not(any(feature = "v4_10")))]
443glib::wrapper! {
444    #[doc(alias = "GtkProgressBar")]
445    pub struct ProgressBar(Object<ffi::GtkProgressBar>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable;
446
447    match fn {
448        type_ => || ffi::gtk_progress_bar_get_type(),
449    }
450}
451
452impl ProgressBar {
453    /// Creates a new [`ProgressBar`][crate::ProgressBar].
454    ///
455    /// # Returns
456    ///
457    /// a [`ProgressBar`][crate::ProgressBar].
458    #[doc(alias = "gtk_progress_bar_new")]
459    pub fn new() -> ProgressBar {
460        assert_initialized_main_thread!();
461        unsafe { Widget::from_glib_none(ffi::gtk_progress_bar_new()).unsafe_cast() }
462    }
463
464    // rustdoc-stripper-ignore-next
465    /// Creates a new builder-pattern struct instance to construct [`ProgressBar`] objects.
466    ///
467    /// This method returns an instance of [`ProgressBarBuilder`](crate::builders::ProgressBarBuilder) which can be used to create [`ProgressBar`] objects.
468    pub fn builder() -> ProgressBarBuilder {
469        ProgressBarBuilder::new()
470    }
471
472    /// Returns the ellipsizing position of the progress bar.
473    ///
474    /// See [`set_ellipsize()`][Self::set_ellipsize()].
475    ///
476    /// # Returns
477    ///
478    /// [`pango::EllipsizeMode`][crate::pango::EllipsizeMode]
479    #[doc(alias = "gtk_progress_bar_get_ellipsize")]
480    #[doc(alias = "get_ellipsize")]
481    pub fn ellipsize(&self) -> pango::EllipsizeMode {
482        unsafe { from_glib(ffi::gtk_progress_bar_get_ellipsize(self.to_glib_none().0)) }
483    }
484
485    /// Returns the current fraction of the task that’s been completed.
486    ///
487    /// # Returns
488    ///
489    /// a fraction from 0.0 to 1.0
490    #[doc(alias = "gtk_progress_bar_get_fraction")]
491    #[doc(alias = "get_fraction")]
492    pub fn fraction(&self) -> f64 {
493        unsafe { ffi::gtk_progress_bar_get_fraction(self.to_glib_none().0) }
494    }
495
496    /// Returns whether the progress bar is inverted.
497    ///
498    /// # Returns
499    ///
500    /// [`true`] if the progress bar is inverted
501    #[doc(alias = "gtk_progress_bar_get_inverted")]
502    #[doc(alias = "get_inverted")]
503    #[doc(alias = "inverted")]
504    pub fn is_inverted(&self) -> bool {
505        unsafe { from_glib(ffi::gtk_progress_bar_get_inverted(self.to_glib_none().0)) }
506    }
507
508    /// Retrieves the pulse step.
509    ///
510    /// See [`set_pulse_step()`][Self::set_pulse_step()].
511    ///
512    /// # Returns
513    ///
514    /// a fraction from 0.0 to 1.0
515    #[doc(alias = "gtk_progress_bar_get_pulse_step")]
516    #[doc(alias = "get_pulse_step")]
517    #[doc(alias = "pulse-step")]
518    pub fn pulse_step(&self) -> f64 {
519        unsafe { ffi::gtk_progress_bar_get_pulse_step(self.to_glib_none().0) }
520    }
521
522    /// Returns whether the [`ProgressBar`][crate::ProgressBar] shows text.
523    ///
524    /// See [`set_show_text()`][Self::set_show_text()].
525    ///
526    /// # Returns
527    ///
528    /// [`true`] if text is shown in the progress bar
529    #[doc(alias = "gtk_progress_bar_get_show_text")]
530    #[doc(alias = "get_show_text")]
531    #[doc(alias = "show-text")]
532    pub fn shows_text(&self) -> bool {
533        unsafe { from_glib(ffi::gtk_progress_bar_get_show_text(self.to_glib_none().0)) }
534    }
535
536    /// Retrieves the text that is displayed with the progress bar.
537    ///
538    /// The return value is a reference to the text, not a copy of it,
539    /// so will become invalid if you change the text in the progress bar.
540    ///
541    /// # Returns
542    ///
543    /// the text
544    #[doc(alias = "gtk_progress_bar_get_text")]
545    #[doc(alias = "get_text")]
546    pub fn text(&self) -> Option<glib::GString> {
547        unsafe { from_glib_none(ffi::gtk_progress_bar_get_text(self.to_glib_none().0)) }
548    }
549
550    /// Indicates that some progress has been made, but you don’t know how much.
551    ///
552    /// Causes the progress bar to enter “activity mode,” where a block
553    /// bounces back and forth. Each call to [`pulse()`][Self::pulse()]
554    /// causes the block to move by a little bit (the amount of movement
555    /// per pulse is determined by [`set_pulse_step()`][Self::set_pulse_step()]).
556    #[doc(alias = "gtk_progress_bar_pulse")]
557    pub fn pulse(&self) {
558        unsafe {
559            ffi::gtk_progress_bar_pulse(self.to_glib_none().0);
560        }
561    }
562
563    /// Sets the mode used to ellipsize the text.
564    ///
565    /// The text is ellipsized if there is not enough space
566    /// to render the entire string.
567    /// ## `mode`
568    /// a [`pango::EllipsizeMode`][crate::pango::EllipsizeMode]
569    #[doc(alias = "gtk_progress_bar_set_ellipsize")]
570    #[doc(alias = "ellipsize")]
571    pub fn set_ellipsize(&self, mode: pango::EllipsizeMode) {
572        unsafe {
573            ffi::gtk_progress_bar_set_ellipsize(self.to_glib_none().0, mode.into_glib());
574        }
575    }
576
577    /// Causes the progress bar to “fill in” the given fraction
578    /// of the bar.
579    ///
580    /// The fraction should be between 0.0 and 1.0, inclusive.
581    /// ## `fraction`
582    /// fraction of the task that’s been completed
583    #[doc(alias = "gtk_progress_bar_set_fraction")]
584    #[doc(alias = "fraction")]
585    pub fn set_fraction(&self, fraction: f64) {
586        unsafe {
587            ffi::gtk_progress_bar_set_fraction(self.to_glib_none().0, fraction);
588        }
589    }
590
591    /// Sets whether the progress bar is inverted.
592    ///
593    /// Progress bars normally grow from top to bottom or left to right.
594    /// Inverted progress bars grow in the opposite direction.
595    /// ## `inverted`
596    /// [`true`] to invert the progress bar
597    #[doc(alias = "gtk_progress_bar_set_inverted")]
598    #[doc(alias = "inverted")]
599    pub fn set_inverted(&self, inverted: bool) {
600        unsafe {
601            ffi::gtk_progress_bar_set_inverted(self.to_glib_none().0, inverted.into_glib());
602        }
603    }
604
605    /// Sets the fraction of total progress bar length to move the
606    /// bouncing block.
607    ///
608    /// The bouncing block is moved when [`pulse()`][Self::pulse()]
609    /// is called.
610    /// ## `fraction`
611    /// fraction between 0.0 and 1.0
612    #[doc(alias = "gtk_progress_bar_set_pulse_step")]
613    #[doc(alias = "pulse-step")]
614    pub fn set_pulse_step(&self, fraction: f64) {
615        unsafe {
616            ffi::gtk_progress_bar_set_pulse_step(self.to_glib_none().0, fraction);
617        }
618    }
619
620    /// Sets whether the progress bar will show text next to the bar.
621    ///
622    /// The shown text is either the value of the [`text`][struct@crate::ProgressBar#text]
623    /// property or, if that is [`None`], the [`fraction`][struct@crate::ProgressBar#fraction] value,
624    /// as a percentage.
625    ///
626    /// To make a progress bar that is styled and sized suitably for containing
627    /// text (even if the actual text is blank), set [`show-text`][struct@crate::ProgressBar#show-text]
628    /// to [`true`] and [`text`][struct@crate::ProgressBar#text] to the empty string (not [`None`]).
629    /// ## `show_text`
630    /// whether to show text
631    #[doc(alias = "gtk_progress_bar_set_show_text")]
632    #[doc(alias = "show-text")]
633    pub fn set_show_text(&self, show_text: bool) {
634        unsafe {
635            ffi::gtk_progress_bar_set_show_text(self.to_glib_none().0, show_text.into_glib());
636        }
637    }
638
639    /// Causes the given @text to appear next to the progress bar.
640    ///
641    /// If @text is [`None`] and [`show-text`][struct@crate::ProgressBar#show-text] is [`true`],
642    /// the current value of [`fraction`][struct@crate::ProgressBar#fraction] will be displayed
643    /// as a percentage.
644    ///
645    /// If @text is non-[`None`] and [`show-text`][struct@crate::ProgressBar#show-text] is [`true`],
646    /// the text will be displayed. In this case, it will not display the progress
647    /// percentage. If @text is the empty string, the progress bar will still
648    /// be styled and sized suitably for containing text, as long as
649    /// [`show-text`][struct@crate::ProgressBar#show-text] is [`true`].
650    /// ## `text`
651    /// a UTF-8 string
652    #[doc(alias = "gtk_progress_bar_set_text")]
653    #[doc(alias = "text")]
654    pub fn set_text(&self, text: Option<&str>) {
655        unsafe {
656            ffi::gtk_progress_bar_set_text(self.to_glib_none().0, text.to_glib_none().0);
657        }
658    }
659
660    #[doc(alias = "ellipsize")]
661    pub fn connect_ellipsize_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
662        unsafe extern "C" fn notify_ellipsize_trampoline<F: Fn(&ProgressBar) + 'static>(
663            this: *mut ffi::GtkProgressBar,
664            _param_spec: glib::ffi::gpointer,
665            f: glib::ffi::gpointer,
666        ) {
667            let f: &F = &*(f as *const F);
668            f(&from_glib_borrow(this))
669        }
670        unsafe {
671            let f: Box_<F> = Box_::new(f);
672            connect_raw(
673                self.as_ptr() as *mut _,
674                b"notify::ellipsize\0".as_ptr() as *const _,
675                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
676                    notify_ellipsize_trampoline::<F> as *const (),
677                )),
678                Box_::into_raw(f),
679            )
680        }
681    }
682
683    #[doc(alias = "fraction")]
684    pub fn connect_fraction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
685        unsafe extern "C" fn notify_fraction_trampoline<F: Fn(&ProgressBar) + 'static>(
686            this: *mut ffi::GtkProgressBar,
687            _param_spec: glib::ffi::gpointer,
688            f: glib::ffi::gpointer,
689        ) {
690            let f: &F = &*(f as *const F);
691            f(&from_glib_borrow(this))
692        }
693        unsafe {
694            let f: Box_<F> = Box_::new(f);
695            connect_raw(
696                self.as_ptr() as *mut _,
697                b"notify::fraction\0".as_ptr() as *const _,
698                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
699                    notify_fraction_trampoline::<F> as *const (),
700                )),
701                Box_::into_raw(f),
702            )
703        }
704    }
705
706    #[doc(alias = "inverted")]
707    pub fn connect_inverted_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
708        unsafe extern "C" fn notify_inverted_trampoline<F: Fn(&ProgressBar) + 'static>(
709            this: *mut ffi::GtkProgressBar,
710            _param_spec: glib::ffi::gpointer,
711            f: glib::ffi::gpointer,
712        ) {
713            let f: &F = &*(f as *const F);
714            f(&from_glib_borrow(this))
715        }
716        unsafe {
717            let f: Box_<F> = Box_::new(f);
718            connect_raw(
719                self.as_ptr() as *mut _,
720                b"notify::inverted\0".as_ptr() as *const _,
721                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
722                    notify_inverted_trampoline::<F> as *const (),
723                )),
724                Box_::into_raw(f),
725            )
726        }
727    }
728
729    #[doc(alias = "pulse-step")]
730    pub fn connect_pulse_step_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
731        unsafe extern "C" fn notify_pulse_step_trampoline<F: Fn(&ProgressBar) + 'static>(
732            this: *mut ffi::GtkProgressBar,
733            _param_spec: glib::ffi::gpointer,
734            f: glib::ffi::gpointer,
735        ) {
736            let f: &F = &*(f as *const F);
737            f(&from_glib_borrow(this))
738        }
739        unsafe {
740            let f: Box_<F> = Box_::new(f);
741            connect_raw(
742                self.as_ptr() as *mut _,
743                b"notify::pulse-step\0".as_ptr() as *const _,
744                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
745                    notify_pulse_step_trampoline::<F> as *const (),
746                )),
747                Box_::into_raw(f),
748            )
749        }
750    }
751
752    #[doc(alias = "show-text")]
753    pub fn connect_show_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
754        unsafe extern "C" fn notify_show_text_trampoline<F: Fn(&ProgressBar) + 'static>(
755            this: *mut ffi::GtkProgressBar,
756            _param_spec: glib::ffi::gpointer,
757            f: glib::ffi::gpointer,
758        ) {
759            let f: &F = &*(f as *const F);
760            f(&from_glib_borrow(this))
761        }
762        unsafe {
763            let f: Box_<F> = Box_::new(f);
764            connect_raw(
765                self.as_ptr() as *mut _,
766                b"notify::show-text\0".as_ptr() as *const _,
767                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
768                    notify_show_text_trampoline::<F> as *const (),
769                )),
770                Box_::into_raw(f),
771            )
772        }
773    }
774
775    #[doc(alias = "text")]
776    pub fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
777        unsafe extern "C" fn notify_text_trampoline<F: Fn(&ProgressBar) + 'static>(
778            this: *mut ffi::GtkProgressBar,
779            _param_spec: glib::ffi::gpointer,
780            f: glib::ffi::gpointer,
781        ) {
782            let f: &F = &*(f as *const F);
783            f(&from_glib_borrow(this))
784        }
785        unsafe {
786            let f: Box_<F> = Box_::new(f);
787            connect_raw(
788                self.as_ptr() as *mut _,
789                b"notify::text\0".as_ptr() as *const _,
790                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
791                    notify_text_trampoline::<F> as *const (),
792                )),
793                Box_::into_raw(f),
794            )
795        }
796    }
797}
798
799impl Default for ProgressBar {
800    fn default() -> Self {
801        Self::new()
802    }
803}
804
805// rustdoc-stripper-ignore-next
806/// A [builder-pattern] type to construct [`ProgressBar`] objects.
807///
808/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
809#[must_use = "The builder must be built to be used"]
810pub struct ProgressBarBuilder {
811    builder: glib::object::ObjectBuilder<'static, ProgressBar>,
812}
813
814impl ProgressBarBuilder {
815    fn new() -> Self {
816        Self {
817            builder: glib::object::Object::builder(),
818        }
819    }
820
821    /// The preferred place to ellipsize the string.
822    ///
823    /// The text will be ellipsized if the progress bar does not have enough room
824    /// to display the entire string, specified as a [`pango::EllipsizeMode`][crate::pango::EllipsizeMode].
825    ///
826    /// Note that setting this property to a value other than
827    /// [`pango::EllipsizeMode::None`][crate::pango::EllipsizeMode::None] has the side-effect that the progress bar requests
828    /// only enough space to display the ellipsis ("..."). Another means to set a
829    /// progress bar's width is [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()].
830    pub fn ellipsize(self, ellipsize: pango::EllipsizeMode) -> Self {
831        Self {
832            builder: self.builder.property("ellipsize", ellipsize),
833        }
834    }
835
836    /// The fraction of total work that has been completed.
837    pub fn fraction(self, fraction: f64) -> Self {
838        Self {
839            builder: self.builder.property("fraction", fraction),
840        }
841    }
842
843    /// Invert the direction in which the progress bar grows.
844    pub fn inverted(self, inverted: bool) -> Self {
845        Self {
846            builder: self.builder.property("inverted", inverted),
847        }
848    }
849
850    /// The fraction of total progress to move the bounding block when pulsed.
851    pub fn pulse_step(self, pulse_step: f64) -> Self {
852        Self {
853            builder: self.builder.property("pulse-step", pulse_step),
854        }
855    }
856
857    /// Sets whether the progress bar will show a text in addition
858    /// to the bar itself.
859    ///
860    /// The shown text is either the value of the [`text`][struct@crate::ProgressBar#text]
861    /// property or, if that is [`None`], the [`fraction`][struct@crate::ProgressBar#fraction]
862    /// value, as a percentage.
863    ///
864    /// To make a progress bar that is styled and sized suitably for showing text
865    /// (even if the actual text is blank), set [`show-text`][struct@crate::ProgressBar#show-text]
866    /// to [`true`] and [`text`][struct@crate::ProgressBar#text] to the empty string (not [`None`]).
867    pub fn show_text(self, show_text: bool) -> Self {
868        Self {
869            builder: self.builder.property("show-text", show_text),
870        }
871    }
872
873    /// Text to be displayed in the progress bar.
874    pub fn text(self, text: impl Into<glib::GString>) -> Self {
875        Self {
876            builder: self.builder.property("text", text.into()),
877        }
878    }
879
880    /// Whether the widget or any of its descendents can accept
881    /// the input focus.
882    ///
883    /// This property is meant to be set by widget implementations,
884    /// typically in their instance init function.
885    pub fn can_focus(self, can_focus: bool) -> Self {
886        Self {
887            builder: self.builder.property("can-focus", can_focus),
888        }
889    }
890
891    /// Whether the widget can receive pointer events.
892    pub fn can_target(self, can_target: bool) -> Self {
893        Self {
894            builder: self.builder.property("can-target", can_target),
895        }
896    }
897
898    /// A list of css classes applied to this widget.
899    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
900        Self {
901            builder: self.builder.property("css-classes", css_classes.into()),
902        }
903    }
904
905    /// The name of this widget in the CSS tree.
906    ///
907    /// This property is meant to be set by widget implementations,
908    /// typically in their instance init function.
909    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
910        Self {
911            builder: self.builder.property("css-name", css_name.into()),
912        }
913    }
914
915    /// The cursor used by @widget.
916    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
917        Self {
918            builder: self.builder.property("cursor", cursor.clone()),
919        }
920    }
921
922    /// Whether the widget should grab focus when it is clicked with the mouse.
923    ///
924    /// This property is only relevant for widgets that can take focus.
925    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
926        Self {
927            builder: self.builder.property("focus-on-click", focus_on_click),
928        }
929    }
930
931    /// Whether this widget itself will accept the input focus.
932    pub fn focusable(self, focusable: bool) -> Self {
933        Self {
934            builder: self.builder.property("focusable", focusable),
935        }
936    }
937
938    /// How to distribute horizontal space if widget gets extra space.
939    pub fn halign(self, halign: Align) -> Self {
940        Self {
941            builder: self.builder.property("halign", halign),
942        }
943    }
944
945    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
946    /// signal on @widget.
947    ///
948    /// A true value indicates that @widget can have a tooltip, in this case
949    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
950    /// determine whether it will provide a tooltip or not.
951    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
952        Self {
953            builder: self.builder.property("has-tooltip", has_tooltip),
954        }
955    }
956
957    /// Overrides for height request of the widget.
958    ///
959    /// If this is -1, the natural request will be used.
960    pub fn height_request(self, height_request: i32) -> Self {
961        Self {
962            builder: self.builder.property("height-request", height_request),
963        }
964    }
965
966    /// Whether to expand horizontally.
967    pub fn hexpand(self, hexpand: bool) -> Self {
968        Self {
969            builder: self.builder.property("hexpand", hexpand),
970        }
971    }
972
973    /// Whether to use the `hexpand` property.
974    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
975        Self {
976            builder: self.builder.property("hexpand-set", hexpand_set),
977        }
978    }
979
980    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
981    /// the preferred size of the widget, and allocate its children.
982    ///
983    /// This property is meant to be set by widget implementations,
984    /// typically in their instance init function.
985    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
986        Self {
987            builder: self
988                .builder
989                .property("layout-manager", layout_manager.clone().upcast()),
990        }
991    }
992
993    /// Makes this widget act like a modal dialog, with respect to
994    /// event delivery.
995    ///
996    /// Global event controllers will not handle events with targets
997    /// inside the widget, unless they are set up to ignore propagation
998    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
999    #[cfg(feature = "v4_18")]
1000    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1001    pub fn limit_events(self, limit_events: bool) -> Self {
1002        Self {
1003            builder: self.builder.property("limit-events", limit_events),
1004        }
1005    }
1006
1007    /// Margin on bottom side of widget.
1008    ///
1009    /// This property adds margin outside of the widget's normal size
1010    /// request, the margin will be added in addition to the size from
1011    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1012    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1013        Self {
1014            builder: self.builder.property("margin-bottom", margin_bottom),
1015        }
1016    }
1017
1018    /// Margin on end of widget, horizontally.
1019    ///
1020    /// This property supports left-to-right and right-to-left text
1021    /// directions.
1022    ///
1023    /// This property adds margin outside of the widget's normal size
1024    /// request, the margin will be added in addition to the size from
1025    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1026    pub fn margin_end(self, margin_end: i32) -> Self {
1027        Self {
1028            builder: self.builder.property("margin-end", margin_end),
1029        }
1030    }
1031
1032    /// Margin on start of widget, horizontally.
1033    ///
1034    /// This property supports left-to-right and right-to-left text
1035    /// directions.
1036    ///
1037    /// This property adds margin outside of the widget's normal size
1038    /// request, the margin will be added in addition to the size from
1039    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1040    pub fn margin_start(self, margin_start: i32) -> Self {
1041        Self {
1042            builder: self.builder.property("margin-start", margin_start),
1043        }
1044    }
1045
1046    /// Margin on top side of widget.
1047    ///
1048    /// This property adds margin outside of the widget's normal size
1049    /// request, the margin will be added in addition to the size from
1050    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1051    pub fn margin_top(self, margin_top: i32) -> Self {
1052        Self {
1053            builder: self.builder.property("margin-top", margin_top),
1054        }
1055    }
1056
1057    /// The name of the widget.
1058    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1059        Self {
1060            builder: self.builder.property("name", name.into()),
1061        }
1062    }
1063
1064    /// The requested opacity of the widget.
1065    pub fn opacity(self, opacity: f64) -> Self {
1066        Self {
1067            builder: self.builder.property("opacity", opacity),
1068        }
1069    }
1070
1071    /// How content outside the widget's content area is treated.
1072    ///
1073    /// This property is meant to be set by widget implementations,
1074    /// typically in their instance init function.
1075    pub fn overflow(self, overflow: Overflow) -> Self {
1076        Self {
1077            builder: self.builder.property("overflow", overflow),
1078        }
1079    }
1080
1081    /// Whether the widget will receive the default action when it is focused.
1082    pub fn receives_default(self, receives_default: bool) -> Self {
1083        Self {
1084            builder: self.builder.property("receives-default", receives_default),
1085        }
1086    }
1087
1088    /// Whether the widget responds to input.
1089    pub fn sensitive(self, sensitive: bool) -> Self {
1090        Self {
1091            builder: self.builder.property("sensitive", sensitive),
1092        }
1093    }
1094
1095    /// Sets the text of tooltip to be the given string, which is marked up
1096    /// with Pango markup.
1097    ///
1098    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1099    ///
1100    /// This is a convenience property which will take care of getting the
1101    /// tooltip shown if the given string is not `NULL`:
1102    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1103    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1104    /// the default signal handler.
1105    ///
1106    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1107    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1108    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1109        Self {
1110            builder: self
1111                .builder
1112                .property("tooltip-markup", tooltip_markup.into()),
1113        }
1114    }
1115
1116    /// Sets the text of tooltip to be the given string.
1117    ///
1118    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1119    ///
1120    /// This is a convenience property which will take care of getting the
1121    /// tooltip shown if the given string is not `NULL`:
1122    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1123    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1124    /// the default signal handler.
1125    ///
1126    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1127    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1128    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1129        Self {
1130            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1131        }
1132    }
1133
1134    /// How to distribute vertical space if widget gets extra space.
1135    pub fn valign(self, valign: Align) -> Self {
1136        Self {
1137            builder: self.builder.property("valign", valign),
1138        }
1139    }
1140
1141    /// Whether to expand vertically.
1142    pub fn vexpand(self, vexpand: bool) -> Self {
1143        Self {
1144            builder: self.builder.property("vexpand", vexpand),
1145        }
1146    }
1147
1148    /// Whether to use the `vexpand` property.
1149    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1150        Self {
1151            builder: self.builder.property("vexpand-set", vexpand_set),
1152        }
1153    }
1154
1155    /// Whether the widget is visible.
1156    pub fn visible(self, visible: bool) -> Self {
1157        Self {
1158            builder: self.builder.property("visible", visible),
1159        }
1160    }
1161
1162    /// Overrides for width request of the widget.
1163    ///
1164    /// If this is -1, the natural request will be used.
1165    pub fn width_request(self, width_request: i32) -> Self {
1166        Self {
1167            builder: self.builder.property("width-request", width_request),
1168        }
1169    }
1170
1171    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1172    ///
1173    /// The accessible role cannot be changed once set.
1174    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1175        Self {
1176            builder: self.builder.property("accessible-role", accessible_role),
1177        }
1178    }
1179
1180    /// The orientation of the orientable.
1181    pub fn orientation(self, orientation: Orientation) -> Self {
1182        Self {
1183            builder: self.builder.property("orientation", orientation),
1184        }
1185    }
1186
1187    // rustdoc-stripper-ignore-next
1188    /// Build the [`ProgressBar`].
1189    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1190    pub fn build(self) -> ProgressBar {
1191        assert_initialized_main_thread!();
1192        self.builder.build()
1193    }
1194}