gtk4/auto/
level_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,
10    LevelBarMode, Orientable, Orientation, Overflow, Widget,
11};
12use glib::{
13    object::ObjectType as _,
14    prelude::*,
15    signal::{connect_raw, SignalHandlerId},
16    translate::*,
17};
18use std::boxed::Box as Box_;
19
20#[cfg(feature = "v4_10")]
21#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
22glib::wrapper! {
23    /// Shows a level indicator.
24    ///
25    /// Typical use cases are displaying the strength of a password, or
26    /// showing the charge level of a battery.
27    ///
28    /// <picture>
29    ///   <source srcset="levelbar-dark.png" media="(prefers-color-scheme: dark)">
30    ///   <img alt="An example GtkLevelBar" src="levelbar.png">
31    /// </picture>
32    ///
33    /// Use [`set_value()`][Self::set_value()] to set the current value, and
34    /// [`add_offset_value()`][Self::add_offset_value()] to set the value offsets at which
35    /// the bar will be considered in a different state. GTK will add a few
36    /// offsets by default on the level bar: [`LEVEL_BAR_OFFSET_LOW`][crate::LEVEL_BAR_OFFSET_LOW],
37    /// [`LEVEL_BAR_OFFSET_HIGH`][crate::LEVEL_BAR_OFFSET_HIGH] and [`LEVEL_BAR_OFFSET_FULL`][crate::LEVEL_BAR_OFFSET_FULL], with
38    /// values 0.25, 0.75 and 1.0 respectively.
39    ///
40    /// Note that it is your responsibility to update preexisting offsets
41    /// when changing the minimum or maximum value. GTK will simply clamp
42    /// them to the new range.
43    ///
44    /// ## Adding a custom offset on the bar
45    ///
46    /// **⚠️ The following code is in c ⚠️**
47    ///
48    /// ```c
49    /// static GtkWidget *
50    /// create_level_bar (void)
51    /// {
52    ///   GtkWidget *widget;
53    ///   GtkLevelBar *bar;
54    ///
55    ///   widget = gtk_level_bar_new ();
56    ///   bar = GTK_LEVEL_BAR (widget);
57    ///
58    ///   // This changes the value of the default low offset
59    ///
60    ///   gtk_level_bar_add_offset_value (bar,
61    ///                                   GTK_LEVEL_BAR_OFFSET_LOW,
62    ///                                   0.10);
63    ///
64    ///   // This adds a new offset to the bar; the application will
65    ///   // be able to change its color CSS like this:
66    ///   //
67    ///   // levelbar block.my-offset {
68    ///   //   background-color: magenta;
69    ///   //   border-style: solid;
70    ///   //   border-color: black;
71    ///   //   border-width: 1px;
72    ///   // }
73    ///
74    ///   gtk_level_bar_add_offset_value (bar, "my-offset", 0.60);
75    ///
76    ///   return widget;
77    /// }
78    /// ```
79    ///
80    /// The default interval of values is between zero and one, but it’s possible
81    /// to modify the interval using [`set_min_value()`][Self::set_min_value()] and
82    /// [`set_max_value()`][Self::set_max_value()]. The value will be always drawn in
83    /// proportion to the admissible interval, i.e. a value of 15 with a specified
84    /// interval between 10 and 20 is equivalent to a value of 0.5 with an interval
85    /// between 0 and 1. When [`LevelBarMode::Discrete`][crate::LevelBarMode::Discrete] is used, the bar level
86    /// is rendered as a finite number of separated blocks instead of a single one.
87    /// The number of blocks that will be rendered is equal to the number of units
88    /// specified by the admissible interval.
89    ///
90    /// For instance, to build a bar rendered with five blocks, it’s sufficient to
91    /// set the minimum value to 0 and the maximum value to 5 after changing the
92    /// indicator mode to discrete.
93    ///
94    /// # GtkLevelBar as GtkBuildable
95    ///
96    /// The [`LevelBar`][crate::LevelBar] implementation of the [`Buildable`][crate::Buildable] interface supports a
97    /// custom `<offsets>` element, which can contain any number of `<offset>` elements,
98    /// each of which must have "name" and "value" attributes.
99    ///
100    /// # CSS nodes
101    ///
102    /// ```text
103    /// levelbar[.discrete]
104    /// ╰── trough
105    ///     ├── block.filled.level-name
106    ///     ┊
107    ///     ├── block.empty
108    ///     ┊
109    /// ```
110    ///
111    /// [`LevelBar`][crate::LevelBar] has a main CSS node with name levelbar and one of the style
112    /// classes .discrete or .continuous and a subnode with name trough. Below the
113    /// trough node are a number of nodes with name block and style class .filled
114    /// or .empty. In continuous mode, there is exactly one node of each, in discrete
115    /// mode, the number of filled and unfilled nodes corresponds to blocks that are
116    /// drawn. The block.filled nodes also get a style class .level-name corresponding
117    /// to the level for the current value.
118    ///
119    /// In horizontal orientation, the nodes are always arranged from left to right,
120    /// regardless of text direction.
121    ///
122    /// # Accessibility
123    ///
124    /// [`LevelBar`][crate::LevelBar] uses the [enum@Gtk.AccessibleRole.meter] role.
125    ///
126    /// ## Properties
127    ///
128    ///
129    /// #### `inverted`
130    ///  Whether the `GtkLeveBar` is inverted.
131    ///
132    /// Level bars normally grow from top to bottom or left to right.
133    /// Inverted level bars grow in the opposite direction.
134    ///
135    /// Readable | Writeable
136    ///
137    ///
138    /// #### `max-value`
139    ///  Determines the maximum value of the interval that can be displayed by the bar.
140    ///
141    /// Readable | Writeable
142    ///
143    ///
144    /// #### `min-value`
145    ///  Determines the minimum value of the interval that can be displayed by the bar.
146    ///
147    /// Readable | Writeable
148    ///
149    ///
150    /// #### `mode`
151    ///  Determines the way [`LevelBar`][crate::LevelBar] interprets the value properties to draw the
152    /// level fill area.
153    ///
154    /// Specifically, when the value is [`LevelBarMode::Continuous`][crate::LevelBarMode::Continuous],
155    /// [`LevelBar`][crate::LevelBar] will draw a single block representing the current value in
156    /// that area; when the value is [`LevelBarMode::Discrete`][crate::LevelBarMode::Discrete],
157    /// the widget will draw a succession of separate blocks filling the
158    /// draw area, with the number of blocks being equal to the units separating
159    /// the integral roundings of [`min-value`][struct@crate::LevelBar#min-value] and
160    /// [`max-value`][struct@crate::LevelBar#max-value].
161    ///
162    /// Readable | Writeable
163    ///
164    ///
165    /// #### `value`
166    ///  Determines the currently filled value of the level bar.
167    ///
168    /// Readable | Writeable
169    /// <details><summary><h4>Widget</h4></summary>
170    ///
171    ///
172    /// #### `can-focus`
173    ///  Whether the widget or any of its descendents can accept
174    /// the input focus.
175    ///
176    /// This property is meant to be set by widget implementations,
177    /// typically in their instance init function.
178    ///
179    /// Readable | Writeable
180    ///
181    ///
182    /// #### `can-target`
183    ///  Whether the widget can receive pointer events.
184    ///
185    /// Readable | Writeable
186    ///
187    ///
188    /// #### `css-classes`
189    ///  A list of css classes applied to this widget.
190    ///
191    /// Readable | Writeable
192    ///
193    ///
194    /// #### `css-name`
195    ///  The name of this widget in the CSS tree.
196    ///
197    /// This property is meant to be set by widget implementations,
198    /// typically in their instance init function.
199    ///
200    /// Readable | Writeable | Construct Only
201    ///
202    ///
203    /// #### `cursor`
204    ///  The cursor used by @widget.
205    ///
206    /// Readable | Writeable
207    ///
208    ///
209    /// #### `focus-on-click`
210    ///  Whether the widget should grab focus when it is clicked with the mouse.
211    ///
212    /// This property is only relevant for widgets that can take focus.
213    ///
214    /// Readable | Writeable
215    ///
216    ///
217    /// #### `focusable`
218    ///  Whether this widget itself will accept the input focus.
219    ///
220    /// Readable | Writeable
221    ///
222    ///
223    /// #### `halign`
224    ///  How to distribute horizontal space if widget gets extra space.
225    ///
226    /// Readable | Writeable
227    ///
228    ///
229    /// #### `has-default`
230    ///  Whether the widget is the default widget.
231    ///
232    /// Readable
233    ///
234    ///
235    /// #### `has-focus`
236    ///  Whether the widget has the input focus.
237    ///
238    /// Readable
239    ///
240    ///
241    /// #### `has-tooltip`
242    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
243    /// signal on @widget.
244    ///
245    /// A true value indicates that @widget can have a tooltip, in this case
246    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
247    /// determine whether it will provide a tooltip or not.
248    ///
249    /// Readable | Writeable
250    ///
251    ///
252    /// #### `height-request`
253    ///  Overrides for height request of the widget.
254    ///
255    /// If this is -1, the natural request will be used.
256    ///
257    /// Readable | Writeable
258    ///
259    ///
260    /// #### `hexpand`
261    ///  Whether to expand horizontally.
262    ///
263    /// Readable | Writeable
264    ///
265    ///
266    /// #### `hexpand-set`
267    ///  Whether to use the `hexpand` property.
268    ///
269    /// Readable | Writeable
270    ///
271    ///
272    /// #### `layout-manager`
273    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
274    /// the preferred size of the widget, and allocate its children.
275    ///
276    /// This property is meant to be set by widget implementations,
277    /// typically in their instance init function.
278    ///
279    /// Readable | Writeable
280    ///
281    ///
282    /// #### `limit-events`
283    ///  Makes this widget act like a modal dialog, with respect to
284    /// event delivery.
285    ///
286    /// Global event controllers will not handle events with targets
287    /// inside the widget, unless they are set up to ignore propagation
288    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
289    ///
290    /// Readable | Writeable
291    ///
292    ///
293    /// #### `margin-bottom`
294    ///  Margin on bottom side of widget.
295    ///
296    /// This property adds margin outside of the widget's normal size
297    /// request, the margin will be added in addition to the size from
298    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
299    ///
300    /// Readable | Writeable
301    ///
302    ///
303    /// #### `margin-end`
304    ///  Margin on end of widget, horizontally.
305    ///
306    /// This property supports left-to-right and right-to-left text
307    /// directions.
308    ///
309    /// This property adds margin outside of the widget's normal size
310    /// request, the margin will be added in addition to the size from
311    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
312    ///
313    /// Readable | Writeable
314    ///
315    ///
316    /// #### `margin-start`
317    ///  Margin on start of widget, horizontally.
318    ///
319    /// This property supports left-to-right and right-to-left text
320    /// directions.
321    ///
322    /// This property adds margin outside of the widget's normal size
323    /// request, the margin will be added in addition to the size from
324    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
325    ///
326    /// Readable | Writeable
327    ///
328    ///
329    /// #### `margin-top`
330    ///  Margin on top side of widget.
331    ///
332    /// This property adds margin outside of the widget's normal size
333    /// request, the margin will be added in addition to the size from
334    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
335    ///
336    /// Readable | Writeable
337    ///
338    ///
339    /// #### `name`
340    ///  The name of the widget.
341    ///
342    /// Readable | Writeable
343    ///
344    ///
345    /// #### `opacity`
346    ///  The requested opacity of the widget.
347    ///
348    /// Readable | Writeable
349    ///
350    ///
351    /// #### `overflow`
352    ///  How content outside the widget's content area is treated.
353    ///
354    /// This property is meant to be set by widget implementations,
355    /// typically in their instance init function.
356    ///
357    /// Readable | Writeable
358    ///
359    ///
360    /// #### `parent`
361    ///  The parent widget of this widget.
362    ///
363    /// Readable
364    ///
365    ///
366    /// #### `receives-default`
367    ///  Whether the widget will receive the default action when it is focused.
368    ///
369    /// Readable | Writeable
370    ///
371    ///
372    /// #### `root`
373    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
374    ///
375    /// This will be `NULL` if the widget is not contained in a root widget.
376    ///
377    /// Readable
378    ///
379    ///
380    /// #### `scale-factor`
381    ///  The scale factor of the widget.
382    ///
383    /// Readable
384    ///
385    ///
386    /// #### `sensitive`
387    ///  Whether the widget responds to input.
388    ///
389    /// Readable | Writeable
390    ///
391    ///
392    /// #### `tooltip-markup`
393    ///  Sets the text of tooltip to be the given string, which is marked up
394    /// with Pango markup.
395    ///
396    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
397    ///
398    /// This is a convenience property which will take care of getting the
399    /// tooltip shown if the given string is not `NULL`:
400    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
401    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
402    /// the default signal handler.
403    ///
404    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
405    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
406    ///
407    /// Readable | Writeable
408    ///
409    ///
410    /// #### `tooltip-text`
411    ///  Sets the text of tooltip to be the given string.
412    ///
413    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
414    ///
415    /// This is a convenience property which will take care of getting the
416    /// tooltip shown if the given string is not `NULL`:
417    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
418    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
419    /// the default signal handler.
420    ///
421    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
422    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
423    ///
424    /// Readable | Writeable
425    ///
426    ///
427    /// #### `valign`
428    ///  How to distribute vertical space if widget gets extra space.
429    ///
430    /// Readable | Writeable
431    ///
432    ///
433    /// #### `vexpand`
434    ///  Whether to expand vertically.
435    ///
436    /// Readable | Writeable
437    ///
438    ///
439    /// #### `vexpand-set`
440    ///  Whether to use the `vexpand` property.
441    ///
442    /// Readable | Writeable
443    ///
444    ///
445    /// #### `visible`
446    ///  Whether the widget is visible.
447    ///
448    /// Readable | Writeable
449    ///
450    ///
451    /// #### `width-request`
452    ///  Overrides for width request of the widget.
453    ///
454    /// If this is -1, the natural request will be used.
455    ///
456    /// Readable | Writeable
457    /// </details>
458    /// <details><summary><h4>Accessible</h4></summary>
459    ///
460    ///
461    /// #### `accessible-role`
462    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
463    ///
464    /// The accessible role cannot be changed once set.
465    ///
466    /// Readable | Writeable
467    /// </details>
468    /// <details><summary><h4>Orientable</h4></summary>
469    ///
470    ///
471    /// #### `orientation`
472    ///  The orientation of the orientable.
473    ///
474    /// Readable | Writeable
475    /// </details>
476    ///
477    /// ## Signals
478    ///
479    ///
480    /// #### `offset-changed`
481    ///  Emitted when an offset specified on the bar changes value.
482    ///
483    /// This typically is the result of a [`LevelBar::add_offset_value()`][crate::LevelBar::add_offset_value()]
484    /// call.
485    ///
486    /// The signal supports detailed connections; you can connect to the
487    /// detailed signal "changed::x" in order to only receive callbacks when
488    /// the value of offset "x" changes.
489    ///
490    /// Detailed
491    /// <details><summary><h4>Widget</h4></summary>
492    ///
493    ///
494    /// #### `destroy`
495    ///  Signals that all holders of a reference to the widget should release
496    /// the reference that they hold.
497    ///
498    /// May result in finalization of the widget if all references are released.
499    ///
500    /// This signal is not suitable for saving widget state.
501    ///
502    ///
503    ///
504    ///
505    /// #### `direction-changed`
506    ///  Emitted when the text direction of a widget changes.
507    ///
508    ///
509    ///
510    ///
511    /// #### `hide`
512    ///  Emitted when @widget is hidden.
513    ///
514    ///
515    ///
516    ///
517    /// #### `keynav-failed`
518    ///  Emitted if keyboard navigation fails.
519    ///
520    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
521    ///
522    ///
523    ///
524    ///
525    /// #### `map`
526    ///  Emitted when @widget is going to be mapped.
527    ///
528    /// A widget is mapped when the widget is visible (which is controlled with
529    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
530    /// are also visible.
531    ///
532    /// The `::map` signal can be used to determine whether a widget will be drawn,
533    /// for instance it can resume an animation that was stopped during the
534    /// emission of [`unmap`][struct@crate::Widget#unmap].
535    ///
536    ///
537    ///
538    ///
539    /// #### `mnemonic-activate`
540    ///  Emitted when a widget is activated via a mnemonic.
541    ///
542    /// The default handler for this signal activates @widget if @group_cycling
543    /// is false, or just makes @widget grab focus if @group_cycling is true.
544    ///
545    ///
546    ///
547    ///
548    /// #### `move-focus`
549    ///  Emitted when the focus is moved.
550    ///
551    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
552    ///
553    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
554    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
555    ///
556    /// Action
557    ///
558    ///
559    /// #### `query-tooltip`
560    ///  Emitted when the widget’s tooltip is about to be shown.
561    ///
562    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
563    /// is true and the hover timeout has expired with the cursor hovering
564    /// above @widget; or emitted when @widget got focus in keyboard mode.
565    ///
566    /// Using the given coordinates, the signal handler should determine
567    /// whether a tooltip should be shown for @widget. If this is the case
568    /// true should be returned, false otherwise. Note that if @keyboard_mode
569    /// is true, the values of @x and @y are undefined and should not be used.
570    ///
571    /// The signal handler is free to manipulate @tooltip with the therefore
572    /// destined function calls.
573    ///
574    ///
575    ///
576    ///
577    /// #### `realize`
578    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
579    ///
580    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
581    /// or the widget has been mapped (that is, it is going to be drawn).
582    ///
583    ///
584    ///
585    ///
586    /// #### `show`
587    ///  Emitted when @widget is shown.
588    ///
589    ///
590    ///
591    ///
592    /// #### `state-flags-changed`
593    ///  Emitted when the widget state changes.
594    ///
595    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
596    ///
597    ///
598    ///
599    ///
600    /// #### `unmap`
601    ///  Emitted when @widget is going to be unmapped.
602    ///
603    /// A widget is unmapped when either it or any of its parents up to the
604    /// toplevel widget have been set as hidden.
605    ///
606    /// As `::unmap` indicates that a widget will not be shown any longer,
607    /// it can be used to, for example, stop an animation on the widget.
608    ///
609    ///
610    ///
611    ///
612    /// #### `unrealize`
613    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
614    ///
615    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
616    /// or the widget has been unmapped (that is, it is going to be hidden).
617    ///
618    ///
619    /// </details>
620    ///
621    /// # Implements
622    ///
623    /// [`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]
624    #[doc(alias = "GtkLevelBar")]
625    pub struct LevelBar(Object<ffi::GtkLevelBar>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, AccessibleRange, Orientable;
626
627    match fn {
628        type_ => || ffi::gtk_level_bar_get_type(),
629    }
630}
631
632#[cfg(not(any(feature = "v4_10")))]
633glib::wrapper! {
634    #[doc(alias = "GtkLevelBar")]
635    pub struct LevelBar(Object<ffi::GtkLevelBar>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable;
636
637    match fn {
638        type_ => || ffi::gtk_level_bar_get_type(),
639    }
640}
641
642impl LevelBar {
643    /// Creates a new [`LevelBar`][crate::LevelBar].
644    ///
645    /// # Returns
646    ///
647    /// a [`LevelBar`][crate::LevelBar].
648    #[doc(alias = "gtk_level_bar_new")]
649    pub fn new() -> LevelBar {
650        assert_initialized_main_thread!();
651        unsafe { Widget::from_glib_none(ffi::gtk_level_bar_new()).unsafe_cast() }
652    }
653
654    /// Creates a new [`LevelBar`][crate::LevelBar] for the specified interval.
655    /// ## `min_value`
656    /// a positive value
657    /// ## `max_value`
658    /// a positive value
659    ///
660    /// # Returns
661    ///
662    /// a [`LevelBar`][crate::LevelBar]
663    #[doc(alias = "gtk_level_bar_new_for_interval")]
664    #[doc(alias = "new_for_interval")]
665    pub fn for_interval(min_value: f64, max_value: f64) -> LevelBar {
666        assert_initialized_main_thread!();
667        unsafe {
668            Widget::from_glib_none(ffi::gtk_level_bar_new_for_interval(min_value, max_value))
669                .unsafe_cast()
670        }
671    }
672
673    // rustdoc-stripper-ignore-next
674    /// Creates a new builder-pattern struct instance to construct [`LevelBar`] objects.
675    ///
676    /// This method returns an instance of [`LevelBarBuilder`](crate::builders::LevelBarBuilder) which can be used to create [`LevelBar`] objects.
677    pub fn builder() -> LevelBarBuilder {
678        LevelBarBuilder::new()
679    }
680
681    /// Adds a new offset marker on @self at the position specified by @value.
682    ///
683    /// When the bar value is in the interval topped by @value (or between @value
684    /// and [`max-value`][struct@crate::LevelBar#max-value] in case the offset is the last one
685    /// on the bar) a style class named `level-`@name will be applied
686    /// when rendering the level bar fill.
687    ///
688    /// If another offset marker named @name exists, its value will be
689    /// replaced by @value.
690    /// ## `name`
691    /// the name of the new offset
692    /// ## `value`
693    /// the value for the new offset
694    #[doc(alias = "gtk_level_bar_add_offset_value")]
695    pub fn add_offset_value(&self, name: &str, value: f64) {
696        unsafe {
697            ffi::gtk_level_bar_add_offset_value(
698                self.to_glib_none().0,
699                name.to_glib_none().0,
700                value,
701            );
702        }
703    }
704
705    /// Returns whether the levelbar is inverted.
706    ///
707    /// # Returns
708    ///
709    /// [`true`] if the level bar is inverted
710    #[doc(alias = "gtk_level_bar_get_inverted")]
711    #[doc(alias = "get_inverted")]
712    #[doc(alias = "inverted")]
713    pub fn is_inverted(&self) -> bool {
714        unsafe { from_glib(ffi::gtk_level_bar_get_inverted(self.to_glib_none().0)) }
715    }
716
717    /// Returns the `max-value` of the [`LevelBar`][crate::LevelBar].
718    ///
719    /// # Returns
720    ///
721    /// a positive value
722    #[doc(alias = "gtk_level_bar_get_max_value")]
723    #[doc(alias = "get_max_value")]
724    #[doc(alias = "max-value")]
725    pub fn max_value(&self) -> f64 {
726        unsafe { ffi::gtk_level_bar_get_max_value(self.to_glib_none().0) }
727    }
728
729    /// Returns the `min-value` of the [`LevelBar`][crate::LevelBar].
730    ///
731    /// # Returns
732    ///
733    /// a positive value
734    #[doc(alias = "gtk_level_bar_get_min_value")]
735    #[doc(alias = "get_min_value")]
736    #[doc(alias = "min-value")]
737    pub fn min_value(&self) -> f64 {
738        unsafe { ffi::gtk_level_bar_get_min_value(self.to_glib_none().0) }
739    }
740
741    /// Returns the `mode` of the [`LevelBar`][crate::LevelBar].
742    ///
743    /// # Returns
744    ///
745    /// a [`LevelBarMode`][crate::LevelBarMode]
746    #[doc(alias = "gtk_level_bar_get_mode")]
747    #[doc(alias = "get_mode")]
748    pub fn mode(&self) -> LevelBarMode {
749        unsafe { from_glib(ffi::gtk_level_bar_get_mode(self.to_glib_none().0)) }
750    }
751
752    /// Fetches the value specified for the offset marker @name in @self.
753    /// ## `name`
754    /// the name of an offset in the bar
755    ///
756    /// # Returns
757    ///
758    /// [`true`] if the specified offset is found
759    ///
760    /// ## `value`
761    /// location where to store the value
762    #[doc(alias = "gtk_level_bar_get_offset_value")]
763    #[doc(alias = "get_offset_value")]
764    pub fn offset_value(&self, name: Option<&str>) -> Option<f64> {
765        unsafe {
766            let mut value = std::mem::MaybeUninit::uninit();
767            let ret = from_glib(ffi::gtk_level_bar_get_offset_value(
768                self.to_glib_none().0,
769                name.to_glib_none().0,
770                value.as_mut_ptr(),
771            ));
772            if ret {
773                Some(value.assume_init())
774            } else {
775                None
776            }
777        }
778    }
779
780    /// Returns the `value` of the [`LevelBar`][crate::LevelBar].
781    ///
782    /// # Returns
783    ///
784    /// a value in the interval between
785    ///   [`min-value`][struct@crate::LevelBar#min-value] and [`max-value`][struct@crate::LevelBar#max-value]
786    #[doc(alias = "gtk_level_bar_get_value")]
787    #[doc(alias = "get_value")]
788    pub fn value(&self) -> f64 {
789        unsafe { ffi::gtk_level_bar_get_value(self.to_glib_none().0) }
790    }
791
792    /// Removes an offset marker from a [`LevelBar`][crate::LevelBar].
793    ///
794    /// The marker must have been previously added with
795    /// [`add_offset_value()`][Self::add_offset_value()].
796    /// ## `name`
797    /// the name of an offset in the bar
798    #[doc(alias = "gtk_level_bar_remove_offset_value")]
799    pub fn remove_offset_value(&self, name: Option<&str>) {
800        unsafe {
801            ffi::gtk_level_bar_remove_offset_value(self.to_glib_none().0, name.to_glib_none().0);
802        }
803    }
804
805    /// Sets whether the [`LevelBar`][crate::LevelBar] is inverted.
806    /// ## `inverted`
807    /// [`true`] to invert the level bar
808    #[doc(alias = "gtk_level_bar_set_inverted")]
809    #[doc(alias = "inverted")]
810    pub fn set_inverted(&self, inverted: bool) {
811        unsafe {
812            ffi::gtk_level_bar_set_inverted(self.to_glib_none().0, inverted.into_glib());
813        }
814    }
815
816    /// Sets the `max-value` of the [`LevelBar`][crate::LevelBar].
817    ///
818    /// You probably want to update preexisting level offsets after calling
819    /// this function.
820    /// ## `value`
821    /// a positive value
822    #[doc(alias = "gtk_level_bar_set_max_value")]
823    #[doc(alias = "max-value")]
824    pub fn set_max_value(&self, value: f64) {
825        unsafe {
826            ffi::gtk_level_bar_set_max_value(self.to_glib_none().0, value);
827        }
828    }
829
830    /// Sets the `min-value` of the [`LevelBar`][crate::LevelBar].
831    ///
832    /// You probably want to update preexisting level offsets after calling
833    /// this function.
834    /// ## `value`
835    /// a positive value
836    #[doc(alias = "gtk_level_bar_set_min_value")]
837    #[doc(alias = "min-value")]
838    pub fn set_min_value(&self, value: f64) {
839        unsafe {
840            ffi::gtk_level_bar_set_min_value(self.to_glib_none().0, value);
841        }
842    }
843
844    /// Sets the `mode` of the [`LevelBar`][crate::LevelBar].
845    /// ## `mode`
846    /// a [`LevelBarMode`][crate::LevelBarMode]
847    #[doc(alias = "gtk_level_bar_set_mode")]
848    #[doc(alias = "mode")]
849    pub fn set_mode(&self, mode: LevelBarMode) {
850        unsafe {
851            ffi::gtk_level_bar_set_mode(self.to_glib_none().0, mode.into_glib());
852        }
853    }
854
855    /// Sets the value of the [`LevelBar`][crate::LevelBar].
856    /// ## `value`
857    /// a value in the interval between
858    ///   [`min-value`][struct@crate::LevelBar#min-value] and [`max-value`][struct@crate::LevelBar#max-value]
859    #[doc(alias = "gtk_level_bar_set_value")]
860    #[doc(alias = "value")]
861    pub fn set_value(&self, value: f64) {
862        unsafe {
863            ffi::gtk_level_bar_set_value(self.to_glib_none().0, value);
864        }
865    }
866
867    /// Emitted when an offset specified on the bar changes value.
868    ///
869    /// This typically is the result of a [`add_offset_value()`][Self::add_offset_value()]
870    /// call.
871    ///
872    /// The signal supports detailed connections; you can connect to the
873    /// detailed signal "changed::x" in order to only receive callbacks when
874    /// the value of offset "x" changes.
875    /// ## `name`
876    /// the name of the offset that changed value
877    #[doc(alias = "offset-changed")]
878    pub fn connect_offset_changed<F: Fn(&Self, &str) + 'static>(
879        &self,
880        detail: Option<&str>,
881        f: F,
882    ) -> SignalHandlerId {
883        unsafe extern "C" fn offset_changed_trampoline<F: Fn(&LevelBar, &str) + 'static>(
884            this: *mut ffi::GtkLevelBar,
885            name: *mut std::ffi::c_char,
886            f: glib::ffi::gpointer,
887        ) {
888            let f: &F = &*(f as *const F);
889            f(
890                &from_glib_borrow(this),
891                &glib::GString::from_glib_borrow(name),
892            )
893        }
894        unsafe {
895            let f: Box_<F> = Box_::new(f);
896            let detailed_signal_name = detail.map(|name| format!("offset-changed::{name}\0"));
897            let signal_name: &[u8] = detailed_signal_name
898                .as_ref()
899                .map_or(c"offset-changed".to_bytes(), |n| n.as_bytes());
900            connect_raw(
901                self.as_ptr() as *mut _,
902                signal_name.as_ptr() as *const _,
903                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
904                    offset_changed_trampoline::<F> as *const (),
905                )),
906                Box_::into_raw(f),
907            )
908        }
909    }
910
911    #[doc(alias = "inverted")]
912    pub fn connect_inverted_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
913        unsafe extern "C" fn notify_inverted_trampoline<F: Fn(&LevelBar) + 'static>(
914            this: *mut ffi::GtkLevelBar,
915            _param_spec: glib::ffi::gpointer,
916            f: glib::ffi::gpointer,
917        ) {
918            let f: &F = &*(f as *const F);
919            f(&from_glib_borrow(this))
920        }
921        unsafe {
922            let f: Box_<F> = Box_::new(f);
923            connect_raw(
924                self.as_ptr() as *mut _,
925                c"notify::inverted".as_ptr() as *const _,
926                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
927                    notify_inverted_trampoline::<F> as *const (),
928                )),
929                Box_::into_raw(f),
930            )
931        }
932    }
933
934    #[doc(alias = "max-value")]
935    pub fn connect_max_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
936        unsafe extern "C" fn notify_max_value_trampoline<F: Fn(&LevelBar) + 'static>(
937            this: *mut ffi::GtkLevelBar,
938            _param_spec: glib::ffi::gpointer,
939            f: glib::ffi::gpointer,
940        ) {
941            let f: &F = &*(f as *const F);
942            f(&from_glib_borrow(this))
943        }
944        unsafe {
945            let f: Box_<F> = Box_::new(f);
946            connect_raw(
947                self.as_ptr() as *mut _,
948                c"notify::max-value".as_ptr() as *const _,
949                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
950                    notify_max_value_trampoline::<F> as *const (),
951                )),
952                Box_::into_raw(f),
953            )
954        }
955    }
956
957    #[doc(alias = "min-value")]
958    pub fn connect_min_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
959        unsafe extern "C" fn notify_min_value_trampoline<F: Fn(&LevelBar) + 'static>(
960            this: *mut ffi::GtkLevelBar,
961            _param_spec: glib::ffi::gpointer,
962            f: glib::ffi::gpointer,
963        ) {
964            let f: &F = &*(f as *const F);
965            f(&from_glib_borrow(this))
966        }
967        unsafe {
968            let f: Box_<F> = Box_::new(f);
969            connect_raw(
970                self.as_ptr() as *mut _,
971                c"notify::min-value".as_ptr() as *const _,
972                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
973                    notify_min_value_trampoline::<F> as *const (),
974                )),
975                Box_::into_raw(f),
976            )
977        }
978    }
979
980    #[doc(alias = "mode")]
981    pub fn connect_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
982        unsafe extern "C" fn notify_mode_trampoline<F: Fn(&LevelBar) + 'static>(
983            this: *mut ffi::GtkLevelBar,
984            _param_spec: glib::ffi::gpointer,
985            f: glib::ffi::gpointer,
986        ) {
987            let f: &F = &*(f as *const F);
988            f(&from_glib_borrow(this))
989        }
990        unsafe {
991            let f: Box_<F> = Box_::new(f);
992            connect_raw(
993                self.as_ptr() as *mut _,
994                c"notify::mode".as_ptr() as *const _,
995                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
996                    notify_mode_trampoline::<F> as *const (),
997                )),
998                Box_::into_raw(f),
999            )
1000        }
1001    }
1002
1003    #[doc(alias = "value")]
1004    pub fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1005        unsafe extern "C" fn notify_value_trampoline<F: Fn(&LevelBar) + 'static>(
1006            this: *mut ffi::GtkLevelBar,
1007            _param_spec: glib::ffi::gpointer,
1008            f: glib::ffi::gpointer,
1009        ) {
1010            let f: &F = &*(f as *const F);
1011            f(&from_glib_borrow(this))
1012        }
1013        unsafe {
1014            let f: Box_<F> = Box_::new(f);
1015            connect_raw(
1016                self.as_ptr() as *mut _,
1017                c"notify::value".as_ptr() as *const _,
1018                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1019                    notify_value_trampoline::<F> as *const (),
1020                )),
1021                Box_::into_raw(f),
1022            )
1023        }
1024    }
1025}
1026
1027impl Default for LevelBar {
1028    fn default() -> Self {
1029        Self::new()
1030    }
1031}
1032
1033// rustdoc-stripper-ignore-next
1034/// A [builder-pattern] type to construct [`LevelBar`] objects.
1035///
1036/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1037#[must_use = "The builder must be built to be used"]
1038pub struct LevelBarBuilder {
1039    builder: glib::object::ObjectBuilder<'static, LevelBar>,
1040}
1041
1042impl LevelBarBuilder {
1043    fn new() -> Self {
1044        Self {
1045            builder: glib::object::Object::builder(),
1046        }
1047    }
1048
1049    /// Whether the `GtkLeveBar` is inverted.
1050    ///
1051    /// Level bars normally grow from top to bottom or left to right.
1052    /// Inverted level bars grow in the opposite direction.
1053    pub fn inverted(self, inverted: bool) -> Self {
1054        Self {
1055            builder: self.builder.property("inverted", inverted),
1056        }
1057    }
1058
1059    /// Determines the maximum value of the interval that can be displayed by the bar.
1060    pub fn max_value(self, max_value: f64) -> Self {
1061        Self {
1062            builder: self.builder.property("max-value", max_value),
1063        }
1064    }
1065
1066    /// Determines the minimum value of the interval that can be displayed by the bar.
1067    pub fn min_value(self, min_value: f64) -> Self {
1068        Self {
1069            builder: self.builder.property("min-value", min_value),
1070        }
1071    }
1072
1073    /// Determines the way [`LevelBar`][crate::LevelBar] interprets the value properties to draw the
1074    /// level fill area.
1075    ///
1076    /// Specifically, when the value is [`LevelBarMode::Continuous`][crate::LevelBarMode::Continuous],
1077    /// [`LevelBar`][crate::LevelBar] will draw a single block representing the current value in
1078    /// that area; when the value is [`LevelBarMode::Discrete`][crate::LevelBarMode::Discrete],
1079    /// the widget will draw a succession of separate blocks filling the
1080    /// draw area, with the number of blocks being equal to the units separating
1081    /// the integral roundings of [`min-value`][struct@crate::LevelBar#min-value] and
1082    /// [`max-value`][struct@crate::LevelBar#max-value].
1083    pub fn mode(self, mode: LevelBarMode) -> Self {
1084        Self {
1085            builder: self.builder.property("mode", mode),
1086        }
1087    }
1088
1089    /// Determines the currently filled value of the level bar.
1090    pub fn value(self, value: f64) -> Self {
1091        Self {
1092            builder: self.builder.property("value", value),
1093        }
1094    }
1095
1096    /// Whether the widget or any of its descendents can accept
1097    /// the input focus.
1098    ///
1099    /// This property is meant to be set by widget implementations,
1100    /// typically in their instance init function.
1101    pub fn can_focus(self, can_focus: bool) -> Self {
1102        Self {
1103            builder: self.builder.property("can-focus", can_focus),
1104        }
1105    }
1106
1107    /// Whether the widget can receive pointer events.
1108    pub fn can_target(self, can_target: bool) -> Self {
1109        Self {
1110            builder: self.builder.property("can-target", can_target),
1111        }
1112    }
1113
1114    /// A list of css classes applied to this widget.
1115    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1116        Self {
1117            builder: self.builder.property("css-classes", css_classes.into()),
1118        }
1119    }
1120
1121    /// The name of this widget in the CSS tree.
1122    ///
1123    /// This property is meant to be set by widget implementations,
1124    /// typically in their instance init function.
1125    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1126        Self {
1127            builder: self.builder.property("css-name", css_name.into()),
1128        }
1129    }
1130
1131    /// The cursor used by @widget.
1132    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1133        Self {
1134            builder: self.builder.property("cursor", cursor.clone()),
1135        }
1136    }
1137
1138    /// Whether the widget should grab focus when it is clicked with the mouse.
1139    ///
1140    /// This property is only relevant for widgets that can take focus.
1141    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1142        Self {
1143            builder: self.builder.property("focus-on-click", focus_on_click),
1144        }
1145    }
1146
1147    /// Whether this widget itself will accept the input focus.
1148    pub fn focusable(self, focusable: bool) -> Self {
1149        Self {
1150            builder: self.builder.property("focusable", focusable),
1151        }
1152    }
1153
1154    /// How to distribute horizontal space if widget gets extra space.
1155    pub fn halign(self, halign: Align) -> Self {
1156        Self {
1157            builder: self.builder.property("halign", halign),
1158        }
1159    }
1160
1161    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1162    /// signal on @widget.
1163    ///
1164    /// A true value indicates that @widget can have a tooltip, in this case
1165    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1166    /// determine whether it will provide a tooltip or not.
1167    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1168        Self {
1169            builder: self.builder.property("has-tooltip", has_tooltip),
1170        }
1171    }
1172
1173    /// Overrides for height request of the widget.
1174    ///
1175    /// If this is -1, the natural request will be used.
1176    pub fn height_request(self, height_request: i32) -> Self {
1177        Self {
1178            builder: self.builder.property("height-request", height_request),
1179        }
1180    }
1181
1182    /// Whether to expand horizontally.
1183    pub fn hexpand(self, hexpand: bool) -> Self {
1184        Self {
1185            builder: self.builder.property("hexpand", hexpand),
1186        }
1187    }
1188
1189    /// Whether to use the `hexpand` property.
1190    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1191        Self {
1192            builder: self.builder.property("hexpand-set", hexpand_set),
1193        }
1194    }
1195
1196    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1197    /// the preferred size of the widget, and allocate its children.
1198    ///
1199    /// This property is meant to be set by widget implementations,
1200    /// typically in their instance init function.
1201    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1202        Self {
1203            builder: self
1204                .builder
1205                .property("layout-manager", layout_manager.clone().upcast()),
1206        }
1207    }
1208
1209    /// Makes this widget act like a modal dialog, with respect to
1210    /// event delivery.
1211    ///
1212    /// Global event controllers will not handle events with targets
1213    /// inside the widget, unless they are set up to ignore propagation
1214    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1215    #[cfg(feature = "v4_18")]
1216    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1217    pub fn limit_events(self, limit_events: bool) -> Self {
1218        Self {
1219            builder: self.builder.property("limit-events", limit_events),
1220        }
1221    }
1222
1223    /// Margin on bottom side of widget.
1224    ///
1225    /// This property adds margin outside of the widget's normal size
1226    /// request, the margin will be added in addition to the size from
1227    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1228    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1229        Self {
1230            builder: self.builder.property("margin-bottom", margin_bottom),
1231        }
1232    }
1233
1234    /// Margin on end of widget, horizontally.
1235    ///
1236    /// This property supports left-to-right and right-to-left text
1237    /// directions.
1238    ///
1239    /// This property adds margin outside of the widget's normal size
1240    /// request, the margin will be added in addition to the size from
1241    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1242    pub fn margin_end(self, margin_end: i32) -> Self {
1243        Self {
1244            builder: self.builder.property("margin-end", margin_end),
1245        }
1246    }
1247
1248    /// Margin on start of widget, horizontally.
1249    ///
1250    /// This property supports left-to-right and right-to-left text
1251    /// directions.
1252    ///
1253    /// This property adds margin outside of the widget's normal size
1254    /// request, the margin will be added in addition to the size from
1255    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1256    pub fn margin_start(self, margin_start: i32) -> Self {
1257        Self {
1258            builder: self.builder.property("margin-start", margin_start),
1259        }
1260    }
1261
1262    /// Margin on top side of widget.
1263    ///
1264    /// This property adds margin outside of the widget's normal size
1265    /// request, the margin will be added in addition to the size from
1266    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1267    pub fn margin_top(self, margin_top: i32) -> Self {
1268        Self {
1269            builder: self.builder.property("margin-top", margin_top),
1270        }
1271    }
1272
1273    /// The name of the widget.
1274    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1275        Self {
1276            builder: self.builder.property("name", name.into()),
1277        }
1278    }
1279
1280    /// The requested opacity of the widget.
1281    pub fn opacity(self, opacity: f64) -> Self {
1282        Self {
1283            builder: self.builder.property("opacity", opacity),
1284        }
1285    }
1286
1287    /// How content outside the widget's content area is treated.
1288    ///
1289    /// This property is meant to be set by widget implementations,
1290    /// typically in their instance init function.
1291    pub fn overflow(self, overflow: Overflow) -> Self {
1292        Self {
1293            builder: self.builder.property("overflow", overflow),
1294        }
1295    }
1296
1297    /// Whether the widget will receive the default action when it is focused.
1298    pub fn receives_default(self, receives_default: bool) -> Self {
1299        Self {
1300            builder: self.builder.property("receives-default", receives_default),
1301        }
1302    }
1303
1304    /// Whether the widget responds to input.
1305    pub fn sensitive(self, sensitive: bool) -> Self {
1306        Self {
1307            builder: self.builder.property("sensitive", sensitive),
1308        }
1309    }
1310
1311    /// Sets the text of tooltip to be the given string, which is marked up
1312    /// with Pango markup.
1313    ///
1314    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1315    ///
1316    /// This is a convenience property which will take care of getting the
1317    /// tooltip shown if the given string is not `NULL`:
1318    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1319    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1320    /// the default signal handler.
1321    ///
1322    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1323    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1324    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1325        Self {
1326            builder: self
1327                .builder
1328                .property("tooltip-markup", tooltip_markup.into()),
1329        }
1330    }
1331
1332    /// Sets the text of tooltip to be the given string.
1333    ///
1334    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1335    ///
1336    /// This is a convenience property which will take care of getting the
1337    /// tooltip shown if the given string is not `NULL`:
1338    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1339    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1340    /// the default signal handler.
1341    ///
1342    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1343    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1344    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1345        Self {
1346            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1347        }
1348    }
1349
1350    /// How to distribute vertical space if widget gets extra space.
1351    pub fn valign(self, valign: Align) -> Self {
1352        Self {
1353            builder: self.builder.property("valign", valign),
1354        }
1355    }
1356
1357    /// Whether to expand vertically.
1358    pub fn vexpand(self, vexpand: bool) -> Self {
1359        Self {
1360            builder: self.builder.property("vexpand", vexpand),
1361        }
1362    }
1363
1364    /// Whether to use the `vexpand` property.
1365    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1366        Self {
1367            builder: self.builder.property("vexpand-set", vexpand_set),
1368        }
1369    }
1370
1371    /// Whether the widget is visible.
1372    pub fn visible(self, visible: bool) -> Self {
1373        Self {
1374            builder: self.builder.property("visible", visible),
1375        }
1376    }
1377
1378    /// Overrides for width request of the widget.
1379    ///
1380    /// If this is -1, the natural request will be used.
1381    pub fn width_request(self, width_request: i32) -> Self {
1382        Self {
1383            builder: self.builder.property("width-request", width_request),
1384        }
1385    }
1386
1387    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1388    ///
1389    /// The accessible role cannot be changed once set.
1390    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1391        Self {
1392            builder: self.builder.property("accessible-role", accessible_role),
1393        }
1394    }
1395
1396    /// The orientation of the orientable.
1397    pub fn orientation(self, orientation: Orientation) -> Self {
1398        Self {
1399            builder: self.builder.property("orientation", orientation),
1400        }
1401    }
1402
1403    // rustdoc-stripper-ignore-next
1404    /// Build the [`LevelBar`].
1405    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1406    pub fn build(self) -> LevelBar {
1407        assert_initialized_main_thread!();
1408        self.builder.build()
1409    }
1410}