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