Skip to main content

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
5#[cfg(feature = "v4_10")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
7use crate::Accessible;
8use crate::{
9    AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow, PackType, Widget,
10    ffi,
11};
12use glib::{
13    prelude::*,
14    signal::{SignalHandlerId, connect_raw},
15    translate::*,
16};
17use std::boxed::Box as Box_;
18
19#[cfg(feature = "v4_10")]
20#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
21glib::wrapper! {
22    ///
23    /// ```text
24    ///
25    /// # CSS nodes
26    ///
27    /// ```
28    /// windowcontrols
29    /// ├── [image.icon]
30    /// ├── [button.minimize]
31    /// ├── [button.maximize]
32    /// ╰── [button.close]
33    /// ```text
34    ///
35    /// A [`WindowControls`][crate::WindowControls]' CSS node is called windowcontrols. It contains
36    /// subnodes corresponding to each title button. Which of the title buttons
37    /// exist and where they are placed exactly depends on the desktop environment
38    /// and [`decoration-layout`][struct@crate::WindowControls#decoration-layout] value.
39    ///
40    /// When [`empty`][struct@crate::WindowControls#empty] is true, it gets the .empty
41    /// style class.
42    ///
43    /// # Accessibility
44    ///
45    /// [`WindowControls`][crate::WindowControls] uses the [enum@Gtk.AccessibleRole.group] role.
46    ///
47    /// ## Properties
48    ///
49    ///
50    /// #### `decoration-layout`
51    ///  The decoration layout for window buttons.
52    ///
53    /// If this property is not set, the
54    /// [`gtk-decoration-layout`][struct@crate::Settings#gtk-decoration-layout] setting is used.
55    ///
56    /// Readable | Writable
57    ///
58    ///
59    /// #### `empty`
60    ///  Whether the widget has any window buttons.
61    ///
62    /// Readable
63    ///
64    ///
65    /// #### `side`
66    ///  Whether the widget shows start or end side of the decoration layout.
67    ///
68    /// See [`decoration_layout`][struct@crate::WindowControls#decoration_layout].
69    ///
70    /// Readable | Writable
71    ///
72    ///
73    /// #### `use-native-controls`
74    ///  Whether to show platform native close/minimize/maximize buttons.
75    ///
76    /// For macOS, the [`decoration-layout`][struct@crate::HeaderBar#decoration-layout] property
77    /// controls the use of native window controls.
78    ///
79    /// On other platforms, this option has no effect.
80    ///
81    /// See also [Using GTK on Apple macOS](osx.html?native-window-controls).
82    ///
83    /// Readable | Writable
84    /// <details><summary><h4>Widget</h4></summary>
85    ///
86    ///
87    /// #### `can-focus`
88    ///  Whether the widget or any of its descendents can accept
89    /// the input focus.
90    ///
91    /// This property is meant to be set by widget implementations,
92    /// typically in their instance init function.
93    ///
94    /// Readable | Writable
95    ///
96    ///
97    /// #### `can-target`
98    ///  Whether the widget can receive pointer events.
99    ///
100    /// Readable | Writable
101    ///
102    ///
103    /// #### `css-classes`
104    ///  A list of css classes applied to this widget.
105    ///
106    /// Readable | Writable
107    ///
108    ///
109    /// #### `css-name`
110    ///  The name of this widget in the CSS tree.
111    ///
112    /// This property is meant to be set by widget implementations,
113    /// typically in their instance init function.
114    ///
115    /// Readable | Writable | Construct Only
116    ///
117    ///
118    /// #### `cursor`
119    ///  The cursor used by @widget.
120    ///
121    /// Readable | Writable
122    ///
123    ///
124    /// #### `focus-on-click`
125    ///  Whether the widget should grab focus when it is clicked with the mouse.
126    ///
127    /// This property is only relevant for widgets that can take focus.
128    ///
129    /// Readable | Writable
130    ///
131    ///
132    /// #### `focusable`
133    ///  Whether this widget itself will accept the input focus.
134    ///
135    /// Readable | Writable
136    ///
137    ///
138    /// #### `halign`
139    ///  How to distribute horizontal space if widget gets extra space.
140    ///
141    /// Readable | Writable
142    ///
143    ///
144    /// #### `has-default`
145    ///  Whether the widget is the default widget.
146    ///
147    /// Readable
148    ///
149    ///
150    /// #### `has-focus`
151    ///  Whether the widget has the input focus.
152    ///
153    /// Readable
154    ///
155    ///
156    /// #### `has-tooltip`
157    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
158    /// signal on @widget.
159    ///
160    /// A true value indicates that @widget can have a tooltip, in this case
161    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
162    /// determine whether it will provide a tooltip or not.
163    ///
164    /// Readable | Writable
165    ///
166    ///
167    /// #### `height-request`
168    ///  Overrides for height request of the widget.
169    ///
170    /// If this is -1, the natural request will be used.
171    ///
172    /// Readable | Writable
173    ///
174    ///
175    /// #### `hexpand`
176    ///  Whether to expand horizontally.
177    ///
178    /// Readable | Writable
179    ///
180    ///
181    /// #### `hexpand-set`
182    ///  Whether to use the `hexpand` property.
183    ///
184    /// Readable | Writable
185    ///
186    ///
187    /// #### `layout-manager`
188    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
189    /// the preferred size of the widget, and allocate its children.
190    ///
191    /// This property is meant to be set by widget implementations,
192    /// typically in their instance init function.
193    ///
194    /// Readable | Writable
195    ///
196    ///
197    /// #### `limit-events`
198    ///  Makes this widget act like a modal dialog, with respect to
199    /// event delivery.
200    ///
201    /// Global event controllers will not handle events with targets
202    /// inside the widget, unless they are set up to ignore propagation
203    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
204    ///
205    /// Readable | Writable
206    ///
207    ///
208    /// #### `margin-bottom`
209    ///  Margin on bottom side of widget.
210    ///
211    /// This property adds margin outside of the widget's normal size
212    /// request, the margin will be added in addition to the size from
213    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
214    ///
215    /// Readable | Writable
216    ///
217    ///
218    /// #### `margin-end`
219    ///  Margin on end of widget, horizontally.
220    ///
221    /// This property supports left-to-right and right-to-left text
222    /// directions.
223    ///
224    /// This property adds margin outside of the widget's normal size
225    /// request, the margin will be added in addition to the size from
226    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
227    ///
228    /// Readable | Writable
229    ///
230    ///
231    /// #### `margin-start`
232    ///  Margin on start of widget, horizontally.
233    ///
234    /// This property supports left-to-right and right-to-left text
235    /// directions.
236    ///
237    /// This property adds margin outside of the widget's normal size
238    /// request, the margin will be added in addition to the size from
239    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
240    ///
241    /// Readable | Writable
242    ///
243    ///
244    /// #### `margin-top`
245    ///  Margin on top side of widget.
246    ///
247    /// This property adds margin outside of the widget's normal size
248    /// request, the margin will be added in addition to the size from
249    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
250    ///
251    /// Readable | Writable
252    ///
253    ///
254    /// #### `name`
255    ///  The name of the widget.
256    ///
257    /// Readable | Writable
258    ///
259    ///
260    /// #### `opacity`
261    ///  The requested opacity of the widget.
262    ///
263    /// Readable | Writable
264    ///
265    ///
266    /// #### `overflow`
267    ///  How content outside the widget's content area is treated.
268    ///
269    /// This property is meant to be set by widget implementations,
270    /// typically in their instance init function.
271    ///
272    /// Readable | Writable
273    ///
274    ///
275    /// #### `parent`
276    ///  The parent widget of this widget.
277    ///
278    /// Readable
279    ///
280    ///
281    /// #### `receives-default`
282    ///  Whether the widget will receive the default action when it is focused.
283    ///
284    /// Readable | Writable
285    ///
286    ///
287    /// #### `root`
288    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
289    ///
290    /// This will be `NULL` if the widget is not contained in a root widget.
291    ///
292    /// Readable
293    ///
294    ///
295    /// #### `scale-factor`
296    ///  The scale factor of the widget.
297    ///
298    /// Readable
299    ///
300    ///
301    /// #### `sensitive`
302    ///  Whether the widget responds to input.
303    ///
304    /// Readable | Writable
305    ///
306    ///
307    /// #### `tooltip-markup`
308    ///  Sets the text of tooltip to be the given string, which is marked up
309    /// with Pango markup.
310    ///
311    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
312    ///
313    /// This is a convenience property which will take care of getting the
314    /// tooltip shown if the given string is not `NULL`:
315    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
316    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
317    /// the default signal handler.
318    ///
319    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
320    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
321    ///
322    /// Readable | Writable
323    ///
324    ///
325    /// #### `tooltip-text`
326    ///  Sets the text of tooltip to be the given string.
327    ///
328    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
329    ///
330    /// This is a convenience property which will take care of getting the
331    /// tooltip shown if the given string is not `NULL`:
332    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
333    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
334    /// the default signal handler.
335    ///
336    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
337    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
338    ///
339    /// Readable | Writable
340    ///
341    ///
342    /// #### `valign`
343    ///  How to distribute vertical space if widget gets extra space.
344    ///
345    /// Readable | Writable
346    ///
347    ///
348    /// #### `vexpand`
349    ///  Whether to expand vertically.
350    ///
351    /// Readable | Writable
352    ///
353    ///
354    /// #### `vexpand-set`
355    ///  Whether to use the `vexpand` property.
356    ///
357    /// Readable | Writable
358    ///
359    ///
360    /// #### `visible`
361    ///  Whether the widget is visible.
362    ///
363    /// Readable | Writable
364    ///
365    ///
366    /// #### `width-request`
367    ///  Overrides for width request of the widget.
368    ///
369    /// If this is -1, the natural request will be used.
370    ///
371    /// Readable | Writable
372    /// </details>
373    /// <details><summary><h4>Accessible</h4></summary>
374    ///
375    ///
376    /// #### `accessible-role`
377    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
378    ///
379    /// The accessible role cannot be changed once set.
380    ///
381    /// Readable | Writable
382    /// </details>
383    ///
384    /// # Implements
385    ///
386    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
387    #[doc(alias = "GtkWindowControls")]
388    pub struct WindowControls(Object<ffi::GtkWindowControls, ffi::GtkWindowControlsClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
389
390    match fn {
391        type_ => || ffi::gtk_window_controls_get_type(),
392    }
393}
394
395#[cfg(not(feature = "v4_10"))]
396glib::wrapper! {
397    #[doc(alias = "GtkWindowControls")]
398    pub struct WindowControls(Object<ffi::GtkWindowControls, ffi::GtkWindowControlsClass>) @extends Widget, @implements Buildable, ConstraintTarget;
399
400    match fn {
401        type_ => || ffi::gtk_window_controls_get_type(),
402    }
403}
404
405impl WindowControls {
406    /// Creates a new [`WindowControls`][crate::WindowControls].
407    /// ## `side`
408    /// the side
409    ///
410    /// # Returns
411    ///
412    /// a new [`WindowControls`][crate::WindowControls]
413    #[doc(alias = "gtk_window_controls_new")]
414    pub fn new(side: PackType) -> WindowControls {
415        assert_initialized_main_thread!();
416        unsafe {
417            Widget::from_glib_none(ffi::gtk_window_controls_new(side.into_glib())).unsafe_cast()
418        }
419    }
420
421    // rustdoc-stripper-ignore-next
422    /// Creates a new builder-pattern struct instance to construct [`WindowControls`] objects.
423    ///
424    /// This method returns an instance of [`WindowControlsBuilder`](crate::builders::WindowControlsBuilder) which can be used to create [`WindowControls`] objects.
425    pub fn builder() -> WindowControlsBuilder {
426        WindowControlsBuilder::new()
427    }
428
429    /// Gets the decoration layout of this window controls widget
430    ///
431    /// # Returns
432    ///
433    /// the decoration layout
434    #[doc(alias = "gtk_window_controls_get_decoration_layout")]
435    #[doc(alias = "get_decoration_layout")]
436    #[doc(alias = "decoration-layout")]
437    pub fn decoration_layout(&self) -> Option<glib::GString> {
438        unsafe {
439            from_glib_none(ffi::gtk_window_controls_get_decoration_layout(
440                self.to_glib_none().0,
441            ))
442        }
443    }
444
445    /// Gets whether the widget has any window buttons.
446    ///
447    /// # Returns
448    ///
449    /// true if the widget has window buttons
450    #[doc(alias = "gtk_window_controls_get_empty")]
451    #[doc(alias = "get_empty")]
452    #[doc(alias = "empty")]
453    pub fn is_empty(&self) -> bool {
454        unsafe { from_glib(ffi::gtk_window_controls_get_empty(self.to_glib_none().0)) }
455    }
456
457    /// Gets the side to which this window controls widget belongs.
458    ///
459    /// # Returns
460    ///
461    /// the side
462    #[doc(alias = "gtk_window_controls_get_side")]
463    #[doc(alias = "get_side")]
464    pub fn side(&self) -> PackType {
465        unsafe { from_glib(ffi::gtk_window_controls_get_side(self.to_glib_none().0)) }
466    }
467
468    /// Returns whether platform native window controls are shown.
469    ///
470    /// # Returns
471    ///
472    /// true if native window controls are shown
473    #[cfg(feature = "v4_18")]
474    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
475    #[doc(alias = "gtk_window_controls_get_use_native_controls")]
476    #[doc(alias = "get_use_native_controls")]
477    #[doc(alias = "use-native-controls")]
478    pub fn uses_native_controls(&self) -> bool {
479        unsafe {
480            from_glib(ffi::gtk_window_controls_get_use_native_controls(
481                self.to_glib_none().0,
482            ))
483        }
484    }
485
486    /// Sets the decoration layout for the title buttons.
487    ///
488    /// This overrides the [`gtk-decoration-layout`][struct@crate::Settings#gtk-decoration-layout]
489    /// setting.
490    ///
491    /// The format of the string is button names, separated by commas.
492    /// A colon separates the buttons that should appear on the left
493    /// from those on the right. Recognized button names are minimize,
494    /// maximize, close and icon (the window icon).
495    ///
496    /// For example, “icon:minimize,maximize,close” specifies a icon
497    /// on the left, and minimize, maximize and close buttons on the right.
498    ///
499    /// If [`side`][struct@crate::WindowControls#side] value is [enum@Gtk.PackType.start],
500    /// @self will display the part before the colon, otherwise after that.
501    /// ## `layout`
502    /// a decoration layout, or `NULL` to unset the layout
503    #[doc(alias = "gtk_window_controls_set_decoration_layout")]
504    #[doc(alias = "decoration-layout")]
505    pub fn set_decoration_layout(&self, layout: Option<&str>) {
506        unsafe {
507            ffi::gtk_window_controls_set_decoration_layout(
508                self.to_glib_none().0,
509                layout.to_glib_none().0,
510            );
511        }
512    }
513
514    /// Determines which part of decoration layout
515    /// the window controls widget uses.
516    ///
517    /// See [`decoration-layout`][struct@crate::WindowControls#decoration-layout].
518    /// ## `side`
519    /// a side
520    #[doc(alias = "gtk_window_controls_set_side")]
521    #[doc(alias = "side")]
522    pub fn set_side(&self, side: PackType) {
523        unsafe {
524            ffi::gtk_window_controls_set_side(self.to_glib_none().0, side.into_glib());
525        }
526    }
527
528    /// Sets whether platform native window controls are used.
529    ///
530    /// This option shows the "stoplight" buttons on macOS.
531    /// For Linux, this option has no effect.
532    ///
533    /// See also [Using GTK on Apple macOS](osx.html?native-window-controls).
534    /// ## `setting`
535    /// true to show native window controls
536    #[cfg(feature = "v4_18")]
537    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
538    #[doc(alias = "gtk_window_controls_set_use_native_controls")]
539    #[doc(alias = "use-native-controls")]
540    pub fn set_use_native_controls(&self, setting: bool) {
541        unsafe {
542            ffi::gtk_window_controls_set_use_native_controls(
543                self.to_glib_none().0,
544                setting.into_glib(),
545            );
546        }
547    }
548
549    #[doc(alias = "decoration-layout")]
550    pub fn connect_decoration_layout_notify<F: Fn(&Self) + 'static>(
551        &self,
552        f: F,
553    ) -> SignalHandlerId {
554        unsafe extern "C" fn notify_decoration_layout_trampoline<
555            F: Fn(&WindowControls) + 'static,
556        >(
557            this: *mut ffi::GtkWindowControls,
558            _param_spec: glib::ffi::gpointer,
559            f: glib::ffi::gpointer,
560        ) {
561            unsafe {
562                let f: &F = &*(f as *const F);
563                f(&from_glib_borrow(this))
564            }
565        }
566        unsafe {
567            let f: Box_<F> = Box_::new(f);
568            connect_raw(
569                self.as_ptr() as *mut _,
570                c"notify::decoration-layout".as_ptr(),
571                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
572                    notify_decoration_layout_trampoline::<F> as *const (),
573                )),
574                Box_::into_raw(f),
575            )
576        }
577    }
578
579    #[doc(alias = "empty")]
580    pub fn connect_empty_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
581        unsafe extern "C" fn notify_empty_trampoline<F: Fn(&WindowControls) + 'static>(
582            this: *mut ffi::GtkWindowControls,
583            _param_spec: glib::ffi::gpointer,
584            f: glib::ffi::gpointer,
585        ) {
586            unsafe {
587                let f: &F = &*(f as *const F);
588                f(&from_glib_borrow(this))
589            }
590        }
591        unsafe {
592            let f: Box_<F> = Box_::new(f);
593            connect_raw(
594                self.as_ptr() as *mut _,
595                c"notify::empty".as_ptr(),
596                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
597                    notify_empty_trampoline::<F> as *const (),
598                )),
599                Box_::into_raw(f),
600            )
601        }
602    }
603
604    #[doc(alias = "side")]
605    pub fn connect_side_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
606        unsafe extern "C" fn notify_side_trampoline<F: Fn(&WindowControls) + 'static>(
607            this: *mut ffi::GtkWindowControls,
608            _param_spec: glib::ffi::gpointer,
609            f: glib::ffi::gpointer,
610        ) {
611            unsafe {
612                let f: &F = &*(f as *const F);
613                f(&from_glib_borrow(this))
614            }
615        }
616        unsafe {
617            let f: Box_<F> = Box_::new(f);
618            connect_raw(
619                self.as_ptr() as *mut _,
620                c"notify::side".as_ptr(),
621                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
622                    notify_side_trampoline::<F> as *const (),
623                )),
624                Box_::into_raw(f),
625            )
626        }
627    }
628
629    #[cfg(feature = "v4_18")]
630    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
631    #[doc(alias = "use-native-controls")]
632    pub fn connect_use_native_controls_notify<F: Fn(&Self) + 'static>(
633        &self,
634        f: F,
635    ) -> SignalHandlerId {
636        unsafe extern "C" fn notify_use_native_controls_trampoline<
637            F: Fn(&WindowControls) + 'static,
638        >(
639            this: *mut ffi::GtkWindowControls,
640            _param_spec: glib::ffi::gpointer,
641            f: glib::ffi::gpointer,
642        ) {
643            unsafe {
644                let f: &F = &*(f as *const F);
645                f(&from_glib_borrow(this))
646            }
647        }
648        unsafe {
649            let f: Box_<F> = Box_::new(f);
650            connect_raw(
651                self.as_ptr() as *mut _,
652                c"notify::use-native-controls".as_ptr(),
653                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
654                    notify_use_native_controls_trampoline::<F> as *const (),
655                )),
656                Box_::into_raw(f),
657            )
658        }
659    }
660}
661
662impl Default for WindowControls {
663    fn default() -> Self {
664        glib::object::Object::new::<Self>()
665    }
666}
667
668// rustdoc-stripper-ignore-next
669/// A [builder-pattern] type to construct [`WindowControls`] objects.
670///
671/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
672#[must_use = "The builder must be built to be used"]
673pub struct WindowControlsBuilder {
674    builder: glib::object::ObjectBuilder<'static, WindowControls>,
675}
676
677impl WindowControlsBuilder {
678    fn new() -> Self {
679        Self {
680            builder: glib::object::Object::builder(),
681        }
682    }
683
684    /// The decoration layout for window buttons.
685    ///
686    /// If this property is not set, the
687    /// [`gtk-decoration-layout`][struct@crate::Settings#gtk-decoration-layout] setting is used.
688    pub fn decoration_layout(self, decoration_layout: impl Into<glib::GString>) -> Self {
689        Self {
690            builder: self
691                .builder
692                .property("decoration-layout", decoration_layout.into()),
693        }
694    }
695
696    /// Whether the widget shows start or end side of the decoration layout.
697    ///
698    /// See [`decoration_layout`][struct@crate::WindowControls#decoration_layout].
699    pub fn side(self, side: PackType) -> Self {
700        Self {
701            builder: self.builder.property("side", side),
702        }
703    }
704
705    /// Whether to show platform native close/minimize/maximize buttons.
706    ///
707    /// For macOS, the [`decoration-layout`][struct@crate::HeaderBar#decoration-layout] property
708    /// controls the use of native window controls.
709    ///
710    /// On other platforms, this option has no effect.
711    ///
712    /// See also [Using GTK on Apple macOS](osx.html?native-window-controls).
713    #[cfg(feature = "v4_18")]
714    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
715    pub fn use_native_controls(self, use_native_controls: bool) -> Self {
716        Self {
717            builder: self
718                .builder
719                .property("use-native-controls", use_native_controls),
720        }
721    }
722
723    /// Whether the widget or any of its descendents can accept
724    /// the input focus.
725    ///
726    /// This property is meant to be set by widget implementations,
727    /// typically in their instance init function.
728    pub fn can_focus(self, can_focus: bool) -> Self {
729        Self {
730            builder: self.builder.property("can-focus", can_focus),
731        }
732    }
733
734    /// Whether the widget can receive pointer events.
735    pub fn can_target(self, can_target: bool) -> Self {
736        Self {
737            builder: self.builder.property("can-target", can_target),
738        }
739    }
740
741    /// A list of css classes applied to this widget.
742    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
743        Self {
744            builder: self.builder.property("css-classes", css_classes.into()),
745        }
746    }
747
748    /// The name of this widget in the CSS tree.
749    ///
750    /// This property is meant to be set by widget implementations,
751    /// typically in their instance init function.
752    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
753        Self {
754            builder: self.builder.property("css-name", css_name.into()),
755        }
756    }
757
758    /// The cursor used by @widget.
759    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
760        Self {
761            builder: self.builder.property("cursor", cursor.clone()),
762        }
763    }
764
765    /// Whether the widget should grab focus when it is clicked with the mouse.
766    ///
767    /// This property is only relevant for widgets that can take focus.
768    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
769        Self {
770            builder: self.builder.property("focus-on-click", focus_on_click),
771        }
772    }
773
774    /// Whether this widget itself will accept the input focus.
775    pub fn focusable(self, focusable: bool) -> Self {
776        Self {
777            builder: self.builder.property("focusable", focusable),
778        }
779    }
780
781    /// How to distribute horizontal space if widget gets extra space.
782    pub fn halign(self, halign: Align) -> Self {
783        Self {
784            builder: self.builder.property("halign", halign),
785        }
786    }
787
788    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
789    /// signal on @widget.
790    ///
791    /// A true value indicates that @widget can have a tooltip, in this case
792    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
793    /// determine whether it will provide a tooltip or not.
794    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
795        Self {
796            builder: self.builder.property("has-tooltip", has_tooltip),
797        }
798    }
799
800    /// Overrides for height request of the widget.
801    ///
802    /// If this is -1, the natural request will be used.
803    pub fn height_request(self, height_request: i32) -> Self {
804        Self {
805            builder: self.builder.property("height-request", height_request),
806        }
807    }
808
809    /// Whether to expand horizontally.
810    pub fn hexpand(self, hexpand: bool) -> Self {
811        Self {
812            builder: self.builder.property("hexpand", hexpand),
813        }
814    }
815
816    /// Whether to use the `hexpand` property.
817    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
818        Self {
819            builder: self.builder.property("hexpand-set", hexpand_set),
820        }
821    }
822
823    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
824    /// the preferred size of the widget, and allocate its children.
825    ///
826    /// This property is meant to be set by widget implementations,
827    /// typically in their instance init function.
828    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
829        Self {
830            builder: self
831                .builder
832                .property("layout-manager", layout_manager.clone().upcast()),
833        }
834    }
835
836    /// Makes this widget act like a modal dialog, with respect to
837    /// event delivery.
838    ///
839    /// Global event controllers will not handle events with targets
840    /// inside the widget, unless they are set up to ignore propagation
841    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
842    #[cfg(feature = "v4_18")]
843    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
844    pub fn limit_events(self, limit_events: bool) -> Self {
845        Self {
846            builder: self.builder.property("limit-events", limit_events),
847        }
848    }
849
850    /// Margin on bottom side of widget.
851    ///
852    /// This property adds margin outside of the widget's normal size
853    /// request, the margin will be added in addition to the size from
854    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
855    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
856        Self {
857            builder: self.builder.property("margin-bottom", margin_bottom),
858        }
859    }
860
861    /// Margin on end of widget, horizontally.
862    ///
863    /// This property supports left-to-right and right-to-left text
864    /// directions.
865    ///
866    /// This property adds margin outside of the widget's normal size
867    /// request, the margin will be added in addition to the size from
868    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
869    pub fn margin_end(self, margin_end: i32) -> Self {
870        Self {
871            builder: self.builder.property("margin-end", margin_end),
872        }
873    }
874
875    /// Margin on start of widget, horizontally.
876    ///
877    /// This property supports left-to-right and right-to-left text
878    /// directions.
879    ///
880    /// This property adds margin outside of the widget's normal size
881    /// request, the margin will be added in addition to the size from
882    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
883    pub fn margin_start(self, margin_start: i32) -> Self {
884        Self {
885            builder: self.builder.property("margin-start", margin_start),
886        }
887    }
888
889    /// Margin on top side of widget.
890    ///
891    /// This property adds margin outside of the widget's normal size
892    /// request, the margin will be added in addition to the size from
893    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
894    pub fn margin_top(self, margin_top: i32) -> Self {
895        Self {
896            builder: self.builder.property("margin-top", margin_top),
897        }
898    }
899
900    /// The name of the widget.
901    pub fn name(self, name: impl Into<glib::GString>) -> Self {
902        Self {
903            builder: self.builder.property("name", name.into()),
904        }
905    }
906
907    /// The requested opacity of the widget.
908    pub fn opacity(self, opacity: f64) -> Self {
909        Self {
910            builder: self.builder.property("opacity", opacity),
911        }
912    }
913
914    /// How content outside the widget's content area is treated.
915    ///
916    /// This property is meant to be set by widget implementations,
917    /// typically in their instance init function.
918    pub fn overflow(self, overflow: Overflow) -> Self {
919        Self {
920            builder: self.builder.property("overflow", overflow),
921        }
922    }
923
924    /// Whether the widget will receive the default action when it is focused.
925    pub fn receives_default(self, receives_default: bool) -> Self {
926        Self {
927            builder: self.builder.property("receives-default", receives_default),
928        }
929    }
930
931    /// Whether the widget responds to input.
932    pub fn sensitive(self, sensitive: bool) -> Self {
933        Self {
934            builder: self.builder.property("sensitive", sensitive),
935        }
936    }
937
938    /// Sets the text of tooltip to be the given string, which is marked up
939    /// with Pango markup.
940    ///
941    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
942    ///
943    /// This is a convenience property which will take care of getting the
944    /// tooltip shown if the given string is not `NULL`:
945    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
946    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
947    /// the default signal handler.
948    ///
949    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
950    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
951    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
952        Self {
953            builder: self
954                .builder
955                .property("tooltip-markup", tooltip_markup.into()),
956        }
957    }
958
959    /// Sets the text of tooltip to be the given string.
960    ///
961    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
962    ///
963    /// This is a convenience property which will take care of getting the
964    /// tooltip shown if the given string is not `NULL`:
965    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
966    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
967    /// the default signal handler.
968    ///
969    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
970    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
971    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
972        Self {
973            builder: self.builder.property("tooltip-text", tooltip_text.into()),
974        }
975    }
976
977    /// How to distribute vertical space if widget gets extra space.
978    pub fn valign(self, valign: Align) -> Self {
979        Self {
980            builder: self.builder.property("valign", valign),
981        }
982    }
983
984    /// Whether to expand vertically.
985    pub fn vexpand(self, vexpand: bool) -> Self {
986        Self {
987            builder: self.builder.property("vexpand", vexpand),
988        }
989    }
990
991    /// Whether to use the `vexpand` property.
992    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
993        Self {
994            builder: self.builder.property("vexpand-set", vexpand_set),
995        }
996    }
997
998    /// Whether the widget is visible.
999    pub fn visible(self, visible: bool) -> Self {
1000        Self {
1001            builder: self.builder.property("visible", visible),
1002        }
1003    }
1004
1005    /// Overrides for width request of the widget.
1006    ///
1007    /// If this is -1, the natural request will be used.
1008    pub fn width_request(self, width_request: i32) -> Self {
1009        Self {
1010            builder: self.builder.property("width-request", width_request),
1011        }
1012    }
1013
1014    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1015    ///
1016    /// The accessible role cannot be changed once set.
1017    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1018        Self {
1019            builder: self.builder.property("accessible-role", accessible_role),
1020        }
1021    }
1022
1023    // rustdoc-stripper-ignore-next
1024    /// Build the [`WindowControls`].
1025    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1026    pub fn build(self) -> WindowControls {
1027        assert_initialized_main_thread!();
1028        self.builder.build()
1029    }
1030}