Skip to main content

gtk/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
5use crate::{
6    Actionable, Adjustment, Align, Bin, Buildable, Button, Container, IconSize, Orientable,
7    Orientation, PositionType, ReliefStyle, ResizeMode, ScaleButton, Widget, ffi,
8};
9use glib::{
10    prelude::*,
11    signal::{SignalHandlerId, connect_raw},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    /// [`VolumeButton`][crate::VolumeButton] is a subclass of [`ScaleButton`][crate::ScaleButton] that has
18    /// been tailored for use as a volume control widget with suitable
19    /// icons, tooltips and accessible labels.
20    ///
21    /// ## Properties
22    ///
23    ///
24    /// #### `use-symbolic`
25    ///  Whether to use symbolic icons as the icons. Note that
26    /// if the symbolic icons are not available in your installed
27    /// theme, then the normal (potentially colorful) icons will
28    /// be used.
29    ///
30    /// Readable | Writable | Construct
31    /// <details><summary><h4>ScaleButton</h4></summary>
32    ///
33    ///
34    /// #### `adjustment`
35    ///  Readable | Writable
36    ///
37    ///
38    /// #### `icons`
39    ///  The names of the icons to be used by the scale button.
40    /// The first item in the array will be used in the button
41    /// when the current value is the lowest value, the second
42    /// item for the highest value. All the subsequent icons will
43    /// be used for all the other values, spread evenly over the
44    /// range of values.
45    ///
46    /// If there's only one icon name in the `icons` array, it will
47    /// be used for all the values. If only two icon names are in
48    /// the `icons` array, the first one will be used for the bottom
49    /// 50% of the scale, and the second one for the top 50%.
50    ///
51    /// It is recommended to use at least 3 icons so that the
52    /// [`ScaleButton`][crate::ScaleButton] reflects the current value of the scale
53    /// better for the users.
54    ///
55    /// Readable | Writable
56    ///
57    ///
58    /// #### `size`
59    ///  Readable | Writable
60    ///
61    ///
62    /// #### `value`
63    ///  Readable | Writable
64    /// </details>
65    /// <details><summary><h4>Button</h4></summary>
66    ///
67    ///
68    /// #### `always-show-image`
69    ///  If [`true`], the button will ignore the [`gtk-button-images`][struct@crate::Settings#gtk-button-images]
70    /// setting and always show the image, if available.
71    ///
72    /// Use this property if the button would be useless or hard to use
73    /// without the image.
74    ///
75    /// Readable | Writable | Construct
76    ///
77    ///
78    /// #### `image`
79    ///  The child widget to appear next to the button text.
80    ///
81    /// Readable | Writable
82    ///
83    ///
84    /// #### `image-position`
85    ///  The position of the image relative to the text inside the button.
86    ///
87    /// Readable | Writable
88    ///
89    ///
90    /// #### `label`
91    ///  Readable | Writable | Construct
92    ///
93    ///
94    /// #### `relief`
95    ///  Readable | Writable
96    ///
97    ///
98    /// #### `use-stock`
99    ///  Readable | Writable | Construct
100    ///
101    ///
102    /// #### `use-underline`
103    ///  Readable | Writable | Construct
104    ///
105    ///
106    /// #### `xalign`
107    ///  If the child of the button is a [`Misc`][crate::Misc] or `GtkAlignment`, this property
108    /// can be used to control its horizontal alignment. 0.0 is left aligned,
109    /// 1.0 is right aligned.
110    ///
111    /// Readable | Writable
112    ///
113    ///
114    /// #### `yalign`
115    ///  If the child of the button is a [`Misc`][crate::Misc] or `GtkAlignment`, this property
116    /// can be used to control its vertical alignment. 0.0 is top aligned,
117    /// 1.0 is bottom aligned.
118    ///
119    /// Readable | Writable
120    /// </details>
121    /// <details><summary><h4>Container</h4></summary>
122    ///
123    ///
124    /// #### `border-width`
125    ///  Readable | Writable
126    ///
127    ///
128    /// #### `child`
129    ///  Writable
130    ///
131    ///
132    /// #### `resize-mode`
133    ///  Readable | Writable
134    /// </details>
135    /// <details><summary><h4>Widget</h4></summary>
136    ///
137    ///
138    /// #### `app-paintable`
139    ///  Readable | Writable
140    ///
141    ///
142    /// #### `can-default`
143    ///  Readable | Writable
144    ///
145    ///
146    /// #### `can-focus`
147    ///  Readable | Writable
148    ///
149    ///
150    /// #### `composite-child`
151    ///  Readable
152    ///
153    ///
154    /// #### `double-buffered`
155    ///  Whether the widget is double buffered.
156    ///
157    /// Readable | Writable
158    ///
159    ///
160    /// #### `events`
161    ///  Readable | Writable
162    ///
163    ///
164    /// #### `expand`
165    ///  Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
166    ///
167    /// Readable | Writable
168    ///
169    ///
170    /// #### `focus-on-click`
171    ///  Whether the widget should grab focus when it is clicked with the mouse.
172    ///
173    /// This property is only relevant for widgets that can take focus.
174    ///
175    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
176    /// GtkComboBox) implemented this property individually.
177    ///
178    /// Readable | Writable
179    ///
180    ///
181    /// #### `halign`
182    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
183    ///
184    /// Readable | Writable
185    ///
186    ///
187    /// #### `has-default`
188    ///  Readable | Writable
189    ///
190    ///
191    /// #### `has-focus`
192    ///  Readable | Writable
193    ///
194    ///
195    /// #### `has-tooltip`
196    ///  Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
197    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
198    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
199    /// whether it will provide a tooltip or not.
200    ///
201    /// Note that setting this property to [`true`] for the first time will change
202    /// the event masks of the GdkWindows of this widget to include leave-notify
203    /// and motion-notify events. This cannot and will not be undone when the
204    /// property is set to [`false`] again.
205    ///
206    /// Readable | Writable
207    ///
208    ///
209    /// #### `height-request`
210    ///  Readable | Writable
211    ///
212    ///
213    /// #### `hexpand`
214    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
215    ///
216    /// Readable | Writable
217    ///
218    ///
219    /// #### `hexpand-set`
220    ///  Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
221    ///
222    /// Readable | Writable
223    ///
224    ///
225    /// #### `is-focus`
226    ///  Readable | Writable
227    ///
228    ///
229    /// #### `margin`
230    ///  Sets all four sides' margin at once. If read, returns max
231    /// margin on any side.
232    ///
233    /// Readable | Writable
234    ///
235    ///
236    /// #### `margin-bottom`
237    ///  Margin on bottom side of widget.
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 | Writable
244    ///
245    ///
246    /// #### `margin-end`
247    ///  Margin on end of widget, horizontally. This property supports
248    /// left-to-right and right-to-left text directions.
249    ///
250    /// This property adds margin outside of the widget's normal size
251    /// request, the margin will be added in addition to the size from
252    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
253    ///
254    /// Readable | Writable
255    ///
256    ///
257    /// #### `margin-left`
258    ///  Margin on left side of widget.
259    ///
260    /// This property adds margin outside of the widget's normal size
261    /// request, the margin will be added in addition to the size from
262    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
263    ///
264    /// Readable | Writable
265    ///
266    ///
267    /// #### `margin-right`
268    ///  Margin on right side of widget.
269    ///
270    /// This property adds margin outside of the widget's normal size
271    /// request, the margin will be added in addition to the size from
272    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
273    ///
274    /// Readable | Writable
275    ///
276    ///
277    /// #### `margin-start`
278    ///  Margin on start of widget, horizontally. This property supports
279    /// left-to-right and right-to-left text directions.
280    ///
281    /// This property adds margin outside of the widget's normal size
282    /// request, the margin will be added in addition to the size from
283    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
284    ///
285    /// Readable | Writable
286    ///
287    ///
288    /// #### `margin-top`
289    ///  Margin on top side of widget.
290    ///
291    /// This property adds margin outside of the widget's normal size
292    /// request, the margin will be added in addition to the size from
293    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
294    ///
295    /// Readable | Writable
296    ///
297    ///
298    /// #### `name`
299    ///  Readable | Writable
300    ///
301    ///
302    /// #### `no-show-all`
303    ///  Readable | Writable
304    ///
305    ///
306    /// #### `opacity`
307    ///  The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
308    /// more details about window opacity.
309    ///
310    /// Before 3.8 this was only available in GtkWindow
311    ///
312    /// Readable | Writable
313    ///
314    ///
315    /// #### `parent`
316    ///  Readable | Writable
317    ///
318    ///
319    /// #### `receives-default`
320    ///  Readable | Writable
321    ///
322    ///
323    /// #### `scale-factor`
324    ///  The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
325    /// more details about widget scaling.
326    ///
327    /// Readable
328    ///
329    ///
330    /// #### `sensitive`
331    ///  Readable | Writable
332    ///
333    ///
334    /// #### `style`
335    ///  The style of the widget, which contains information about how it will look (colors, etc).
336    ///
337    /// Readable | Writable
338    ///
339    ///
340    /// #### `tooltip-markup`
341    ///  Sets the text of tooltip to be the given string, which is marked up
342    /// with the [Pango text markup language][PangoMarkupFormat].
343    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
344    ///
345    /// This is a convenience property which will take care of getting the
346    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
347    /// will automatically be set to [`true`] and there will be taken care of
348    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
349    ///
350    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
351    /// are set, the last one wins.
352    ///
353    /// Readable | Writable
354    ///
355    ///
356    /// #### `tooltip-text`
357    ///  Sets the text of tooltip to be the given string.
358    ///
359    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
360    ///
361    /// This is a convenience property which will take care of getting the
362    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
363    /// will automatically be set to [`true`] and there will be taken care of
364    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
365    ///
366    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
367    /// are set, the last one wins.
368    ///
369    /// Readable | Writable
370    ///
371    ///
372    /// #### `valign`
373    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
374    ///
375    /// Readable | Writable
376    ///
377    ///
378    /// #### `vexpand`
379    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
380    ///
381    /// Readable | Writable
382    ///
383    ///
384    /// #### `vexpand-set`
385    ///  Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
386    ///
387    /// Readable | Writable
388    ///
389    ///
390    /// #### `visible`
391    ///  Readable | Writable
392    ///
393    ///
394    /// #### `width-request`
395    ///  Readable | Writable
396    ///
397    ///
398    /// #### `window`
399    ///  The widget's window if it is realized, [`None`] otherwise.
400    ///
401    /// Readable
402    /// </details>
403    /// <details><summary><h4>Actionable</h4></summary>
404    ///
405    ///
406    /// #### `action-name`
407    ///  Readable | Writable
408    ///
409    ///
410    /// #### `action-target`
411    ///  Readable | Writable
412    /// </details>
413    /// <details><summary><h4>Activatable</h4></summary>
414    ///
415    ///
416    /// #### `related-action`
417    ///   call `gtk_activatable_do_set_related_action()` when it changes.
418    ///
419    /// Readable | Writable
420    ///
421    ///
422    /// #### `use-action-appearance`
423    ///   widget when it changes.
424    ///
425    /// Readable | Writable
426    /// </details>
427    /// <details><summary><h4>Orientable</h4></summary>
428    ///
429    ///
430    /// #### `orientation`
431    ///  The orientation of the orientable.
432    ///
433    /// Readable | Writable
434    /// </details>
435    ///
436    /// # Implements
437    ///
438    /// [`VolumeButtonExt`][trait@crate::prelude::VolumeButtonExt], [`ScaleButtonExt`][trait@crate::prelude::ScaleButtonExt], [`ButtonExt`][trait@crate::prelude::ButtonExt], [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ActionableExt`][trait@crate::prelude::ActionableExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
439    #[doc(alias = "GtkVolumeButton")]
440    pub struct VolumeButton(Object<ffi::GtkVolumeButton, ffi::GtkVolumeButtonClass>) @extends ScaleButton, Button, Bin, Container, Widget, @implements Buildable, Actionable, Orientable;
441
442    match fn {
443        type_ => || ffi::gtk_volume_button_get_type(),
444    }
445}
446
447impl VolumeButton {
448    pub const NONE: Option<&'static VolumeButton> = None;
449
450    /// Creates a [`VolumeButton`][crate::VolumeButton], with a range between 0.0 and 1.0, with
451    /// a stepping of 0.02. Volume values can be obtained and modified using
452    /// the functions from [`ScaleButton`][crate::ScaleButton].
453    ///
454    /// # Returns
455    ///
456    /// a new [`VolumeButton`][crate::VolumeButton]
457    #[doc(alias = "gtk_volume_button_new")]
458    pub fn new() -> VolumeButton {
459        assert_initialized_main_thread!();
460        unsafe { Widget::from_glib_none(ffi::gtk_volume_button_new()).unsafe_cast() }
461    }
462
463    // rustdoc-stripper-ignore-next
464    /// Creates a new builder-pattern struct instance to construct [`VolumeButton`] objects.
465    ///
466    /// This method returns an instance of [`VolumeButtonBuilder`](crate::builders::VolumeButtonBuilder) which can be used to create [`VolumeButton`] objects.
467    pub fn builder() -> VolumeButtonBuilder {
468        VolumeButtonBuilder::new()
469    }
470}
471
472impl Default for VolumeButton {
473    fn default() -> Self {
474        Self::new()
475    }
476}
477
478// rustdoc-stripper-ignore-next
479/// A [builder-pattern] type to construct [`VolumeButton`] objects.
480///
481/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
482#[must_use = "The builder must be built to be used"]
483pub struct VolumeButtonBuilder {
484    builder: glib::object::ObjectBuilder<'static, VolumeButton>,
485}
486
487impl VolumeButtonBuilder {
488    fn new() -> Self {
489        Self {
490            builder: glib::object::Object::builder(),
491        }
492    }
493
494    /// Whether to use symbolic icons as the icons. Note that
495    /// if the symbolic icons are not available in your installed
496    /// theme, then the normal (potentially colorful) icons will
497    /// be used.
498    pub fn use_symbolic(self, use_symbolic: bool) -> Self {
499        Self {
500            builder: self.builder.property("use-symbolic", use_symbolic),
501        }
502    }
503
504    pub fn adjustment(self, adjustment: &impl IsA<Adjustment>) -> Self {
505        Self {
506            builder: self
507                .builder
508                .property("adjustment", adjustment.clone().upcast()),
509        }
510    }
511
512    /// The names of the icons to be used by the scale button.
513    /// The first item in the array will be used in the button
514    /// when the current value is the lowest value, the second
515    /// item for the highest value. All the subsequent icons will
516    /// be used for all the other values, spread evenly over the
517    /// range of values.
518    ///
519    /// If there's only one icon name in the `icons` array, it will
520    /// be used for all the values. If only two icon names are in
521    /// the `icons` array, the first one will be used for the bottom
522    /// 50% of the scale, and the second one for the top 50%.
523    ///
524    /// It is recommended to use at least 3 icons so that the
525    /// [`ScaleButton`][crate::ScaleButton] reflects the current value of the scale
526    /// better for the users.
527    pub fn icons(self, icons: impl Into<glib::StrV>) -> Self {
528        Self {
529            builder: self.builder.property("icons", icons.into()),
530        }
531    }
532
533    pub fn size(self, size: IconSize) -> Self {
534        Self {
535            builder: self.builder.property("size", size),
536        }
537    }
538
539    pub fn value(self, value: f64) -> Self {
540        Self {
541            builder: self.builder.property("value", value),
542        }
543    }
544
545    /// If [`true`], the button will ignore the [`gtk-button-images`][struct@crate::Settings#gtk-button-images]
546    /// setting and always show the image, if available.
547    ///
548    /// Use this property if the button would be useless or hard to use
549    /// without the image.
550    pub fn always_show_image(self, always_show_image: bool) -> Self {
551        Self {
552            builder: self
553                .builder
554                .property("always-show-image", always_show_image),
555        }
556    }
557
558    /// The child widget to appear next to the button text.
559    pub fn image(self, image: &impl IsA<Widget>) -> Self {
560        Self {
561            builder: self.builder.property("image", image.clone().upcast()),
562        }
563    }
564
565    /// The position of the image relative to the text inside the button.
566    pub fn image_position(self, image_position: PositionType) -> Self {
567        Self {
568            builder: self.builder.property("image-position", image_position),
569        }
570    }
571
572    pub fn label(self, label: impl Into<glib::GString>) -> Self {
573        Self {
574            builder: self.builder.property("label", label.into()),
575        }
576    }
577
578    pub fn relief(self, relief: ReliefStyle) -> Self {
579        Self {
580            builder: self.builder.property("relief", relief),
581        }
582    }
583
584    pub fn use_underline(self, use_underline: bool) -> Self {
585        Self {
586            builder: self.builder.property("use-underline", use_underline),
587        }
588    }
589
590    pub fn border_width(self, border_width: u32) -> Self {
591        Self {
592            builder: self.builder.property("border-width", border_width),
593        }
594    }
595
596    pub fn child(self, child: &impl IsA<Widget>) -> Self {
597        Self {
598            builder: self.builder.property("child", child.clone().upcast()),
599        }
600    }
601
602    pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
603        Self {
604            builder: self.builder.property("resize-mode", resize_mode),
605        }
606    }
607
608    pub fn app_paintable(self, app_paintable: bool) -> Self {
609        Self {
610            builder: self.builder.property("app-paintable", app_paintable),
611        }
612    }
613
614    pub fn can_default(self, can_default: bool) -> Self {
615        Self {
616            builder: self.builder.property("can-default", can_default),
617        }
618    }
619
620    pub fn can_focus(self, can_focus: bool) -> Self {
621        Self {
622            builder: self.builder.property("can-focus", can_focus),
623        }
624    }
625
626    pub fn events(self, events: gdk::EventMask) -> Self {
627        Self {
628            builder: self.builder.property("events", events),
629        }
630    }
631
632    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
633    pub fn expand(self, expand: bool) -> Self {
634        Self {
635            builder: self.builder.property("expand", expand),
636        }
637    }
638
639    /// Whether the widget should grab focus when it is clicked with the mouse.
640    ///
641    /// This property is only relevant for widgets that can take focus.
642    ///
643    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
644    /// GtkComboBox) implemented this property individually.
645    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
646        Self {
647            builder: self.builder.property("focus-on-click", focus_on_click),
648        }
649    }
650
651    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
652    pub fn halign(self, halign: Align) -> Self {
653        Self {
654            builder: self.builder.property("halign", halign),
655        }
656    }
657
658    pub fn has_default(self, has_default: bool) -> Self {
659        Self {
660            builder: self.builder.property("has-default", has_default),
661        }
662    }
663
664    pub fn has_focus(self, has_focus: bool) -> Self {
665        Self {
666            builder: self.builder.property("has-focus", has_focus),
667        }
668    }
669
670    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
671    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
672    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
673    /// whether it will provide a tooltip or not.
674    ///
675    /// Note that setting this property to [`true`] for the first time will change
676    /// the event masks of the GdkWindows of this widget to include leave-notify
677    /// and motion-notify events. This cannot and will not be undone when the
678    /// property is set to [`false`] again.
679    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
680        Self {
681            builder: self.builder.property("has-tooltip", has_tooltip),
682        }
683    }
684
685    pub fn height_request(self, height_request: i32) -> Self {
686        Self {
687            builder: self.builder.property("height-request", height_request),
688        }
689    }
690
691    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
692    pub fn hexpand(self, hexpand: bool) -> Self {
693        Self {
694            builder: self.builder.property("hexpand", hexpand),
695        }
696    }
697
698    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
699    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
700        Self {
701            builder: self.builder.property("hexpand-set", hexpand_set),
702        }
703    }
704
705    pub fn is_focus(self, is_focus: bool) -> Self {
706        Self {
707            builder: self.builder.property("is-focus", is_focus),
708        }
709    }
710
711    /// Sets all four sides' margin at once. If read, returns max
712    /// margin on any side.
713    pub fn margin(self, margin: i32) -> Self {
714        Self {
715            builder: self.builder.property("margin", margin),
716        }
717    }
718
719    /// Margin on bottom side of widget.
720    ///
721    /// This property adds margin outside of the widget's normal size
722    /// request, the margin will be added in addition to the size from
723    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
724    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
725        Self {
726            builder: self.builder.property("margin-bottom", margin_bottom),
727        }
728    }
729
730    /// Margin on end of widget, horizontally. This property supports
731    /// left-to-right and right-to-left text directions.
732    ///
733    /// This property adds margin outside of the widget's normal size
734    /// request, the margin will be added in addition to the size from
735    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
736    pub fn margin_end(self, margin_end: i32) -> Self {
737        Self {
738            builder: self.builder.property("margin-end", margin_end),
739        }
740    }
741
742    /// Margin on start of widget, horizontally. This property supports
743    /// left-to-right and right-to-left text directions.
744    ///
745    /// This property adds margin outside of the widget's normal size
746    /// request, the margin will be added in addition to the size from
747    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
748    pub fn margin_start(self, margin_start: i32) -> Self {
749        Self {
750            builder: self.builder.property("margin-start", margin_start),
751        }
752    }
753
754    /// Margin on top side of widget.
755    ///
756    /// This property adds margin outside of the widget's normal size
757    /// request, the margin will be added in addition to the size from
758    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
759    pub fn margin_top(self, margin_top: i32) -> Self {
760        Self {
761            builder: self.builder.property("margin-top", margin_top),
762        }
763    }
764
765    pub fn name(self, name: impl Into<glib::GString>) -> Self {
766        Self {
767            builder: self.builder.property("name", name.into()),
768        }
769    }
770
771    pub fn no_show_all(self, no_show_all: bool) -> Self {
772        Self {
773            builder: self.builder.property("no-show-all", no_show_all),
774        }
775    }
776
777    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
778    /// more details about window opacity.
779    ///
780    /// Before 3.8 this was only available in GtkWindow
781    pub fn opacity(self, opacity: f64) -> Self {
782        Self {
783            builder: self.builder.property("opacity", opacity),
784        }
785    }
786
787    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
788        Self {
789            builder: self.builder.property("parent", parent.clone().upcast()),
790        }
791    }
792
793    pub fn receives_default(self, receives_default: bool) -> Self {
794        Self {
795            builder: self.builder.property("receives-default", receives_default),
796        }
797    }
798
799    pub fn sensitive(self, sensitive: bool) -> Self {
800        Self {
801            builder: self.builder.property("sensitive", sensitive),
802        }
803    }
804
805    /// Sets the text of tooltip to be the given string, which is marked up
806    /// with the [Pango text markup language][PangoMarkupFormat].
807    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
808    ///
809    /// This is a convenience property which will take care of getting the
810    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
811    /// will automatically be set to [`true`] and there will be taken care of
812    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
813    ///
814    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
815    /// are set, the last one wins.
816    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
817        Self {
818            builder: self
819                .builder
820                .property("tooltip-markup", tooltip_markup.into()),
821        }
822    }
823
824    /// Sets the text of tooltip to be the given string.
825    ///
826    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
827    ///
828    /// This is a convenience property which will take care of getting the
829    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
830    /// will automatically be set to [`true`] and there will be taken care of
831    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
832    ///
833    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
834    /// are set, the last one wins.
835    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
836        Self {
837            builder: self.builder.property("tooltip-text", tooltip_text.into()),
838        }
839    }
840
841    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
842    pub fn valign(self, valign: Align) -> Self {
843        Self {
844            builder: self.builder.property("valign", valign),
845        }
846    }
847
848    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
849    pub fn vexpand(self, vexpand: bool) -> Self {
850        Self {
851            builder: self.builder.property("vexpand", vexpand),
852        }
853    }
854
855    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
856    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
857        Self {
858            builder: self.builder.property("vexpand-set", vexpand_set),
859        }
860    }
861
862    pub fn visible(self, visible: bool) -> Self {
863        Self {
864            builder: self.builder.property("visible", visible),
865        }
866    }
867
868    pub fn width_request(self, width_request: i32) -> Self {
869        Self {
870            builder: self.builder.property("width-request", width_request),
871        }
872    }
873
874    pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
875        Self {
876            builder: self.builder.property("action-name", action_name.into()),
877        }
878    }
879
880    pub fn action_target(self, action_target: &glib::Variant) -> Self {
881        Self {
882            builder: self
883                .builder
884                .property("action-target", action_target.clone()),
885        }
886    }
887
888    /// The orientation of the orientable.
889    pub fn orientation(self, orientation: Orientation) -> Self {
890        Self {
891            builder: self.builder.property("orientation", orientation),
892        }
893    }
894
895    // rustdoc-stripper-ignore-next
896    /// Build the [`VolumeButton`].
897    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
898    pub fn build(self) -> VolumeButton {
899        assert_initialized_main_thread!();
900        self.builder.build()
901    }
902}
903
904/// Trait containing all [`struct@VolumeButton`] methods.
905///
906/// # Implementors
907///
908/// [`VolumeButton`][struct@crate::VolumeButton]
909pub trait VolumeButtonExt: IsA<VolumeButton> + 'static {
910    /// Whether to use symbolic icons as the icons. Note that
911    /// if the symbolic icons are not available in your installed
912    /// theme, then the normal (potentially colorful) icons will
913    /// be used.
914    #[doc(alias = "use-symbolic")]
915    fn uses_symbolic(&self) -> bool {
916        ObjectExt::property(self.as_ref(), "use-symbolic")
917    }
918
919    /// Whether to use symbolic icons as the icons. Note that
920    /// if the symbolic icons are not available in your installed
921    /// theme, then the normal (potentially colorful) icons will
922    /// be used.
923    #[doc(alias = "use-symbolic")]
924    fn set_use_symbolic(&self, use_symbolic: bool) {
925        ObjectExt::set_property(self.as_ref(), "use-symbolic", use_symbolic)
926    }
927
928    #[doc(alias = "use-symbolic")]
929    fn connect_use_symbolic_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
930        unsafe extern "C" fn notify_use_symbolic_trampoline<
931            P: IsA<VolumeButton>,
932            F: Fn(&P) + 'static,
933        >(
934            this: *mut ffi::GtkVolumeButton,
935            _param_spec: glib::ffi::gpointer,
936            f: glib::ffi::gpointer,
937        ) {
938            unsafe {
939                let f: &F = &*(f as *const F);
940                f(VolumeButton::from_glib_borrow(this).unsafe_cast_ref())
941            }
942        }
943        unsafe {
944            let f: Box_<F> = Box_::new(f);
945            connect_raw(
946                self.as_ptr() as *mut _,
947                c"notify::use-symbolic".as_ptr(),
948                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
949                    notify_use_symbolic_trampoline::<Self, F> as *const (),
950                )),
951                Box_::into_raw(f),
952            )
953        }
954    }
955}
956
957impl<O: IsA<VolumeButton>> VolumeButtonExt for O {}