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