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