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