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