gtk4/auto/volume_button.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#![allow(deprecated)]
5
6#[cfg(feature = "v4_10")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
8use crate::AccessibleRange;
9use crate::{
10 ffi, Accessible, AccessibleRole, Adjustment, Align, Buildable, ConstraintTarget, LayoutManager,
11 Orientable, Orientation, Overflow, ScaleButton, Widget,
12};
13use glib::{
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 /// This widget will be removed in GTK 5
24 /// [`VolumeButton`][crate::VolumeButton] is a [`ScaleButton`][crate::ScaleButton] subclass tailored for
25 /// volume control.
26 ///
27 /// 
28 ///
29 /// ## Properties
30 ///
31 ///
32 /// #### `use-symbolic`
33 /// Whether to use symbolic icons as the icons.
34 ///
35 /// Note that if the symbolic icons are not available in your installed
36 /// theme, then the normal (potentially colorful) icons will be used.
37 ///
38 /// Readable | Writeable | Construct
39 /// <details><summary><h4>ScaleButton</h4></summary>
40 ///
41 ///
42 /// #### `active`
43 /// If the scale button should be pressed in.
44 ///
45 /// Readable
46 ///
47 ///
48 /// #### `adjustment`
49 /// The [`Adjustment`][crate::Adjustment] that is used as the model.
50 ///
51 /// Readable | Writeable
52 ///
53 ///
54 /// #### `has-frame`
55 /// If the scale button has a frame.
56 ///
57 /// Readable | Writeable
58 ///
59 ///
60 /// #### `icons`
61 /// The names of the icons to be used by the scale button.
62 ///
63 /// The first item in the array will be used in the button
64 /// when the current value is the lowest value, the second
65 /// item for the highest value. All the subsequent icons will
66 /// be used for all the other values, spread evenly over the
67 /// range of values.
68 ///
69 /// If there's only one icon name in the @icons array, it will
70 /// be used for all the values. If only two icon names are in
71 /// the @icons array, the first one will be used for the bottom
72 /// 50% of the scale, and the second one for the top 50%.
73 ///
74 /// It is recommended to use at least 3 icons so that the
75 /// [`ScaleButton`][crate::ScaleButton] reflects the current value of the scale
76 /// better for the users.
77 ///
78 /// Readable | Writeable
79 ///
80 ///
81 /// #### `value`
82 /// The value of the scale.
83 ///
84 /// Readable | Writeable
85 /// </details>
86 /// <details><summary><h4>Widget</h4></summary>
87 ///
88 ///
89 /// #### `can-focus`
90 /// Whether the widget or any of its descendents can accept
91 /// the input focus.
92 ///
93 /// This property is meant to be set by widget implementations,
94 /// typically in their instance init function.
95 ///
96 /// Readable | Writeable
97 ///
98 ///
99 /// #### `can-target`
100 /// Whether the widget can receive pointer events.
101 ///
102 /// Readable | Writeable
103 ///
104 ///
105 /// #### `css-classes`
106 /// A list of css classes applied to this widget.
107 ///
108 /// Readable | Writeable
109 ///
110 ///
111 /// #### `css-name`
112 /// The name of this widget in the CSS tree.
113 ///
114 /// This property is meant to be set by widget implementations,
115 /// typically in their instance init function.
116 ///
117 /// Readable | Writeable | Construct Only
118 ///
119 ///
120 /// #### `cursor`
121 /// The cursor used by @widget.
122 ///
123 /// Readable | Writeable
124 ///
125 ///
126 /// #### `focus-on-click`
127 /// Whether the widget should grab focus when it is clicked with the mouse.
128 ///
129 /// This property is only relevant for widgets that can take focus.
130 ///
131 /// Readable | Writeable
132 ///
133 ///
134 /// #### `focusable`
135 /// Whether this widget itself will accept the input focus.
136 ///
137 /// Readable | Writeable
138 ///
139 ///
140 /// #### `halign`
141 /// How to distribute horizontal space if widget gets extra space.
142 ///
143 /// Readable | Writeable
144 ///
145 ///
146 /// #### `has-default`
147 /// Whether the widget is the default widget.
148 ///
149 /// Readable
150 ///
151 ///
152 /// #### `has-focus`
153 /// Whether the widget has the input focus.
154 ///
155 /// Readable
156 ///
157 ///
158 /// #### `has-tooltip`
159 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
160 /// signal on @widget.
161 ///
162 /// A true value indicates that @widget can have a tooltip, in this case
163 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
164 /// determine whether it will provide a tooltip or not.
165 ///
166 /// Readable | Writeable
167 ///
168 ///
169 /// #### `height-request`
170 /// Overrides for height request of the widget.
171 ///
172 /// If this is -1, the natural request will be used.
173 ///
174 /// Readable | Writeable
175 ///
176 ///
177 /// #### `hexpand`
178 /// Whether to expand horizontally.
179 ///
180 /// Readable | Writeable
181 ///
182 ///
183 /// #### `hexpand-set`
184 /// Whether to use the `hexpand` property.
185 ///
186 /// Readable | Writeable
187 ///
188 ///
189 /// #### `layout-manager`
190 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
191 /// the preferred size of the widget, and allocate its children.
192 ///
193 /// This property is meant to be set by widget implementations,
194 /// typically in their instance init function.
195 ///
196 /// Readable | Writeable
197 ///
198 ///
199 /// #### `limit-events`
200 /// Makes this widget act like a modal dialog, with respect to
201 /// event delivery.
202 ///
203 /// Global event controllers will not handle events with targets
204 /// inside the widget, unless they are set up to ignore propagation
205 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
206 ///
207 /// Readable | Writeable
208 ///
209 ///
210 /// #### `margin-bottom`
211 /// Margin on bottom side of widget.
212 ///
213 /// This property adds margin outside of the widget's normal size
214 /// request, the margin will be added in addition to the size from
215 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
216 ///
217 /// Readable | Writeable
218 ///
219 ///
220 /// #### `margin-end`
221 /// Margin on end of widget, horizontally.
222 ///
223 /// This property supports left-to-right and right-to-left text
224 /// directions.
225 ///
226 /// This property adds margin outside of the widget's normal size
227 /// request, the margin will be added in addition to the size from
228 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
229 ///
230 /// Readable | Writeable
231 ///
232 ///
233 /// #### `margin-start`
234 /// Margin on start of widget, horizontally.
235 ///
236 /// This property supports left-to-right and right-to-left text
237 /// directions.
238 ///
239 /// This property adds margin outside of the widget's normal size
240 /// request, the margin will be added in addition to the size from
241 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
242 ///
243 /// Readable | Writeable
244 ///
245 ///
246 /// #### `margin-top`
247 /// Margin on top side of widget.
248 ///
249 /// This property adds margin outside of the widget's normal size
250 /// request, the margin will be added in addition to the size from
251 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
252 ///
253 /// Readable | Writeable
254 ///
255 ///
256 /// #### `name`
257 /// The name of the widget.
258 ///
259 /// Readable | Writeable
260 ///
261 ///
262 /// #### `opacity`
263 /// The requested opacity of the widget.
264 ///
265 /// Readable | Writeable
266 ///
267 ///
268 /// #### `overflow`
269 /// How content outside the widget's content area is treated.
270 ///
271 /// This property is meant to be set by widget implementations,
272 /// typically in their instance init function.
273 ///
274 /// Readable | Writeable
275 ///
276 ///
277 /// #### `parent`
278 /// The parent widget of this widget.
279 ///
280 /// Readable
281 ///
282 ///
283 /// #### `receives-default`
284 /// Whether the widget will receive the default action when it is focused.
285 ///
286 /// Readable | Writeable
287 ///
288 ///
289 /// #### `root`
290 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
291 ///
292 /// This will be `NULL` if the widget is not contained in a root widget.
293 ///
294 /// Readable
295 ///
296 ///
297 /// #### `scale-factor`
298 /// The scale factor of the widget.
299 ///
300 /// Readable
301 ///
302 ///
303 /// #### `sensitive`
304 /// Whether the widget responds to input.
305 ///
306 /// Readable | Writeable
307 ///
308 ///
309 /// #### `tooltip-markup`
310 /// Sets the text of tooltip to be the given string, which is marked up
311 /// with Pango markup.
312 ///
313 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
314 ///
315 /// This is a convenience property which will take care of getting the
316 /// tooltip shown if the given string is not `NULL`:
317 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
318 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
319 /// the default signal handler.
320 ///
321 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
322 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
323 ///
324 /// Readable | Writeable
325 ///
326 ///
327 /// #### `tooltip-text`
328 /// Sets the text of tooltip to be the given string.
329 ///
330 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
331 ///
332 /// This is a convenience property which will take care of getting the
333 /// tooltip shown if the given string is not `NULL`:
334 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
335 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
336 /// the default signal handler.
337 ///
338 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
339 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
340 ///
341 /// Readable | Writeable
342 ///
343 ///
344 /// #### `valign`
345 /// How to distribute vertical space if widget gets extra space.
346 ///
347 /// Readable | Writeable
348 ///
349 ///
350 /// #### `vexpand`
351 /// Whether to expand vertically.
352 ///
353 /// Readable | Writeable
354 ///
355 ///
356 /// #### `vexpand-set`
357 /// Whether to use the `vexpand` property.
358 ///
359 /// Readable | Writeable
360 ///
361 ///
362 /// #### `visible`
363 /// Whether the widget is visible.
364 ///
365 /// Readable | Writeable
366 ///
367 ///
368 /// #### `width-request`
369 /// Overrides for width request of the widget.
370 ///
371 /// If this is -1, the natural request will be used.
372 ///
373 /// Readable | Writeable
374 /// </details>
375 /// <details><summary><h4>Accessible</h4></summary>
376 ///
377 ///
378 /// #### `accessible-role`
379 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
380 ///
381 /// The accessible role cannot be changed once set.
382 ///
383 /// Readable | Writeable
384 /// </details>
385 /// <details><summary><h4>Orientable</h4></summary>
386 ///
387 ///
388 /// #### `orientation`
389 /// The orientation of the orientable.
390 ///
391 /// Readable | Writeable
392 /// </details>
393 ///
394 /// # Implements
395 ///
396 /// [`ScaleButtonExt`][trait@crate::prelude::ScaleButtonExt], [`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]
397 #[doc(alias = "GtkVolumeButton")]
398 pub struct VolumeButton(Object<ffi::GtkVolumeButton>) @extends ScaleButton, Widget, @implements Accessible, Buildable, ConstraintTarget, AccessibleRange, Orientable;
399
400 match fn {
401 type_ => || ffi::gtk_volume_button_get_type(),
402 }
403}
404
405#[cfg(not(any(feature = "v4_10")))]
406glib::wrapper! {
407 #[doc(alias = "GtkVolumeButton")]
408 pub struct VolumeButton(Object<ffi::GtkVolumeButton>) @extends ScaleButton, Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable;
409
410 match fn {
411 type_ => || ffi::gtk_volume_button_get_type(),
412 }
413}
414
415impl VolumeButton {
416 /// Creates a [`VolumeButton`][crate::VolumeButton].
417 ///
418 /// The button has a range between 0.0 and 1.0, with a stepping of 0.02.
419 /// Volume values can be obtained and modified using the functions from
420 /// [`ScaleButton`][crate::ScaleButton].
421 ///
422 /// # Deprecated since 4.10
423 ///
424 /// This widget will be removed in GTK 5
425 ///
426 /// # Returns
427 ///
428 /// a new [`VolumeButton`][crate::VolumeButton]
429 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
430 #[allow(deprecated)]
431 #[doc(alias = "gtk_volume_button_new")]
432 pub fn new() -> VolumeButton {
433 assert_initialized_main_thread!();
434 unsafe { Widget::from_glib_none(ffi::gtk_volume_button_new()).unsafe_cast() }
435 }
436
437 // rustdoc-stripper-ignore-next
438 /// Creates a new builder-pattern struct instance to construct [`VolumeButton`] objects.
439 ///
440 /// This method returns an instance of [`VolumeButtonBuilder`](crate::builders::VolumeButtonBuilder) which can be used to create [`VolumeButton`] objects.
441 pub fn builder() -> VolumeButtonBuilder {
442 VolumeButtonBuilder::new()
443 }
444
445 /// Whether to use symbolic icons as the icons.
446 ///
447 /// Note that if the symbolic icons are not available in your installed
448 /// theme, then the normal (potentially colorful) icons will be used.
449 ///
450 /// # Deprecated since 4.10
451 ///
452 /// This widget will be removed in GTK 5
453 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
454 #[doc(alias = "use-symbolic")]
455 pub fn uses_symbolic(&self) -> bool {
456 ObjectExt::property(self, "use-symbolic")
457 }
458
459 /// Whether to use symbolic icons as the icons.
460 ///
461 /// Note that if the symbolic icons are not available in your installed
462 /// theme, then the normal (potentially colorful) icons will be used.
463 ///
464 /// # Deprecated since 4.10
465 ///
466 /// This widget will be removed in GTK 5
467 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
468 #[doc(alias = "use-symbolic")]
469 pub fn set_use_symbolic(&self, use_symbolic: bool) {
470 ObjectExt::set_property(self, "use-symbolic", use_symbolic)
471 }
472
473 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
474 #[doc(alias = "use-symbolic")]
475 pub fn connect_use_symbolic_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
476 unsafe extern "C" fn notify_use_symbolic_trampoline<F: Fn(&VolumeButton) + 'static>(
477 this: *mut ffi::GtkVolumeButton,
478 _param_spec: glib::ffi::gpointer,
479 f: glib::ffi::gpointer,
480 ) {
481 let f: &F = &*(f as *const F);
482 f(&from_glib_borrow(this))
483 }
484 unsafe {
485 let f: Box_<F> = Box_::new(f);
486 connect_raw(
487 self.as_ptr() as *mut _,
488 b"notify::use-symbolic\0".as_ptr() as *const _,
489 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
490 notify_use_symbolic_trampoline::<F> as *const (),
491 )),
492 Box_::into_raw(f),
493 )
494 }
495 }
496}
497
498impl Default for VolumeButton {
499 fn default() -> Self {
500 Self::new()
501 }
502}
503
504// rustdoc-stripper-ignore-next
505/// A [builder-pattern] type to construct [`VolumeButton`] objects.
506///
507/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
508#[must_use = "The builder must be built to be used"]
509pub struct VolumeButtonBuilder {
510 builder: glib::object::ObjectBuilder<'static, VolumeButton>,
511}
512
513impl VolumeButtonBuilder {
514 fn new() -> Self {
515 Self {
516 builder: glib::object::Object::builder(),
517 }
518 }
519
520 /// Whether to use symbolic icons as the icons.
521 ///
522 /// Note that if the symbolic icons are not available in your installed
523 /// theme, then the normal (potentially colorful) icons will be used.
524 /// This widget will be removed in GTK 5
525 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
526 pub fn use_symbolic(self, use_symbolic: bool) -> Self {
527 Self {
528 builder: self.builder.property("use-symbolic", use_symbolic),
529 }
530 }
531
532 /// The [`Adjustment`][crate::Adjustment] that is used as the model.
533 pub fn adjustment(self, adjustment: &impl IsA<Adjustment>) -> Self {
534 Self {
535 builder: self
536 .builder
537 .property("adjustment", adjustment.clone().upcast()),
538 }
539 }
540
541 /// If the scale button has a frame.
542 #[cfg(feature = "v4_14")]
543 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
544 pub fn has_frame(self, has_frame: bool) -> Self {
545 Self {
546 builder: self.builder.property("has-frame", has_frame),
547 }
548 }
549
550 /// The names of the icons to be used by the scale button.
551 ///
552 /// The first item in the array will be used in the button
553 /// when the current value is the lowest value, the second
554 /// item for the highest value. All the subsequent icons will
555 /// be used for all the other values, spread evenly over the
556 /// range of values.
557 ///
558 /// If there's only one icon name in the @icons array, it will
559 /// be used for all the values. If only two icon names are in
560 /// the @icons array, the first one will be used for the bottom
561 /// 50% of the scale, and the second one for the top 50%.
562 ///
563 /// It is recommended to use at least 3 icons so that the
564 /// [`ScaleButton`][crate::ScaleButton] reflects the current value of the scale
565 /// better for the users.
566 pub fn icons(self, icons: impl Into<glib::StrV>) -> Self {
567 Self {
568 builder: self.builder.property("icons", icons.into()),
569 }
570 }
571
572 /// The value of the scale.
573 pub fn value(self, value: f64) -> Self {
574 Self {
575 builder: self.builder.property("value", value),
576 }
577 }
578
579 /// Whether the widget or any of its descendents can accept
580 /// the input focus.
581 ///
582 /// This property is meant to be set by widget implementations,
583 /// typically in their instance init function.
584 pub fn can_focus(self, can_focus: bool) -> Self {
585 Self {
586 builder: self.builder.property("can-focus", can_focus),
587 }
588 }
589
590 /// Whether the widget can receive pointer events.
591 pub fn can_target(self, can_target: bool) -> Self {
592 Self {
593 builder: self.builder.property("can-target", can_target),
594 }
595 }
596
597 /// A list of css classes applied to this widget.
598 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
599 Self {
600 builder: self.builder.property("css-classes", css_classes.into()),
601 }
602 }
603
604 /// The name of this widget in the CSS tree.
605 ///
606 /// This property is meant to be set by widget implementations,
607 /// typically in their instance init function.
608 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
609 Self {
610 builder: self.builder.property("css-name", css_name.into()),
611 }
612 }
613
614 /// The cursor used by @widget.
615 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
616 Self {
617 builder: self.builder.property("cursor", cursor.clone()),
618 }
619 }
620
621 /// Whether the widget should grab focus when it is clicked with the mouse.
622 ///
623 /// This property is only relevant for widgets that can take focus.
624 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
625 Self {
626 builder: self.builder.property("focus-on-click", focus_on_click),
627 }
628 }
629
630 /// Whether this widget itself will accept the input focus.
631 pub fn focusable(self, focusable: bool) -> Self {
632 Self {
633 builder: self.builder.property("focusable", focusable),
634 }
635 }
636
637 /// How to distribute horizontal space if widget gets extra space.
638 pub fn halign(self, halign: Align) -> Self {
639 Self {
640 builder: self.builder.property("halign", halign),
641 }
642 }
643
644 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
645 /// signal on @widget.
646 ///
647 /// A true value indicates that @widget can have a tooltip, in this case
648 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
649 /// determine whether it will provide a tooltip or not.
650 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
651 Self {
652 builder: self.builder.property("has-tooltip", has_tooltip),
653 }
654 }
655
656 /// Overrides for height request of the widget.
657 ///
658 /// If this is -1, the natural request will be used.
659 pub fn height_request(self, height_request: i32) -> Self {
660 Self {
661 builder: self.builder.property("height-request", height_request),
662 }
663 }
664
665 /// Whether to expand horizontally.
666 pub fn hexpand(self, hexpand: bool) -> Self {
667 Self {
668 builder: self.builder.property("hexpand", hexpand),
669 }
670 }
671
672 /// Whether to use the `hexpand` property.
673 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
674 Self {
675 builder: self.builder.property("hexpand-set", hexpand_set),
676 }
677 }
678
679 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
680 /// the preferred size of the widget, and allocate its children.
681 ///
682 /// This property is meant to be set by widget implementations,
683 /// typically in their instance init function.
684 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
685 Self {
686 builder: self
687 .builder
688 .property("layout-manager", layout_manager.clone().upcast()),
689 }
690 }
691
692 /// Makes this widget act like a modal dialog, with respect to
693 /// event delivery.
694 ///
695 /// Global event controllers will not handle events with targets
696 /// inside the widget, unless they are set up to ignore propagation
697 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
698 #[cfg(feature = "v4_18")]
699 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
700 pub fn limit_events(self, limit_events: bool) -> Self {
701 Self {
702 builder: self.builder.property("limit-events", limit_events),
703 }
704 }
705
706 /// Margin on bottom side of widget.
707 ///
708 /// This property adds margin outside of the widget's normal size
709 /// request, the margin will be added in addition to the size from
710 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
711 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
712 Self {
713 builder: self.builder.property("margin-bottom", margin_bottom),
714 }
715 }
716
717 /// Margin on end of widget, horizontally.
718 ///
719 /// This property supports left-to-right and right-to-left text
720 /// directions.
721 ///
722 /// This property adds margin outside of the widget's normal size
723 /// request, the margin will be added in addition to the size from
724 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
725 pub fn margin_end(self, margin_end: i32) -> Self {
726 Self {
727 builder: self.builder.property("margin-end", margin_end),
728 }
729 }
730
731 /// Margin on start of widget, horizontally.
732 ///
733 /// This property supports left-to-right and right-to-left text
734 /// directions.
735 ///
736 /// This property adds margin outside of the widget's normal size
737 /// request, the margin will be added in addition to the size from
738 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
739 pub fn margin_start(self, margin_start: i32) -> Self {
740 Self {
741 builder: self.builder.property("margin-start", margin_start),
742 }
743 }
744
745 /// Margin on top side of widget.
746 ///
747 /// This property adds margin outside of the widget's normal size
748 /// request, the margin will be added in addition to the size from
749 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
750 pub fn margin_top(self, margin_top: i32) -> Self {
751 Self {
752 builder: self.builder.property("margin-top", margin_top),
753 }
754 }
755
756 /// The name of the widget.
757 pub fn name(self, name: impl Into<glib::GString>) -> Self {
758 Self {
759 builder: self.builder.property("name", name.into()),
760 }
761 }
762
763 /// The requested opacity of the widget.
764 pub fn opacity(self, opacity: f64) -> Self {
765 Self {
766 builder: self.builder.property("opacity", opacity),
767 }
768 }
769
770 /// How content outside the widget's content area is treated.
771 ///
772 /// This property is meant to be set by widget implementations,
773 /// typically in their instance init function.
774 pub fn overflow(self, overflow: Overflow) -> Self {
775 Self {
776 builder: self.builder.property("overflow", overflow),
777 }
778 }
779
780 /// Whether the widget will receive the default action when it is focused.
781 pub fn receives_default(self, receives_default: bool) -> Self {
782 Self {
783 builder: self.builder.property("receives-default", receives_default),
784 }
785 }
786
787 /// Whether the widget responds to input.
788 pub fn sensitive(self, sensitive: bool) -> Self {
789 Self {
790 builder: self.builder.property("sensitive", sensitive),
791 }
792 }
793
794 /// Sets the text of tooltip to be the given string, which is marked up
795 /// with Pango markup.
796 ///
797 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
798 ///
799 /// This is a convenience property which will take care of getting the
800 /// tooltip shown if the given string is not `NULL`:
801 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
802 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
803 /// the default signal handler.
804 ///
805 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
806 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
807 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
808 Self {
809 builder: self
810 .builder
811 .property("tooltip-markup", tooltip_markup.into()),
812 }
813 }
814
815 /// Sets the text of tooltip to be the given string.
816 ///
817 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
818 ///
819 /// This is a convenience property which will take care of getting the
820 /// tooltip shown if the given string is not `NULL`:
821 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
822 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
823 /// the default signal handler.
824 ///
825 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
826 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
827 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
828 Self {
829 builder: self.builder.property("tooltip-text", tooltip_text.into()),
830 }
831 }
832
833 /// How to distribute vertical space if widget gets extra space.
834 pub fn valign(self, valign: Align) -> Self {
835 Self {
836 builder: self.builder.property("valign", valign),
837 }
838 }
839
840 /// Whether to expand vertically.
841 pub fn vexpand(self, vexpand: bool) -> Self {
842 Self {
843 builder: self.builder.property("vexpand", vexpand),
844 }
845 }
846
847 /// Whether to use the `vexpand` property.
848 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
849 Self {
850 builder: self.builder.property("vexpand-set", vexpand_set),
851 }
852 }
853
854 /// Whether the widget is visible.
855 pub fn visible(self, visible: bool) -> Self {
856 Self {
857 builder: self.builder.property("visible", visible),
858 }
859 }
860
861 /// Overrides for width request of the widget.
862 ///
863 /// If this is -1, the natural request will be used.
864 pub fn width_request(self, width_request: i32) -> Self {
865 Self {
866 builder: self.builder.property("width-request", width_request),
867 }
868 }
869
870 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
871 ///
872 /// The accessible role cannot be changed once set.
873 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
874 Self {
875 builder: self.builder.property("accessible-role", accessible_role),
876 }
877 }
878
879 /// The orientation of the orientable.
880 pub fn orientation(self, orientation: Orientation) -> Self {
881 Self {
882 builder: self.builder.property("orientation", orientation),
883 }
884 }
885
886 // rustdoc-stripper-ignore-next
887 /// Build the [`VolumeButton`].
888 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
889 pub fn build(self) -> VolumeButton {
890 assert_initialized_main_thread!();
891 self.builder.build()
892 }
893}