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