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    #[doc(alias = "GtkVolumeButton")]
24    pub struct VolumeButton(Object<ffi::GtkVolumeButton>) @extends ScaleButton, Widget, @implements Accessible, Buildable, ConstraintTarget, AccessibleRange, Orientable;
25
26    match fn {
27        type_ => || ffi::gtk_volume_button_get_type(),
28    }
29}
30
31#[cfg(not(any(feature = "v4_10")))]
32glib::wrapper! {
33    #[doc(alias = "GtkVolumeButton")]
34    pub struct VolumeButton(Object<ffi::GtkVolumeButton>) @extends ScaleButton, Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable;
35
36    match fn {
37        type_ => || ffi::gtk_volume_button_get_type(),
38    }
39}
40
41impl VolumeButton {
42    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
43    #[allow(deprecated)]
44    #[doc(alias = "gtk_volume_button_new")]
45    pub fn new() -> VolumeButton {
46        assert_initialized_main_thread!();
47        unsafe { Widget::from_glib_none(ffi::gtk_volume_button_new()).unsafe_cast() }
48    }
49
50    // rustdoc-stripper-ignore-next
51    /// Creates a new builder-pattern struct instance to construct [`VolumeButton`] objects.
52    ///
53    /// This method returns an instance of [`VolumeButtonBuilder`](crate::builders::VolumeButtonBuilder) which can be used to create [`VolumeButton`] objects.
54    pub fn builder() -> VolumeButtonBuilder {
55        VolumeButtonBuilder::new()
56    }
57
58    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
59    #[doc(alias = "use-symbolic")]
60    pub fn uses_symbolic(&self) -> bool {
61        ObjectExt::property(self, "use-symbolic")
62    }
63
64    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
65    #[doc(alias = "use-symbolic")]
66    pub fn set_use_symbolic(&self, use_symbolic: bool) {
67        ObjectExt::set_property(self, "use-symbolic", use_symbolic)
68    }
69
70    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
71    #[doc(alias = "use-symbolic")]
72    pub fn connect_use_symbolic_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
73        unsafe extern "C" fn notify_use_symbolic_trampoline<F: Fn(&VolumeButton) + 'static>(
74            this: *mut ffi::GtkVolumeButton,
75            _param_spec: glib::ffi::gpointer,
76            f: glib::ffi::gpointer,
77        ) {
78            let f: &F = &*(f as *const F);
79            f(&from_glib_borrow(this))
80        }
81        unsafe {
82            let f: Box_<F> = Box_::new(f);
83            connect_raw(
84                self.as_ptr() as *mut _,
85                b"notify::use-symbolic\0".as_ptr() as *const _,
86                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
87                    notify_use_symbolic_trampoline::<F> as *const (),
88                )),
89                Box_::into_raw(f),
90            )
91        }
92    }
93}
94
95impl Default for VolumeButton {
96    fn default() -> Self {
97        Self::new()
98    }
99}
100
101// rustdoc-stripper-ignore-next
102/// A [builder-pattern] type to construct [`VolumeButton`] objects.
103///
104/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
105#[must_use = "The builder must be built to be used"]
106pub struct VolumeButtonBuilder {
107    builder: glib::object::ObjectBuilder<'static, VolumeButton>,
108}
109
110impl VolumeButtonBuilder {
111    fn new() -> Self {
112        Self {
113            builder: glib::object::Object::builder(),
114        }
115    }
116
117    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
118    pub fn use_symbolic(self, use_symbolic: bool) -> Self {
119        Self {
120            builder: self.builder.property("use-symbolic", use_symbolic),
121        }
122    }
123
124    pub fn adjustment(self, adjustment: &impl IsA<Adjustment>) -> Self {
125        Self {
126            builder: self
127                .builder
128                .property("adjustment", adjustment.clone().upcast()),
129        }
130    }
131
132    #[cfg(feature = "v4_14")]
133    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
134    pub fn has_frame(self, has_frame: bool) -> Self {
135        Self {
136            builder: self.builder.property("has-frame", has_frame),
137        }
138    }
139
140    pub fn icons(self, icons: impl Into<glib::StrV>) -> Self {
141        Self {
142            builder: self.builder.property("icons", icons.into()),
143        }
144    }
145
146    pub fn value(self, value: f64) -> Self {
147        Self {
148            builder: self.builder.property("value", value),
149        }
150    }
151
152    pub fn can_focus(self, can_focus: bool) -> Self {
153        Self {
154            builder: self.builder.property("can-focus", can_focus),
155        }
156    }
157
158    pub fn can_target(self, can_target: bool) -> Self {
159        Self {
160            builder: self.builder.property("can-target", can_target),
161        }
162    }
163
164    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
165        Self {
166            builder: self.builder.property("css-classes", css_classes.into()),
167        }
168    }
169
170    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
171        Self {
172            builder: self.builder.property("css-name", css_name.into()),
173        }
174    }
175
176    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
177        Self {
178            builder: self.builder.property("cursor", cursor.clone()),
179        }
180    }
181
182    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
183        Self {
184            builder: self.builder.property("focus-on-click", focus_on_click),
185        }
186    }
187
188    pub fn focusable(self, focusable: bool) -> Self {
189        Self {
190            builder: self.builder.property("focusable", focusable),
191        }
192    }
193
194    pub fn halign(self, halign: Align) -> Self {
195        Self {
196            builder: self.builder.property("halign", halign),
197        }
198    }
199
200    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
201        Self {
202            builder: self.builder.property("has-tooltip", has_tooltip),
203        }
204    }
205
206    pub fn height_request(self, height_request: i32) -> Self {
207        Self {
208            builder: self.builder.property("height-request", height_request),
209        }
210    }
211
212    pub fn hexpand(self, hexpand: bool) -> Self {
213        Self {
214            builder: self.builder.property("hexpand", hexpand),
215        }
216    }
217
218    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
219        Self {
220            builder: self.builder.property("hexpand-set", hexpand_set),
221        }
222    }
223
224    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
225        Self {
226            builder: self
227                .builder
228                .property("layout-manager", layout_manager.clone().upcast()),
229        }
230    }
231
232    #[cfg(feature = "v4_18")]
233    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
234    pub fn limit_events(self, limit_events: bool) -> Self {
235        Self {
236            builder: self.builder.property("limit-events", limit_events),
237        }
238    }
239
240    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
241        Self {
242            builder: self.builder.property("margin-bottom", margin_bottom),
243        }
244    }
245
246    pub fn margin_end(self, margin_end: i32) -> Self {
247        Self {
248            builder: self.builder.property("margin-end", margin_end),
249        }
250    }
251
252    pub fn margin_start(self, margin_start: i32) -> Self {
253        Self {
254            builder: self.builder.property("margin-start", margin_start),
255        }
256    }
257
258    pub fn margin_top(self, margin_top: i32) -> Self {
259        Self {
260            builder: self.builder.property("margin-top", margin_top),
261        }
262    }
263
264    pub fn name(self, name: impl Into<glib::GString>) -> Self {
265        Self {
266            builder: self.builder.property("name", name.into()),
267        }
268    }
269
270    pub fn opacity(self, opacity: f64) -> Self {
271        Self {
272            builder: self.builder.property("opacity", opacity),
273        }
274    }
275
276    pub fn overflow(self, overflow: Overflow) -> Self {
277        Self {
278            builder: self.builder.property("overflow", overflow),
279        }
280    }
281
282    pub fn receives_default(self, receives_default: bool) -> Self {
283        Self {
284            builder: self.builder.property("receives-default", receives_default),
285        }
286    }
287
288    pub fn sensitive(self, sensitive: bool) -> Self {
289        Self {
290            builder: self.builder.property("sensitive", sensitive),
291        }
292    }
293
294    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
295        Self {
296            builder: self
297                .builder
298                .property("tooltip-markup", tooltip_markup.into()),
299        }
300    }
301
302    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
303        Self {
304            builder: self.builder.property("tooltip-text", tooltip_text.into()),
305        }
306    }
307
308    pub fn valign(self, valign: Align) -> Self {
309        Self {
310            builder: self.builder.property("valign", valign),
311        }
312    }
313
314    pub fn vexpand(self, vexpand: bool) -> Self {
315        Self {
316            builder: self.builder.property("vexpand", vexpand),
317        }
318    }
319
320    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
321        Self {
322            builder: self.builder.property("vexpand-set", vexpand_set),
323        }
324    }
325
326    pub fn visible(self, visible: bool) -> Self {
327        Self {
328            builder: self.builder.property("visible", visible),
329        }
330    }
331
332    pub fn width_request(self, width_request: i32) -> Self {
333        Self {
334            builder: self.builder.property("width-request", width_request),
335        }
336    }
337
338    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
339        Self {
340            builder: self.builder.property("accessible-role", accessible_role),
341        }
342    }
343
344    pub fn orientation(self, orientation: Orientation) -> Self {
345        Self {
346            builder: self.builder.property("orientation", orientation),
347        }
348    }
349
350    // rustdoc-stripper-ignore-next
351    /// Build the [`VolumeButton`].
352    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
353    pub fn build(self) -> VolumeButton {
354        assert_initialized_main_thread!();
355        self.builder.build()
356    }
357}