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    /// 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            let f: &F = &*(f as *const F);
576            f(&from_glib_borrow(this))
577        }
578        unsafe {
579            let f: Box_<F> = Box_::new(f);
580            connect_raw(
581                self.as_ptr() as *mut _,
582                c"notify::decoration-layout".as_ptr() as *const _,
583                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
584                    notify_decoration_layout_trampoline::<F> as *const (),
585                )),
586                Box_::into_raw(f),
587            )
588        }
589    }
590
591    #[doc(alias = "empty")]
592    pub fn connect_empty_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
593        unsafe extern "C" fn notify_empty_trampoline<F: Fn(&WindowControls) + 'static>(
594            this: *mut ffi::GtkWindowControls,
595            _param_spec: glib::ffi::gpointer,
596            f: glib::ffi::gpointer,
597        ) {
598            let f: &F = &*(f as *const F);
599            f(&from_glib_borrow(this))
600        }
601        unsafe {
602            let f: Box_<F> = Box_::new(f);
603            connect_raw(
604                self.as_ptr() as *mut _,
605                c"notify::empty".as_ptr() as *const _,
606                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
607                    notify_empty_trampoline::<F> as *const (),
608                )),
609                Box_::into_raw(f),
610            )
611        }
612    }
613
614    #[doc(alias = "side")]
615    pub fn connect_side_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
616        unsafe extern "C" fn notify_side_trampoline<F: Fn(&WindowControls) + 'static>(
617            this: *mut ffi::GtkWindowControls,
618            _param_spec: glib::ffi::gpointer,
619            f: glib::ffi::gpointer,
620        ) {
621            let f: &F = &*(f as *const F);
622            f(&from_glib_borrow(this))
623        }
624        unsafe {
625            let f: Box_<F> = Box_::new(f);
626            connect_raw(
627                self.as_ptr() as *mut _,
628                c"notify::side".as_ptr() as *const _,
629                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
630                    notify_side_trampoline::<F> as *const (),
631                )),
632                Box_::into_raw(f),
633            )
634        }
635    }
636
637    #[cfg(feature = "v4_18")]
638    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
639    #[doc(alias = "use-native-controls")]
640    pub fn connect_use_native_controls_notify<F: Fn(&Self) + 'static>(
641        &self,
642        f: F,
643    ) -> SignalHandlerId {
644        unsafe extern "C" fn notify_use_native_controls_trampoline<
645            F: Fn(&WindowControls) + 'static,
646        >(
647            this: *mut ffi::GtkWindowControls,
648            _param_spec: glib::ffi::gpointer,
649            f: glib::ffi::gpointer,
650        ) {
651            let f: &F = &*(f as *const F);
652            f(&from_glib_borrow(this))
653        }
654        unsafe {
655            let f: Box_<F> = Box_::new(f);
656            connect_raw(
657                self.as_ptr() as *mut _,
658                c"notify::use-native-controls".as_ptr() as *const _,
659                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
660                    notify_use_native_controls_trampoline::<F> as *const (),
661                )),
662                Box_::into_raw(f),
663            )
664        }
665    }
666}
667
668impl Default for WindowControls {
669    fn default() -> Self {
670        glib::object::Object::new::<Self>()
671    }
672}
673
674// rustdoc-stripper-ignore-next
675/// A [builder-pattern] type to construct [`WindowControls`] objects.
676///
677/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
678#[must_use = "The builder must be built to be used"]
679pub struct WindowControlsBuilder {
680    builder: glib::object::ObjectBuilder<'static, WindowControls>,
681}
682
683impl WindowControlsBuilder {
684    fn new() -> Self {
685        Self {
686            builder: glib::object::Object::builder(),
687        }
688    }
689
690    /// The decoration layout for window buttons.
691    ///
692    /// If this property is not set, the
693    /// [`gtk-decoration-layout`][struct@crate::Settings#gtk-decoration-layout] setting is used.
694    pub fn decoration_layout(self, decoration_layout: impl Into<glib::GString>) -> Self {
695        Self {
696            builder: self
697                .builder
698                .property("decoration-layout", decoration_layout.into()),
699        }
700    }
701
702    /// Whether the widget shows start or end side of the decoration layout.
703    ///
704    /// See [`decoration_layout`][struct@crate::WindowControls#decoration_layout].
705    pub fn side(self, side: PackType) -> Self {
706        Self {
707            builder: self.builder.property("side", side),
708        }
709    }
710
711    /// Whether to show platform native close/minimize/maximize buttons.
712    ///
713    /// For macOS, the [`decoration-layout`][struct@crate::HeaderBar#decoration-layout] property
714    /// controls the use of native window controls.
715    ///
716    /// On other platforms, this option has no effect.
717    ///
718    /// See also [Using GTK on Apple macOS](osx.html?native-window-controls).
719    #[cfg(feature = "v4_18")]
720    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
721    pub fn use_native_controls(self, use_native_controls: bool) -> Self {
722        Self {
723            builder: self
724                .builder
725                .property("use-native-controls", use_native_controls),
726        }
727    }
728
729    /// Whether the widget or any of its descendents can accept
730    /// the input focus.
731    ///
732    /// This property is meant to be set by widget implementations,
733    /// typically in their instance init function.
734    pub fn can_focus(self, can_focus: bool) -> Self {
735        Self {
736            builder: self.builder.property("can-focus", can_focus),
737        }
738    }
739
740    /// Whether the widget can receive pointer events.
741    pub fn can_target(self, can_target: bool) -> Self {
742        Self {
743            builder: self.builder.property("can-target", can_target),
744        }
745    }
746
747    /// A list of css classes applied to this widget.
748    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
749        Self {
750            builder: self.builder.property("css-classes", css_classes.into()),
751        }
752    }
753
754    /// The name of this widget in the CSS tree.
755    ///
756    /// This property is meant to be set by widget implementations,
757    /// typically in their instance init function.
758    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
759        Self {
760            builder: self.builder.property("css-name", css_name.into()),
761        }
762    }
763
764    /// The cursor used by @widget.
765    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
766        Self {
767            builder: self.builder.property("cursor", cursor.clone()),
768        }
769    }
770
771    /// Whether the widget should grab focus when it is clicked with the mouse.
772    ///
773    /// This property is only relevant for widgets that can take focus.
774    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
775        Self {
776            builder: self.builder.property("focus-on-click", focus_on_click),
777        }
778    }
779
780    /// Whether this widget itself will accept the input focus.
781    pub fn focusable(self, focusable: bool) -> Self {
782        Self {
783            builder: self.builder.property("focusable", focusable),
784        }
785    }
786
787    /// How to distribute horizontal space if widget gets extra space.
788    pub fn halign(self, halign: Align) -> Self {
789        Self {
790            builder: self.builder.property("halign", halign),
791        }
792    }
793
794    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
795    /// signal on @widget.
796    ///
797    /// A true value indicates that @widget can have a tooltip, in this case
798    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
799    /// determine whether it will provide a tooltip or not.
800    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
801        Self {
802            builder: self.builder.property("has-tooltip", has_tooltip),
803        }
804    }
805
806    /// Overrides for height request of the widget.
807    ///
808    /// If this is -1, the natural request will be used.
809    pub fn height_request(self, height_request: i32) -> Self {
810        Self {
811            builder: self.builder.property("height-request", height_request),
812        }
813    }
814
815    /// Whether to expand horizontally.
816    pub fn hexpand(self, hexpand: bool) -> Self {
817        Self {
818            builder: self.builder.property("hexpand", hexpand),
819        }
820    }
821
822    /// Whether to use the `hexpand` property.
823    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
824        Self {
825            builder: self.builder.property("hexpand-set", hexpand_set),
826        }
827    }
828
829    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
830    /// the preferred size of the widget, and allocate its children.
831    ///
832    /// This property is meant to be set by widget implementations,
833    /// typically in their instance init function.
834    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
835        Self {
836            builder: self
837                .builder
838                .property("layout-manager", layout_manager.clone().upcast()),
839        }
840    }
841
842    /// Makes this widget act like a modal dialog, with respect to
843    /// event delivery.
844    ///
845    /// Global event controllers will not handle events with targets
846    /// inside the widget, unless they are set up to ignore propagation
847    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
848    #[cfg(feature = "v4_18")]
849    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
850    pub fn limit_events(self, limit_events: bool) -> Self {
851        Self {
852            builder: self.builder.property("limit-events", limit_events),
853        }
854    }
855
856    /// Margin on bottom side of widget.
857    ///
858    /// This property adds margin outside of the widget's normal size
859    /// request, the margin will be added in addition to the size from
860    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
861    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
862        Self {
863            builder: self.builder.property("margin-bottom", margin_bottom),
864        }
865    }
866
867    /// Margin on end of widget, horizontally.
868    ///
869    /// This property supports left-to-right and right-to-left text
870    /// directions.
871    ///
872    /// This property adds margin outside of the widget's normal size
873    /// request, the margin will be added in addition to the size from
874    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
875    pub fn margin_end(self, margin_end: i32) -> Self {
876        Self {
877            builder: self.builder.property("margin-end", margin_end),
878        }
879    }
880
881    /// Margin on start of widget, horizontally.
882    ///
883    /// This property supports left-to-right and right-to-left text
884    /// directions.
885    ///
886    /// This property adds margin outside of the widget's normal size
887    /// request, the margin will be added in addition to the size from
888    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
889    pub fn margin_start(self, margin_start: i32) -> Self {
890        Self {
891            builder: self.builder.property("margin-start", margin_start),
892        }
893    }
894
895    /// Margin on top side of widget.
896    ///
897    /// This property adds margin outside of the widget's normal size
898    /// request, the margin will be added in addition to the size from
899    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
900    pub fn margin_top(self, margin_top: i32) -> Self {
901        Self {
902            builder: self.builder.property("margin-top", margin_top),
903        }
904    }
905
906    /// The name of the widget.
907    pub fn name(self, name: impl Into<glib::GString>) -> Self {
908        Self {
909            builder: self.builder.property("name", name.into()),
910        }
911    }
912
913    /// The requested opacity of the widget.
914    pub fn opacity(self, opacity: f64) -> Self {
915        Self {
916            builder: self.builder.property("opacity", opacity),
917        }
918    }
919
920    /// How content outside the widget's content area is treated.
921    ///
922    /// This property is meant to be set by widget implementations,
923    /// typically in their instance init function.
924    pub fn overflow(self, overflow: Overflow) -> Self {
925        Self {
926            builder: self.builder.property("overflow", overflow),
927        }
928    }
929
930    /// Whether the widget will receive the default action when it is focused.
931    pub fn receives_default(self, receives_default: bool) -> Self {
932        Self {
933            builder: self.builder.property("receives-default", receives_default),
934        }
935    }
936
937    /// Whether the widget responds to input.
938    pub fn sensitive(self, sensitive: bool) -> Self {
939        Self {
940            builder: self.builder.property("sensitive", sensitive),
941        }
942    }
943
944    /// Sets the text of tooltip to be the given string, which is marked up
945    /// with Pango markup.
946    ///
947    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
948    ///
949    /// This is a convenience property which will take care of getting the
950    /// tooltip shown if the given string is not `NULL`:
951    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
952    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
953    /// the default signal handler.
954    ///
955    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
956    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
957    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
958        Self {
959            builder: self
960                .builder
961                .property("tooltip-markup", tooltip_markup.into()),
962        }
963    }
964
965    /// Sets the text of tooltip to be the given string.
966    ///
967    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
968    ///
969    /// This is a convenience property which will take care of getting the
970    /// tooltip shown if the given string is not `NULL`:
971    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
972    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
973    /// the default signal handler.
974    ///
975    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
976    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
977    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
978        Self {
979            builder: self.builder.property("tooltip-text", tooltip_text.into()),
980        }
981    }
982
983    /// How to distribute vertical space if widget gets extra space.
984    pub fn valign(self, valign: Align) -> Self {
985        Self {
986            builder: self.builder.property("valign", valign),
987        }
988    }
989
990    /// Whether to expand vertically.
991    pub fn vexpand(self, vexpand: bool) -> Self {
992        Self {
993            builder: self.builder.property("vexpand", vexpand),
994        }
995    }
996
997    /// Whether to use the `vexpand` property.
998    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
999        Self {
1000            builder: self.builder.property("vexpand-set", vexpand_set),
1001        }
1002    }
1003
1004    /// Whether the widget is visible.
1005    pub fn visible(self, visible: bool) -> Self {
1006        Self {
1007            builder: self.builder.property("visible", visible),
1008        }
1009    }
1010
1011    /// Overrides for width request of the widget.
1012    ///
1013    /// If this is -1, the natural request will be used.
1014    pub fn width_request(self, width_request: i32) -> Self {
1015        Self {
1016            builder: self.builder.property("width-request", width_request),
1017        }
1018    }
1019
1020    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1021    ///
1022    /// The accessible role cannot be changed once set.
1023    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1024        Self {
1025            builder: self.builder.property("accessible-role", accessible_role),
1026        }
1027    }
1028
1029    // rustdoc-stripper-ignore-next
1030    /// Build the [`WindowControls`].
1031    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1032    pub fn build(self) -> WindowControls {
1033        assert_initialized_main_thread!();
1034        self.builder.build()
1035    }
1036}