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(any(feature = "v4_10")))]
633glib::wrapper! {
634 #[doc(alias = "GtkLevelBar")]
635 pub struct LevelBar(Object<ffi::GtkLevelBar>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable;
636
637 match fn {
638 type_ => || ffi::gtk_level_bar_get_type(),
639 }
640}
641
642impl LevelBar {
643 /// Creates a new [`LevelBar`][crate::LevelBar].
644 ///
645 /// # Returns
646 ///
647 /// a [`LevelBar`][crate::LevelBar].
648 #[doc(alias = "gtk_level_bar_new")]
649 pub fn new() -> LevelBar {
650 assert_initialized_main_thread!();
651 unsafe { Widget::from_glib_none(ffi::gtk_level_bar_new()).unsafe_cast() }
652 }
653
654 /// Creates a new [`LevelBar`][crate::LevelBar] for the specified interval.
655 /// ## `min_value`
656 /// a positive value
657 /// ## `max_value`
658 /// a positive value
659 ///
660 /// # Returns
661 ///
662 /// a [`LevelBar`][crate::LevelBar]
663 #[doc(alias = "gtk_level_bar_new_for_interval")]
664 #[doc(alias = "new_for_interval")]
665 pub fn for_interval(min_value: f64, max_value: f64) -> LevelBar {
666 assert_initialized_main_thread!();
667 unsafe {
668 Widget::from_glib_none(ffi::gtk_level_bar_new_for_interval(min_value, max_value))
669 .unsafe_cast()
670 }
671 }
672
673 // rustdoc-stripper-ignore-next
674 /// Creates a new builder-pattern struct instance to construct [`LevelBar`] objects.
675 ///
676 /// This method returns an instance of [`LevelBarBuilder`](crate::builders::LevelBarBuilder) which can be used to create [`LevelBar`] objects.
677 pub fn builder() -> LevelBarBuilder {
678 LevelBarBuilder::new()
679 }
680
681 /// Adds a new offset marker on @self at the position specified by @value.
682 ///
683 /// When the bar value is in the interval topped by @value (or between @value
684 /// and [`max-value`][struct@crate::LevelBar#max-value] in case the offset is the last one
685 /// on the bar) a style class named `level-`@name will be applied
686 /// when rendering the level bar fill.
687 ///
688 /// If another offset marker named @name exists, its value will be
689 /// replaced by @value.
690 /// ## `name`
691 /// the name of the new offset
692 /// ## `value`
693 /// the value for the new offset
694 #[doc(alias = "gtk_level_bar_add_offset_value")]
695 pub fn add_offset_value(&self, name: &str, value: f64) {
696 unsafe {
697 ffi::gtk_level_bar_add_offset_value(
698 self.to_glib_none().0,
699 name.to_glib_none().0,
700 value,
701 );
702 }
703 }
704
705 /// Returns whether the levelbar is inverted.
706 ///
707 /// # Returns
708 ///
709 /// [`true`] if the level bar is inverted
710 #[doc(alias = "gtk_level_bar_get_inverted")]
711 #[doc(alias = "get_inverted")]
712 #[doc(alias = "inverted")]
713 pub fn is_inverted(&self) -> bool {
714 unsafe { from_glib(ffi::gtk_level_bar_get_inverted(self.to_glib_none().0)) }
715 }
716
717 /// Returns the `max-value` of the [`LevelBar`][crate::LevelBar].
718 ///
719 /// # Returns
720 ///
721 /// a positive value
722 #[doc(alias = "gtk_level_bar_get_max_value")]
723 #[doc(alias = "get_max_value")]
724 #[doc(alias = "max-value")]
725 pub fn max_value(&self) -> f64 {
726 unsafe { ffi::gtk_level_bar_get_max_value(self.to_glib_none().0) }
727 }
728
729 /// Returns the `min-value` of the [`LevelBar`][crate::LevelBar].
730 ///
731 /// # Returns
732 ///
733 /// a positive value
734 #[doc(alias = "gtk_level_bar_get_min_value")]
735 #[doc(alias = "get_min_value")]
736 #[doc(alias = "min-value")]
737 pub fn min_value(&self) -> f64 {
738 unsafe { ffi::gtk_level_bar_get_min_value(self.to_glib_none().0) }
739 }
740
741 /// Returns the `mode` of the [`LevelBar`][crate::LevelBar].
742 ///
743 /// # Returns
744 ///
745 /// a [`LevelBarMode`][crate::LevelBarMode]
746 #[doc(alias = "gtk_level_bar_get_mode")]
747 #[doc(alias = "get_mode")]
748 pub fn mode(&self) -> LevelBarMode {
749 unsafe { from_glib(ffi::gtk_level_bar_get_mode(self.to_glib_none().0)) }
750 }
751
752 /// Fetches the value specified for the offset marker @name in @self.
753 /// ## `name`
754 /// the name of an offset in the bar
755 ///
756 /// # Returns
757 ///
758 /// [`true`] if the specified offset is found
759 ///
760 /// ## `value`
761 /// location where to store the value
762 #[doc(alias = "gtk_level_bar_get_offset_value")]
763 #[doc(alias = "get_offset_value")]
764 pub fn offset_value(&self, name: Option<&str>) -> Option<f64> {
765 unsafe {
766 let mut value = std::mem::MaybeUninit::uninit();
767 let ret = from_glib(ffi::gtk_level_bar_get_offset_value(
768 self.to_glib_none().0,
769 name.to_glib_none().0,
770 value.as_mut_ptr(),
771 ));
772 if ret { 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: &[u8] = detailed_signal_name
896 .as_ref()
897 .map_or(c"offset-changed".to_bytes(), |n| n.as_bytes());
898 connect_raw(
899 self.as_ptr() as *mut _,
900 signal_name.as_ptr() as *const _,
901 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
902 offset_changed_trampoline::<F> as *const (),
903 )),
904 Box_::into_raw(f),
905 )
906 }
907 }
908
909 #[doc(alias = "inverted")]
910 pub fn connect_inverted_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
911 unsafe extern "C" fn notify_inverted_trampoline<F: Fn(&LevelBar) + 'static>(
912 this: *mut ffi::GtkLevelBar,
913 _param_spec: glib::ffi::gpointer,
914 f: glib::ffi::gpointer,
915 ) {
916 unsafe {
917 let f: &F = &*(f as *const F);
918 f(&from_glib_borrow(this))
919 }
920 }
921 unsafe {
922 let f: Box_<F> = Box_::new(f);
923 connect_raw(
924 self.as_ptr() as *mut _,
925 c"notify::inverted".as_ptr() as *const _,
926 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
927 notify_inverted_trampoline::<F> as *const (),
928 )),
929 Box_::into_raw(f),
930 )
931 }
932 }
933
934 #[doc(alias = "max-value")]
935 pub fn connect_max_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
936 unsafe extern "C" fn notify_max_value_trampoline<F: Fn(&LevelBar) + 'static>(
937 this: *mut ffi::GtkLevelBar,
938 _param_spec: glib::ffi::gpointer,
939 f: glib::ffi::gpointer,
940 ) {
941 unsafe {
942 let f: &F = &*(f as *const F);
943 f(&from_glib_borrow(this))
944 }
945 }
946 unsafe {
947 let f: Box_<F> = Box_::new(f);
948 connect_raw(
949 self.as_ptr() as *mut _,
950 c"notify::max-value".as_ptr() as *const _,
951 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
952 notify_max_value_trampoline::<F> as *const (),
953 )),
954 Box_::into_raw(f),
955 )
956 }
957 }
958
959 #[doc(alias = "min-value")]
960 pub fn connect_min_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
961 unsafe extern "C" fn notify_min_value_trampoline<F: Fn(&LevelBar) + 'static>(
962 this: *mut ffi::GtkLevelBar,
963 _param_spec: glib::ffi::gpointer,
964 f: glib::ffi::gpointer,
965 ) {
966 unsafe {
967 let f: &F = &*(f as *const F);
968 f(&from_glib_borrow(this))
969 }
970 }
971 unsafe {
972 let f: Box_<F> = Box_::new(f);
973 connect_raw(
974 self.as_ptr() as *mut _,
975 c"notify::min-value".as_ptr() as *const _,
976 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
977 notify_min_value_trampoline::<F> as *const (),
978 )),
979 Box_::into_raw(f),
980 )
981 }
982 }
983
984 #[doc(alias = "mode")]
985 pub fn connect_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
986 unsafe extern "C" fn notify_mode_trampoline<F: Fn(&LevelBar) + 'static>(
987 this: *mut ffi::GtkLevelBar,
988 _param_spec: glib::ffi::gpointer,
989 f: glib::ffi::gpointer,
990 ) {
991 unsafe {
992 let f: &F = &*(f as *const F);
993 f(&from_glib_borrow(this))
994 }
995 }
996 unsafe {
997 let f: Box_<F> = Box_::new(f);
998 connect_raw(
999 self.as_ptr() as *mut _,
1000 c"notify::mode".as_ptr() as *const _,
1001 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1002 notify_mode_trampoline::<F> as *const (),
1003 )),
1004 Box_::into_raw(f),
1005 )
1006 }
1007 }
1008
1009 #[doc(alias = "value")]
1010 pub fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1011 unsafe extern "C" fn notify_value_trampoline<F: Fn(&LevelBar) + 'static>(
1012 this: *mut ffi::GtkLevelBar,
1013 _param_spec: glib::ffi::gpointer,
1014 f: glib::ffi::gpointer,
1015 ) {
1016 unsafe {
1017 let f: &F = &*(f as *const F);
1018 f(&from_glib_borrow(this))
1019 }
1020 }
1021 unsafe {
1022 let f: Box_<F> = Box_::new(f);
1023 connect_raw(
1024 self.as_ptr() as *mut _,
1025 c"notify::value".as_ptr() as *const _,
1026 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1027 notify_value_trampoline::<F> as *const (),
1028 )),
1029 Box_::into_raw(f),
1030 )
1031 }
1032 }
1033}
1034
1035impl Default for LevelBar {
1036 fn default() -> Self {
1037 Self::new()
1038 }
1039}
1040
1041// rustdoc-stripper-ignore-next
1042/// A [builder-pattern] type to construct [`LevelBar`] objects.
1043///
1044/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1045#[must_use = "The builder must be built to be used"]
1046pub struct LevelBarBuilder {
1047 builder: glib::object::ObjectBuilder<'static, LevelBar>,
1048}
1049
1050impl LevelBarBuilder {
1051 fn new() -> Self {
1052 Self {
1053 builder: glib::object::Object::builder(),
1054 }
1055 }
1056
1057 /// Whether the `GtkLeveBar` is inverted.
1058 ///
1059 /// Level bars normally grow from top to bottom or left to right.
1060 /// Inverted level bars grow in the opposite direction.
1061 pub fn inverted(self, inverted: bool) -> Self {
1062 Self {
1063 builder: self.builder.property("inverted", inverted),
1064 }
1065 }
1066
1067 /// Determines the maximum value of the interval that can be displayed by the bar.
1068 pub fn max_value(self, max_value: f64) -> Self {
1069 Self {
1070 builder: self.builder.property("max-value", max_value),
1071 }
1072 }
1073
1074 /// Determines the minimum value of the interval that can be displayed by the bar.
1075 pub fn min_value(self, min_value: f64) -> Self {
1076 Self {
1077 builder: self.builder.property("min-value", min_value),
1078 }
1079 }
1080
1081 /// Determines the way [`LevelBar`][crate::LevelBar] interprets the value properties to draw the
1082 /// level fill area.
1083 ///
1084 /// Specifically, when the value is [`LevelBarMode::Continuous`][crate::LevelBarMode::Continuous],
1085 /// [`LevelBar`][crate::LevelBar] will draw a single block representing the current value in
1086 /// that area; when the value is [`LevelBarMode::Discrete`][crate::LevelBarMode::Discrete],
1087 /// the widget will draw a succession of separate blocks filling the
1088 /// draw area, with the number of blocks being equal to the units separating
1089 /// the integral roundings of [`min-value`][struct@crate::LevelBar#min-value] and
1090 /// [`max-value`][struct@crate::LevelBar#max-value].
1091 pub fn mode(self, mode: LevelBarMode) -> Self {
1092 Self {
1093 builder: self.builder.property("mode", mode),
1094 }
1095 }
1096
1097 /// Determines the currently filled value of the level bar.
1098 pub fn value(self, value: f64) -> Self {
1099 Self {
1100 builder: self.builder.property("value", value),
1101 }
1102 }
1103
1104 /// Whether the widget or any of its descendents can accept
1105 /// the input focus.
1106 ///
1107 /// This property is meant to be set by widget implementations,
1108 /// typically in their instance init function.
1109 pub fn can_focus(self, can_focus: bool) -> Self {
1110 Self {
1111 builder: self.builder.property("can-focus", can_focus),
1112 }
1113 }
1114
1115 /// Whether the widget can receive pointer events.
1116 pub fn can_target(self, can_target: bool) -> Self {
1117 Self {
1118 builder: self.builder.property("can-target", can_target),
1119 }
1120 }
1121
1122 /// A list of css classes applied to this widget.
1123 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1124 Self {
1125 builder: self.builder.property("css-classes", css_classes.into()),
1126 }
1127 }
1128
1129 /// The name of this widget in the CSS tree.
1130 ///
1131 /// This property is meant to be set by widget implementations,
1132 /// typically in their instance init function.
1133 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1134 Self {
1135 builder: self.builder.property("css-name", css_name.into()),
1136 }
1137 }
1138
1139 /// The cursor used by @widget.
1140 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1141 Self {
1142 builder: self.builder.property("cursor", cursor.clone()),
1143 }
1144 }
1145
1146 /// Whether the widget should grab focus when it is clicked with the mouse.
1147 ///
1148 /// This property is only relevant for widgets that can take focus.
1149 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1150 Self {
1151 builder: self.builder.property("focus-on-click", focus_on_click),
1152 }
1153 }
1154
1155 /// Whether this widget itself will accept the input focus.
1156 pub fn focusable(self, focusable: bool) -> Self {
1157 Self {
1158 builder: self.builder.property("focusable", focusable),
1159 }
1160 }
1161
1162 /// How to distribute horizontal space if widget gets extra space.
1163 pub fn halign(self, halign: Align) -> Self {
1164 Self {
1165 builder: self.builder.property("halign", halign),
1166 }
1167 }
1168
1169 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1170 /// signal on @widget.
1171 ///
1172 /// A true value indicates that @widget can have a tooltip, in this case
1173 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1174 /// determine whether it will provide a tooltip or not.
1175 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1176 Self {
1177 builder: self.builder.property("has-tooltip", has_tooltip),
1178 }
1179 }
1180
1181 /// Overrides for height request of the widget.
1182 ///
1183 /// If this is -1, the natural request will be used.
1184 pub fn height_request(self, height_request: i32) -> Self {
1185 Self {
1186 builder: self.builder.property("height-request", height_request),
1187 }
1188 }
1189
1190 /// Whether to expand horizontally.
1191 pub fn hexpand(self, hexpand: bool) -> Self {
1192 Self {
1193 builder: self.builder.property("hexpand", hexpand),
1194 }
1195 }
1196
1197 /// Whether to use the `hexpand` property.
1198 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1199 Self {
1200 builder: self.builder.property("hexpand-set", hexpand_set),
1201 }
1202 }
1203
1204 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1205 /// the preferred size of the widget, and allocate its children.
1206 ///
1207 /// This property is meant to be set by widget implementations,
1208 /// typically in their instance init function.
1209 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1210 Self {
1211 builder: self
1212 .builder
1213 .property("layout-manager", layout_manager.clone().upcast()),
1214 }
1215 }
1216
1217 /// Makes this widget act like a modal dialog, with respect to
1218 /// event delivery.
1219 ///
1220 /// Global event controllers will not handle events with targets
1221 /// inside the widget, unless they are set up to ignore propagation
1222 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1223 #[cfg(feature = "v4_18")]
1224 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1225 pub fn limit_events(self, limit_events: bool) -> Self {
1226 Self {
1227 builder: self.builder.property("limit-events", limit_events),
1228 }
1229 }
1230
1231 /// Margin on bottom side of widget.
1232 ///
1233 /// This property adds margin outside of the widget's normal size
1234 /// request, the margin will be added in addition to the size from
1235 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1236 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1237 Self {
1238 builder: self.builder.property("margin-bottom", margin_bottom),
1239 }
1240 }
1241
1242 /// Margin on end of widget, horizontally.
1243 ///
1244 /// This property supports left-to-right and right-to-left text
1245 /// directions.
1246 ///
1247 /// This property adds margin outside of the widget's normal size
1248 /// request, the margin will be added in addition to the size from
1249 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1250 pub fn margin_end(self, margin_end: i32) -> Self {
1251 Self {
1252 builder: self.builder.property("margin-end", margin_end),
1253 }
1254 }
1255
1256 /// Margin on start of widget, horizontally.
1257 ///
1258 /// This property supports left-to-right and right-to-left text
1259 /// directions.
1260 ///
1261 /// This property adds margin outside of the widget's normal size
1262 /// request, the margin will be added in addition to the size from
1263 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1264 pub fn margin_start(self, margin_start: i32) -> Self {
1265 Self {
1266 builder: self.builder.property("margin-start", margin_start),
1267 }
1268 }
1269
1270 /// Margin on top side of widget.
1271 ///
1272 /// This property adds margin outside of the widget's normal size
1273 /// request, the margin will be added in addition to the size from
1274 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1275 pub fn margin_top(self, margin_top: i32) -> Self {
1276 Self {
1277 builder: self.builder.property("margin-top", margin_top),
1278 }
1279 }
1280
1281 /// The name of the widget.
1282 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1283 Self {
1284 builder: self.builder.property("name", name.into()),
1285 }
1286 }
1287
1288 /// The requested opacity of the widget.
1289 pub fn opacity(self, opacity: f64) -> Self {
1290 Self {
1291 builder: self.builder.property("opacity", opacity),
1292 }
1293 }
1294
1295 /// How content outside the widget's content area is treated.
1296 ///
1297 /// This property is meant to be set by widget implementations,
1298 /// typically in their instance init function.
1299 pub fn overflow(self, overflow: Overflow) -> Self {
1300 Self {
1301 builder: self.builder.property("overflow", overflow),
1302 }
1303 }
1304
1305 /// Whether the widget will receive the default action when it is focused.
1306 pub fn receives_default(self, receives_default: bool) -> Self {
1307 Self {
1308 builder: self.builder.property("receives-default", receives_default),
1309 }
1310 }
1311
1312 /// Whether the widget responds to input.
1313 pub fn sensitive(self, sensitive: bool) -> Self {
1314 Self {
1315 builder: self.builder.property("sensitive", sensitive),
1316 }
1317 }
1318
1319 /// Sets the text of tooltip to be the given string, which is marked up
1320 /// with Pango markup.
1321 ///
1322 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1323 ///
1324 /// This is a convenience property which will take care of getting the
1325 /// tooltip shown if the given string is not `NULL`:
1326 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1327 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1328 /// the default signal handler.
1329 ///
1330 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1331 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1332 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1333 Self {
1334 builder: self
1335 .builder
1336 .property("tooltip-markup", tooltip_markup.into()),
1337 }
1338 }
1339
1340 /// Sets the text of tooltip to be the given string.
1341 ///
1342 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1343 ///
1344 /// This is a convenience property which will take care of getting the
1345 /// tooltip shown if the given string is not `NULL`:
1346 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1347 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1348 /// the default signal handler.
1349 ///
1350 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1351 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1352 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1353 Self {
1354 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1355 }
1356 }
1357
1358 /// How to distribute vertical space if widget gets extra space.
1359 pub fn valign(self, valign: Align) -> Self {
1360 Self {
1361 builder: self.builder.property("valign", valign),
1362 }
1363 }
1364
1365 /// Whether to expand vertically.
1366 pub fn vexpand(self, vexpand: bool) -> Self {
1367 Self {
1368 builder: self.builder.property("vexpand", vexpand),
1369 }
1370 }
1371
1372 /// Whether to use the `vexpand` property.
1373 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1374 Self {
1375 builder: self.builder.property("vexpand-set", vexpand_set),
1376 }
1377 }
1378
1379 /// Whether the widget is visible.
1380 pub fn visible(self, visible: bool) -> Self {
1381 Self {
1382 builder: self.builder.property("visible", visible),
1383 }
1384 }
1385
1386 /// Overrides for width request of the widget.
1387 ///
1388 /// If this is -1, the natural request will be used.
1389 pub fn width_request(self, width_request: i32) -> Self {
1390 Self {
1391 builder: self.builder.property("width-request", width_request),
1392 }
1393 }
1394
1395 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1396 ///
1397 /// The accessible role cannot be changed once set.
1398 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1399 Self {
1400 builder: self.builder.property("accessible-role", accessible_role),
1401 }
1402 }
1403
1404 /// The orientation of the orientable.
1405 pub fn orientation(self, orientation: Orientation) -> Self {
1406 Self {
1407 builder: self.builder.property("orientation", orientation),
1408 }
1409 }
1410
1411 // rustdoc-stripper-ignore-next
1412 /// Build the [`LevelBar`].
1413 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1414 pub fn build(self) -> LevelBar {
1415 assert_initialized_main_thread!();
1416 self.builder.build()
1417 }
1418}