Skip to main content

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    Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, LevelBarMode,
10    Orientable, Orientation, Overflow, Widget, ffi,
11};
12use glib::{
13    object::ObjectType as _,
14    prelude::*,
15    signal::{SignalHandlerId, connect_raw},
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(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 { Some(value.assume_init()) } else { None }
773        }
774    }
775
776    /// Returns the `value` of the [`LevelBar`][crate::LevelBar].
777    ///
778    /// # Returns
779    ///
780    /// a value in the interval between
781    ///   [`min-value`][struct@crate::LevelBar#min-value] and [`max-value`][struct@crate::LevelBar#max-value]
782    #[doc(alias = "gtk_level_bar_get_value")]
783    #[doc(alias = "get_value")]
784    pub fn value(&self) -> f64 {
785        unsafe { ffi::gtk_level_bar_get_value(self.to_glib_none().0) }
786    }
787
788    /// Removes an offset marker from a [`LevelBar`][crate::LevelBar].
789    ///
790    /// The marker must have been previously added with
791    /// [`add_offset_value()`][Self::add_offset_value()].
792    /// ## `name`
793    /// the name of an offset in the bar
794    #[doc(alias = "gtk_level_bar_remove_offset_value")]
795    pub fn remove_offset_value(&self, name: Option<&str>) {
796        unsafe {
797            ffi::gtk_level_bar_remove_offset_value(self.to_glib_none().0, name.to_glib_none().0);
798        }
799    }
800
801    /// Sets whether the [`LevelBar`][crate::LevelBar] is inverted.
802    /// ## `inverted`
803    /// [`true`] to invert the level bar
804    #[doc(alias = "gtk_level_bar_set_inverted")]
805    #[doc(alias = "inverted")]
806    pub fn set_inverted(&self, inverted: bool) {
807        unsafe {
808            ffi::gtk_level_bar_set_inverted(self.to_glib_none().0, inverted.into_glib());
809        }
810    }
811
812    /// Sets the `max-value` of the [`LevelBar`][crate::LevelBar].
813    ///
814    /// You probably want to update preexisting level offsets after calling
815    /// this function.
816    /// ## `value`
817    /// a positive value
818    #[doc(alias = "gtk_level_bar_set_max_value")]
819    #[doc(alias = "max-value")]
820    pub fn set_max_value(&self, value: f64) {
821        unsafe {
822            ffi::gtk_level_bar_set_max_value(self.to_glib_none().0, value);
823        }
824    }
825
826    /// Sets the `min-value` of the [`LevelBar`][crate::LevelBar].
827    ///
828    /// You probably want to update preexisting level offsets after calling
829    /// this function.
830    /// ## `value`
831    /// a positive value
832    #[doc(alias = "gtk_level_bar_set_min_value")]
833    #[doc(alias = "min-value")]
834    pub fn set_min_value(&self, value: f64) {
835        unsafe {
836            ffi::gtk_level_bar_set_min_value(self.to_glib_none().0, value);
837        }
838    }
839
840    /// Sets the `mode` of the [`LevelBar`][crate::LevelBar].
841    /// ## `mode`
842    /// a [`LevelBarMode`][crate::LevelBarMode]
843    #[doc(alias = "gtk_level_bar_set_mode")]
844    #[doc(alias = "mode")]
845    pub fn set_mode(&self, mode: LevelBarMode) {
846        unsafe {
847            ffi::gtk_level_bar_set_mode(self.to_glib_none().0, mode.into_glib());
848        }
849    }
850
851    /// Sets the value of the [`LevelBar`][crate::LevelBar].
852    /// ## `value`
853    /// a value in the interval between
854    ///   [`min-value`][struct@crate::LevelBar#min-value] and [`max-value`][struct@crate::LevelBar#max-value]
855    #[doc(alias = "gtk_level_bar_set_value")]
856    #[doc(alias = "value")]
857    pub fn set_value(&self, value: f64) {
858        unsafe {
859            ffi::gtk_level_bar_set_value(self.to_glib_none().0, value);
860        }
861    }
862
863    /// Emitted when an offset specified on the bar changes value.
864    ///
865    /// This typically is the result of a [`add_offset_value()`][Self::add_offset_value()]
866    /// call.
867    ///
868    /// The signal supports detailed connections; you can connect to the
869    /// detailed signal "changed::x" in order to only receive callbacks when
870    /// the value of offset "x" changes.
871    /// ## `name`
872    /// the name of the offset that changed value
873    #[doc(alias = "offset-changed")]
874    pub fn connect_offset_changed<F: Fn(&Self, &str) + 'static>(
875        &self,
876        detail: Option<&str>,
877        f: F,
878    ) -> SignalHandlerId {
879        unsafe extern "C" fn offset_changed_trampoline<F: Fn(&LevelBar, &str) + 'static>(
880            this: *mut ffi::GtkLevelBar,
881            name: *mut std::ffi::c_char,
882            f: glib::ffi::gpointer,
883        ) {
884            unsafe {
885                let f: &F = &*(f as *const F);
886                f(
887                    &from_glib_borrow(this),
888                    &glib::GString::from_glib_borrow(name),
889                )
890            }
891        }
892        unsafe {
893            let f: Box_<F> = Box_::new(f);
894            let detailed_signal_name = detail.map(|name| format!("offset-changed::{name}\0"));
895            let signal_name = detailed_signal_name
896                .as_ref()
897                .map_or(c"offset-changed", |n| {
898                    std::ffi::CStr::from_bytes_with_nul_unchecked(n.as_bytes())
899                });
900            connect_raw(
901                self.as_ptr() as *mut _,
902                signal_name.as_ptr(),
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            unsafe {
919                let f: &F = &*(f as *const F);
920                f(&from_glib_borrow(this))
921            }
922        }
923        unsafe {
924            let f: Box_<F> = Box_::new(f);
925            connect_raw(
926                self.as_ptr() as *mut _,
927                c"notify::inverted".as_ptr(),
928                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
929                    notify_inverted_trampoline::<F> as *const (),
930                )),
931                Box_::into_raw(f),
932            )
933        }
934    }
935
936    #[doc(alias = "max-value")]
937    pub fn connect_max_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
938        unsafe extern "C" fn notify_max_value_trampoline<F: Fn(&LevelBar) + 'static>(
939            this: *mut ffi::GtkLevelBar,
940            _param_spec: glib::ffi::gpointer,
941            f: glib::ffi::gpointer,
942        ) {
943            unsafe {
944                let f: &F = &*(f as *const F);
945                f(&from_glib_borrow(this))
946            }
947        }
948        unsafe {
949            let f: Box_<F> = Box_::new(f);
950            connect_raw(
951                self.as_ptr() as *mut _,
952                c"notify::max-value".as_ptr(),
953                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
954                    notify_max_value_trampoline::<F> as *const (),
955                )),
956                Box_::into_raw(f),
957            )
958        }
959    }
960
961    #[doc(alias = "min-value")]
962    pub fn connect_min_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
963        unsafe extern "C" fn notify_min_value_trampoline<F: Fn(&LevelBar) + 'static>(
964            this: *mut ffi::GtkLevelBar,
965            _param_spec: glib::ffi::gpointer,
966            f: glib::ffi::gpointer,
967        ) {
968            unsafe {
969                let f: &F = &*(f as *const F);
970                f(&from_glib_borrow(this))
971            }
972        }
973        unsafe {
974            let f: Box_<F> = Box_::new(f);
975            connect_raw(
976                self.as_ptr() as *mut _,
977                c"notify::min-value".as_ptr(),
978                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
979                    notify_min_value_trampoline::<F> as *const (),
980                )),
981                Box_::into_raw(f),
982            )
983        }
984    }
985
986    #[doc(alias = "mode")]
987    pub fn connect_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
988        unsafe extern "C" fn notify_mode_trampoline<F: Fn(&LevelBar) + 'static>(
989            this: *mut ffi::GtkLevelBar,
990            _param_spec: glib::ffi::gpointer,
991            f: glib::ffi::gpointer,
992        ) {
993            unsafe {
994                let f: &F = &*(f as *const F);
995                f(&from_glib_borrow(this))
996            }
997        }
998        unsafe {
999            let f: Box_<F> = Box_::new(f);
1000            connect_raw(
1001                self.as_ptr() as *mut _,
1002                c"notify::mode".as_ptr(),
1003                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1004                    notify_mode_trampoline::<F> as *const (),
1005                )),
1006                Box_::into_raw(f),
1007            )
1008        }
1009    }
1010
1011    #[doc(alias = "value")]
1012    pub fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1013        unsafe extern "C" fn notify_value_trampoline<F: Fn(&LevelBar) + 'static>(
1014            this: *mut ffi::GtkLevelBar,
1015            _param_spec: glib::ffi::gpointer,
1016            f: glib::ffi::gpointer,
1017        ) {
1018            unsafe {
1019                let f: &F = &*(f as *const F);
1020                f(&from_glib_borrow(this))
1021            }
1022        }
1023        unsafe {
1024            let f: Box_<F> = Box_::new(f);
1025            connect_raw(
1026                self.as_ptr() as *mut _,
1027                c"notify::value".as_ptr(),
1028                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1029                    notify_value_trampoline::<F> as *const (),
1030                )),
1031                Box_::into_raw(f),
1032            )
1033        }
1034    }
1035}
1036
1037impl Default for LevelBar {
1038    fn default() -> Self {
1039        Self::new()
1040    }
1041}
1042
1043// rustdoc-stripper-ignore-next
1044/// A [builder-pattern] type to construct [`LevelBar`] objects.
1045///
1046/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1047#[must_use = "The builder must be built to be used"]
1048pub struct LevelBarBuilder {
1049    builder: glib::object::ObjectBuilder<'static, LevelBar>,
1050}
1051
1052impl LevelBarBuilder {
1053    fn new() -> Self {
1054        Self {
1055            builder: glib::object::Object::builder(),
1056        }
1057    }
1058
1059    /// Whether the `GtkLeveBar` is inverted.
1060    ///
1061    /// Level bars normally grow from top to bottom or left to right.
1062    /// Inverted level bars grow in the opposite direction.
1063    pub fn inverted(self, inverted: bool) -> Self {
1064        Self {
1065            builder: self.builder.property("inverted", inverted),
1066        }
1067    }
1068
1069    /// Determines the maximum value of the interval that can be displayed by the bar.
1070    pub fn max_value(self, max_value: f64) -> Self {
1071        Self {
1072            builder: self.builder.property("max-value", max_value),
1073        }
1074    }
1075
1076    /// Determines the minimum value of the interval that can be displayed by the bar.
1077    pub fn min_value(self, min_value: f64) -> Self {
1078        Self {
1079            builder: self.builder.property("min-value", min_value),
1080        }
1081    }
1082
1083    /// Determines the way [`LevelBar`][crate::LevelBar] interprets the value properties to draw the
1084    /// level fill area.
1085    ///
1086    /// Specifically, when the value is [`LevelBarMode::Continuous`][crate::LevelBarMode::Continuous],
1087    /// [`LevelBar`][crate::LevelBar] will draw a single block representing the current value in
1088    /// that area; when the value is [`LevelBarMode::Discrete`][crate::LevelBarMode::Discrete],
1089    /// the widget will draw a succession of separate blocks filling the
1090    /// draw area, with the number of blocks being equal to the units separating
1091    /// the integral roundings of [`min-value`][struct@crate::LevelBar#min-value] and
1092    /// [`max-value`][struct@crate::LevelBar#max-value].
1093    pub fn mode(self, mode: LevelBarMode) -> Self {
1094        Self {
1095            builder: self.builder.property("mode", mode),
1096        }
1097    }
1098
1099    /// Determines the currently filled value of the level bar.
1100    pub fn value(self, value: f64) -> Self {
1101        Self {
1102            builder: self.builder.property("value", value),
1103        }
1104    }
1105
1106    /// Whether the widget or any of its descendents can accept
1107    /// the input focus.
1108    ///
1109    /// This property is meant to be set by widget implementations,
1110    /// typically in their instance init function.
1111    pub fn can_focus(self, can_focus: bool) -> Self {
1112        Self {
1113            builder: self.builder.property("can-focus", can_focus),
1114        }
1115    }
1116
1117    /// Whether the widget can receive pointer events.
1118    pub fn can_target(self, can_target: bool) -> Self {
1119        Self {
1120            builder: self.builder.property("can-target", can_target),
1121        }
1122    }
1123
1124    /// A list of css classes applied to this widget.
1125    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1126        Self {
1127            builder: self.builder.property("css-classes", css_classes.into()),
1128        }
1129    }
1130
1131    /// The name of this widget in the CSS tree.
1132    ///
1133    /// This property is meant to be set by widget implementations,
1134    /// typically in their instance init function.
1135    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1136        Self {
1137            builder: self.builder.property("css-name", css_name.into()),
1138        }
1139    }
1140
1141    /// The cursor used by @widget.
1142    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1143        Self {
1144            builder: self.builder.property("cursor", cursor.clone()),
1145        }
1146    }
1147
1148    /// Whether the widget should grab focus when it is clicked with the mouse.
1149    ///
1150    /// This property is only relevant for widgets that can take focus.
1151    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1152        Self {
1153            builder: self.builder.property("focus-on-click", focus_on_click),
1154        }
1155    }
1156
1157    /// Whether this widget itself will accept the input focus.
1158    pub fn focusable(self, focusable: bool) -> Self {
1159        Self {
1160            builder: self.builder.property("focusable", focusable),
1161        }
1162    }
1163
1164    /// How to distribute horizontal space if widget gets extra space.
1165    pub fn halign(self, halign: Align) -> Self {
1166        Self {
1167            builder: self.builder.property("halign", halign),
1168        }
1169    }
1170
1171    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1172    /// signal on @widget.
1173    ///
1174    /// A true value indicates that @widget can have a tooltip, in this case
1175    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1176    /// determine whether it will provide a tooltip or not.
1177    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1178        Self {
1179            builder: self.builder.property("has-tooltip", has_tooltip),
1180        }
1181    }
1182
1183    /// Overrides for height request of the widget.
1184    ///
1185    /// If this is -1, the natural request will be used.
1186    pub fn height_request(self, height_request: i32) -> Self {
1187        Self {
1188            builder: self.builder.property("height-request", height_request),
1189        }
1190    }
1191
1192    /// Whether to expand horizontally.
1193    pub fn hexpand(self, hexpand: bool) -> Self {
1194        Self {
1195            builder: self.builder.property("hexpand", hexpand),
1196        }
1197    }
1198
1199    /// Whether to use the `hexpand` property.
1200    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1201        Self {
1202            builder: self.builder.property("hexpand-set", hexpand_set),
1203        }
1204    }
1205
1206    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1207    /// the preferred size of the widget, and allocate its children.
1208    ///
1209    /// This property is meant to be set by widget implementations,
1210    /// typically in their instance init function.
1211    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1212        Self {
1213            builder: self
1214                .builder
1215                .property("layout-manager", layout_manager.clone().upcast()),
1216        }
1217    }
1218
1219    /// Makes this widget act like a modal dialog, with respect to
1220    /// event delivery.
1221    ///
1222    /// Global event controllers will not handle events with targets
1223    /// inside the widget, unless they are set up to ignore propagation
1224    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1225    #[cfg(feature = "v4_18")]
1226    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1227    pub fn limit_events(self, limit_events: bool) -> Self {
1228        Self {
1229            builder: self.builder.property("limit-events", limit_events),
1230        }
1231    }
1232
1233    /// Margin on bottom side of widget.
1234    ///
1235    /// This property adds margin outside of the widget's normal size
1236    /// request, the margin will be added in addition to the size from
1237    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1238    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1239        Self {
1240            builder: self.builder.property("margin-bottom", margin_bottom),
1241        }
1242    }
1243
1244    /// Margin on end of widget, horizontally.
1245    ///
1246    /// This property supports left-to-right and right-to-left text
1247    /// directions.
1248    ///
1249    /// This property adds margin outside of the widget's normal size
1250    /// request, the margin will be added in addition to the size from
1251    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1252    pub fn margin_end(self, margin_end: i32) -> Self {
1253        Self {
1254            builder: self.builder.property("margin-end", margin_end),
1255        }
1256    }
1257
1258    /// Margin on start of widget, horizontally.
1259    ///
1260    /// This property supports left-to-right and right-to-left text
1261    /// directions.
1262    ///
1263    /// This property adds margin outside of the widget's normal size
1264    /// request, the margin will be added in addition to the size from
1265    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1266    pub fn margin_start(self, margin_start: i32) -> Self {
1267        Self {
1268            builder: self.builder.property("margin-start", margin_start),
1269        }
1270    }
1271
1272    /// Margin on top side of widget.
1273    ///
1274    /// This property adds margin outside of the widget's normal size
1275    /// request, the margin will be added in addition to the size from
1276    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1277    pub fn margin_top(self, margin_top: i32) -> Self {
1278        Self {
1279            builder: self.builder.property("margin-top", margin_top),
1280        }
1281    }
1282
1283    /// The name of the widget.
1284    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1285        Self {
1286            builder: self.builder.property("name", name.into()),
1287        }
1288    }
1289
1290    /// The requested opacity of the widget.
1291    pub fn opacity(self, opacity: f64) -> Self {
1292        Self {
1293            builder: self.builder.property("opacity", opacity),
1294        }
1295    }
1296
1297    /// How content outside the widget's content area is treated.
1298    ///
1299    /// This property is meant to be set by widget implementations,
1300    /// typically in their instance init function.
1301    pub fn overflow(self, overflow: Overflow) -> Self {
1302        Self {
1303            builder: self.builder.property("overflow", overflow),
1304        }
1305    }
1306
1307    /// Whether the widget will receive the default action when it is focused.
1308    pub fn receives_default(self, receives_default: bool) -> Self {
1309        Self {
1310            builder: self.builder.property("receives-default", receives_default),
1311        }
1312    }
1313
1314    /// Whether the widget responds to input.
1315    pub fn sensitive(self, sensitive: bool) -> Self {
1316        Self {
1317            builder: self.builder.property("sensitive", sensitive),
1318        }
1319    }
1320
1321    /// Sets the text of tooltip to be the given string, which is marked up
1322    /// with Pango markup.
1323    ///
1324    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1325    ///
1326    /// This is a convenience property which will take care of getting the
1327    /// tooltip shown if the given string is not `NULL`:
1328    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1329    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1330    /// the default signal handler.
1331    ///
1332    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1333    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1334    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1335        Self {
1336            builder: self
1337                .builder
1338                .property("tooltip-markup", tooltip_markup.into()),
1339        }
1340    }
1341
1342    /// Sets the text of tooltip to be the given string.
1343    ///
1344    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1345    ///
1346    /// This is a convenience property which will take care of getting the
1347    /// tooltip shown if the given string is not `NULL`:
1348    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1349    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1350    /// the default signal handler.
1351    ///
1352    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1353    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1354    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1355        Self {
1356            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1357        }
1358    }
1359
1360    /// How to distribute vertical space if widget gets extra space.
1361    pub fn valign(self, valign: Align) -> Self {
1362        Self {
1363            builder: self.builder.property("valign", valign),
1364        }
1365    }
1366
1367    /// Whether to expand vertically.
1368    pub fn vexpand(self, vexpand: bool) -> Self {
1369        Self {
1370            builder: self.builder.property("vexpand", vexpand),
1371        }
1372    }
1373
1374    /// Whether to use the `vexpand` property.
1375    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1376        Self {
1377            builder: self.builder.property("vexpand-set", vexpand_set),
1378        }
1379    }
1380
1381    /// Whether the widget is visible.
1382    pub fn visible(self, visible: bool) -> Self {
1383        Self {
1384            builder: self.builder.property("visible", visible),
1385        }
1386    }
1387
1388    /// Overrides for width request of the widget.
1389    ///
1390    /// If this is -1, the natural request will be used.
1391    pub fn width_request(self, width_request: i32) -> Self {
1392        Self {
1393            builder: self.builder.property("width-request", width_request),
1394        }
1395    }
1396
1397    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1398    ///
1399    /// The accessible role cannot be changed once set.
1400    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1401        Self {
1402            builder: self.builder.property("accessible-role", accessible_role),
1403        }
1404    }
1405
1406    /// The orientation of the orientable.
1407    pub fn orientation(self, orientation: Orientation) -> Self {
1408        Self {
1409            builder: self.builder.property("orientation", orientation),
1410        }
1411    }
1412
1413    // rustdoc-stripper-ignore-next
1414    /// Build the [`LevelBar`].
1415    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1416    pub fn build(self) -> LevelBar {
1417        assert_initialized_main_thread!();
1418        self.builder.build()
1419    }
1420}