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