[go: up one dir, main page]

gtk4/auto/
window_controls.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    ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow,
7    PackType, Widget,
8};
9use glib::{
10    prelude::*,
11    signal::{connect_raw, SignalHandlerId},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    #[doc(alias = "GtkWindowControls")]
18    pub struct WindowControls(Object<ffi::GtkWindowControls, ffi::GtkWindowControlsClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
19
20    match fn {
21        type_ => || ffi::gtk_window_controls_get_type(),
22    }
23}
24
25impl WindowControls {
26    #[doc(alias = "gtk_window_controls_new")]
27    pub fn new(side: PackType) -> WindowControls {
28        assert_initialized_main_thread!();
29        unsafe {
30            Widget::from_glib_none(ffi::gtk_window_controls_new(side.into_glib())).unsafe_cast()
31        }
32    }
33
34    // rustdoc-stripper-ignore-next
35    /// Creates a new builder-pattern struct instance to construct [`WindowControls`] objects.
36    ///
37    /// This method returns an instance of [`WindowControlsBuilder`](crate::builders::WindowControlsBuilder) which can be used to create [`WindowControls`] objects.
38    pub fn builder() -> WindowControlsBuilder {
39        WindowControlsBuilder::new()
40    }
41
42    #[doc(alias = "gtk_window_controls_get_decoration_layout")]
43    #[doc(alias = "get_decoration_layout")]
44    #[doc(alias = "decoration-layout")]
45    pub fn decoration_layout(&self) -> Option<glib::GString> {
46        unsafe {
47            from_glib_none(ffi::gtk_window_controls_get_decoration_layout(
48                self.to_glib_none().0,
49            ))
50        }
51    }
52
53    #[doc(alias = "gtk_window_controls_get_empty")]
54    #[doc(alias = "get_empty")]
55    #[doc(alias = "empty")]
56    pub fn is_empty(&self) -> bool {
57        unsafe { from_glib(ffi::gtk_window_controls_get_empty(self.to_glib_none().0)) }
58    }
59
60    #[doc(alias = "gtk_window_controls_get_side")]
61    #[doc(alias = "get_side")]
62    pub fn side(&self) -> PackType {
63        unsafe { from_glib(ffi::gtk_window_controls_get_side(self.to_glib_none().0)) }
64    }
65
66    #[cfg(feature = "v4_18")]
67    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
68    #[doc(alias = "gtk_window_controls_get_use_native_controls")]
69    #[doc(alias = "get_use_native_controls")]
70    #[doc(alias = "use-native-controls")]
71    pub fn uses_native_controls(&self) -> bool {
72        unsafe {
73            from_glib(ffi::gtk_window_controls_get_use_native_controls(
74                self.to_glib_none().0,
75            ))
76        }
77    }
78
79    #[doc(alias = "gtk_window_controls_set_decoration_layout")]
80    #[doc(alias = "decoration-layout")]
81    pub fn set_decoration_layout(&self, layout: Option<&str>) {
82        unsafe {
83            ffi::gtk_window_controls_set_decoration_layout(
84                self.to_glib_none().0,
85                layout.to_glib_none().0,
86            );
87        }
88    }
89
90    #[doc(alias = "gtk_window_controls_set_side")]
91    #[doc(alias = "side")]
92    pub fn set_side(&self, side: PackType) {
93        unsafe {
94            ffi::gtk_window_controls_set_side(self.to_glib_none().0, side.into_glib());
95        }
96    }
97
98    #[cfg(feature = "v4_18")]
99    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
100    #[doc(alias = "gtk_window_controls_set_use_native_controls")]
101    #[doc(alias = "use-native-controls")]
102    pub fn set_use_native_controls(&self, setting: bool) {
103        unsafe {
104            ffi::gtk_window_controls_set_use_native_controls(
105                self.to_glib_none().0,
106                setting.into_glib(),
107            );
108        }
109    }
110
111    #[doc(alias = "decoration-layout")]
112    pub fn connect_decoration_layout_notify<F: Fn(&Self) + 'static>(
113        &self,
114        f: F,
115    ) -> SignalHandlerId {
116        unsafe extern "C" fn notify_decoration_layout_trampoline<
117            F: Fn(&WindowControls) + 'static,
118        >(
119            this: *mut ffi::GtkWindowControls,
120            _param_spec: glib::ffi::gpointer,
121            f: glib::ffi::gpointer,
122        ) {
123            let f: &F = &*(f as *const F);
124            f(&from_glib_borrow(this))
125        }
126        unsafe {
127            let f: Box_<F> = Box_::new(f);
128            connect_raw(
129                self.as_ptr() as *mut _,
130                c"notify::decoration-layout".as_ptr() as *const _,
131                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
132                    notify_decoration_layout_trampoline::<F> as *const (),
133                )),
134                Box_::into_raw(f),
135            )
136        }
137    }
138
139    #[doc(alias = "empty")]
140    pub fn connect_empty_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
141        unsafe extern "C" fn notify_empty_trampoline<F: Fn(&WindowControls) + 'static>(
142            this: *mut ffi::GtkWindowControls,
143            _param_spec: glib::ffi::gpointer,
144            f: glib::ffi::gpointer,
145        ) {
146            let f: &F = &*(f as *const F);
147            f(&from_glib_borrow(this))
148        }
149        unsafe {
150            let f: Box_<F> = Box_::new(f);
151            connect_raw(
152                self.as_ptr() as *mut _,
153                c"notify::empty".as_ptr() as *const _,
154                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
155                    notify_empty_trampoline::<F> as *const (),
156                )),
157                Box_::into_raw(f),
158            )
159        }
160    }
161
162    #[doc(alias = "side")]
163    pub fn connect_side_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
164        unsafe extern "C" fn notify_side_trampoline<F: Fn(&WindowControls) + 'static>(
165            this: *mut ffi::GtkWindowControls,
166            _param_spec: glib::ffi::gpointer,
167            f: glib::ffi::gpointer,
168        ) {
169            let f: &F = &*(f as *const F);
170            f(&from_glib_borrow(this))
171        }
172        unsafe {
173            let f: Box_<F> = Box_::new(f);
174            connect_raw(
175                self.as_ptr() as *mut _,
176                c"notify::side".as_ptr() as *const _,
177                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
178                    notify_side_trampoline::<F> as *const (),
179                )),
180                Box_::into_raw(f),
181            )
182        }
183    }
184
185    #[cfg(feature = "v4_18")]
186    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
187    #[doc(alias = "use-native-controls")]
188    pub fn connect_use_native_controls_notify<F: Fn(&Self) + 'static>(
189        &self,
190        f: F,
191    ) -> SignalHandlerId {
192        unsafe extern "C" fn notify_use_native_controls_trampoline<
193            F: Fn(&WindowControls) + 'static,
194        >(
195            this: *mut ffi::GtkWindowControls,
196            _param_spec: glib::ffi::gpointer,
197            f: glib::ffi::gpointer,
198        ) {
199            let f: &F = &*(f as *const F);
200            f(&from_glib_borrow(this))
201        }
202        unsafe {
203            let f: Box_<F> = Box_::new(f);
204            connect_raw(
205                self.as_ptr() as *mut _,
206                c"notify::use-native-controls".as_ptr() as *const _,
207                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
208                    notify_use_native_controls_trampoline::<F> as *const (),
209                )),
210                Box_::into_raw(f),
211            )
212        }
213    }
214}
215
216impl Default for WindowControls {
217    fn default() -> Self {
218        glib::object::Object::new::<Self>()
219    }
220}
221
222// rustdoc-stripper-ignore-next
223/// A [builder-pattern] type to construct [`WindowControls`] objects.
224///
225/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
226#[must_use = "The builder must be built to be used"]
227pub struct WindowControlsBuilder {
228    builder: glib::object::ObjectBuilder<'static, WindowControls>,
229}
230
231impl WindowControlsBuilder {
232    fn new() -> Self {
233        Self {
234            builder: glib::object::Object::builder(),
235        }
236    }
237
238    pub fn decoration_layout(self, decoration_layout: impl Into<glib::GString>) -> Self {
239        Self {
240            builder: self
241                .builder
242                .property("decoration-layout", decoration_layout.into()),
243        }
244    }
245
246    pub fn side(self, side: PackType) -> Self {
247        Self {
248            builder: self.builder.property("side", side),
249        }
250    }
251
252    #[cfg(feature = "v4_18")]
253    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
254    pub fn use_native_controls(self, use_native_controls: bool) -> Self {
255        Self {
256            builder: self
257                .builder
258                .property("use-native-controls", use_native_controls),
259        }
260    }
261
262    pub fn can_focus(self, can_focus: bool) -> Self {
263        Self {
264            builder: self.builder.property("can-focus", can_focus),
265        }
266    }
267
268    pub fn can_target(self, can_target: bool) -> Self {
269        Self {
270            builder: self.builder.property("can-target", can_target),
271        }
272    }
273
274    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
275        Self {
276            builder: self.builder.property("css-classes", css_classes.into()),
277        }
278    }
279
280    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
281        Self {
282            builder: self.builder.property("css-name", css_name.into()),
283        }
284    }
285
286    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
287        Self {
288            builder: self.builder.property("cursor", cursor.clone()),
289        }
290    }
291
292    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
293        Self {
294            builder: self.builder.property("focus-on-click", focus_on_click),
295        }
296    }
297
298    pub fn focusable(self, focusable: bool) -> Self {
299        Self {
300            builder: self.builder.property("focusable", focusable),
301        }
302    }
303
304    pub fn halign(self, halign: Align) -> Self {
305        Self {
306            builder: self.builder.property("halign", halign),
307        }
308    }
309
310    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
311        Self {
312            builder: self.builder.property("has-tooltip", has_tooltip),
313        }
314    }
315
316    pub fn height_request(self, height_request: i32) -> Self {
317        Self {
318            builder: self.builder.property("height-request", height_request),
319        }
320    }
321
322    pub fn hexpand(self, hexpand: bool) -> Self {
323        Self {
324            builder: self.builder.property("hexpand", hexpand),
325        }
326    }
327
328    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
329        Self {
330            builder: self.builder.property("hexpand-set", hexpand_set),
331        }
332    }
333
334    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
335        Self {
336            builder: self
337                .builder
338                .property("layout-manager", layout_manager.clone().upcast()),
339        }
340    }
341
342    #[cfg(feature = "v4_18")]
343    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
344    pub fn limit_events(self, limit_events: bool) -> Self {
345        Self {
346            builder: self.builder.property("limit-events", limit_events),
347        }
348    }
349
350    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
351        Self {
352            builder: self.builder.property("margin-bottom", margin_bottom),
353        }
354    }
355
356    pub fn margin_end(self, margin_end: i32) -> Self {
357        Self {
358            builder: self.builder.property("margin-end", margin_end),
359        }
360    }
361
362    pub fn margin_start(self, margin_start: i32) -> Self {
363        Self {
364            builder: self.builder.property("margin-start", margin_start),
365        }
366    }
367
368    pub fn margin_top(self, margin_top: i32) -> Self {
369        Self {
370            builder: self.builder.property("margin-top", margin_top),
371        }
372    }
373
374    pub fn name(self, name: impl Into<glib::GString>) -> Self {
375        Self {
376            builder: self.builder.property("name", name.into()),
377        }
378    }
379
380    pub fn opacity(self, opacity: f64) -> Self {
381        Self {
382            builder: self.builder.property("opacity", opacity),
383        }
384    }
385
386    pub fn overflow(self, overflow: Overflow) -> Self {
387        Self {
388            builder: self.builder.property("overflow", overflow),
389        }
390    }
391
392    pub fn receives_default(self, receives_default: bool) -> Self {
393        Self {
394            builder: self.builder.property("receives-default", receives_default),
395        }
396    }
397
398    pub fn sensitive(self, sensitive: bool) -> Self {
399        Self {
400            builder: self.builder.property("sensitive", sensitive),
401        }
402    }
403
404    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
405        Self {
406            builder: self
407                .builder
408                .property("tooltip-markup", tooltip_markup.into()),
409        }
410    }
411
412    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
413        Self {
414            builder: self.builder.property("tooltip-text", tooltip_text.into()),
415        }
416    }
417
418    pub fn valign(self, valign: Align) -> Self {
419        Self {
420            builder: self.builder.property("valign", valign),
421        }
422    }
423
424    pub fn vexpand(self, vexpand: bool) -> Self {
425        Self {
426            builder: self.builder.property("vexpand", vexpand),
427        }
428    }
429
430    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
431        Self {
432            builder: self.builder.property("vexpand-set", vexpand_set),
433        }
434    }
435
436    pub fn visible(self, visible: bool) -> Self {
437        Self {
438            builder: self.builder.property("visible", visible),
439        }
440    }
441
442    pub fn width_request(self, width_request: i32) -> Self {
443        Self {
444            builder: self.builder.property("width-request", width_request),
445        }
446    }
447
448    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
449        Self {
450            builder: self.builder.property("accessible-role", accessible_role),
451        }
452    }
453
454    // rustdoc-stripper-ignore-next
455    /// Build the [`WindowControls`].
456    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
457    pub fn build(self) -> WindowControls {
458        assert_initialized_main_thread!();
459        self.builder.build()
460    }
461}