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