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 /// 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 let f: &F = &*(f as *const F);
519 f(&from_glib_borrow(this))
520 }
521 unsafe {
522 let f: Box_<F> = Box_::new(f);
523 connect_raw(
524 self.as_ptr() as *mut _,
525 c"notify::black-background".as_ptr() as *const _,
526 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
527 notify_black_background_trampoline::<F> as *const (),
528 )),
529 Box_::into_raw(f),
530 )
531 }
532 }
533
534 #[cfg(feature = "v4_14")]
535 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
536 #[doc(alias = "child")]
537 pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
538 unsafe extern "C" fn notify_child_trampoline<F: Fn(&GraphicsOffload) + 'static>(
539 this: *mut ffi::GtkGraphicsOffload,
540 _param_spec: glib::ffi::gpointer,
541 f: glib::ffi::gpointer,
542 ) {
543 let f: &F = &*(f as *const F);
544 f(&from_glib_borrow(this))
545 }
546 unsafe {
547 let f: Box_<F> = Box_::new(f);
548 connect_raw(
549 self.as_ptr() as *mut _,
550 c"notify::child".as_ptr() as *const _,
551 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
552 notify_child_trampoline::<F> as *const (),
553 )),
554 Box_::into_raw(f),
555 )
556 }
557 }
558
559 #[cfg(feature = "v4_14")]
560 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
561 #[doc(alias = "enabled")]
562 pub fn connect_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
563 unsafe extern "C" fn notify_enabled_trampoline<F: Fn(&GraphicsOffload) + 'static>(
564 this: *mut ffi::GtkGraphicsOffload,
565 _param_spec: glib::ffi::gpointer,
566 f: glib::ffi::gpointer,
567 ) {
568 let f: &F = &*(f as *const F);
569 f(&from_glib_borrow(this))
570 }
571 unsafe {
572 let f: Box_<F> = Box_::new(f);
573 connect_raw(
574 self.as_ptr() as *mut _,
575 c"notify::enabled".as_ptr() as *const _,
576 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
577 notify_enabled_trampoline::<F> as *const (),
578 )),
579 Box_::into_raw(f),
580 )
581 }
582 }
583}
584
585#[cfg(feature = "v4_14")]
586#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
587impl Default for GraphicsOffload {
588 fn default() -> Self {
589 glib::object::Object::new::<Self>()
590 }
591}
592
593// rustdoc-stripper-ignore-next
594/// A [builder-pattern] type to construct [`GraphicsOffload`] objects.
595///
596/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
597#[must_use = "The builder must be built to be used"]
598pub struct GraphicsOffloadBuilder {
599 builder: glib::object::ObjectBuilder<'static, GraphicsOffload>,
600}
601
602impl GraphicsOffloadBuilder {
603 fn new() -> Self {
604 Self {
605 builder: glib::object::Object::builder(),
606 }
607 }
608
609 /// Whether to draw a black background.
610 #[cfg(feature = "v4_16")]
611 #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
612 pub fn black_background(self, black_background: bool) -> Self {
613 Self {
614 builder: self.builder.property("black-background", black_background),
615 }
616 }
617
618 /// The child widget.
619 #[cfg(feature = "v4_14")]
620 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
621 pub fn child(self, child: &impl IsA<Widget>) -> Self {
622 Self {
623 builder: self.builder.property("child", child.clone().upcast()),
624 }
625 }
626
627 /// Whether graphics offload is enabled.
628 #[cfg(feature = "v4_14")]
629 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
630 pub fn enabled(self, enabled: GraphicsOffloadEnabled) -> Self {
631 Self {
632 builder: self.builder.property("enabled", enabled),
633 }
634 }
635
636 /// Whether the widget or any of its descendents can accept
637 /// the input focus.
638 ///
639 /// This property is meant to be set by widget implementations,
640 /// typically in their instance init function.
641 pub fn can_focus(self, can_focus: bool) -> Self {
642 Self {
643 builder: self.builder.property("can-focus", can_focus),
644 }
645 }
646
647 /// Whether the widget can receive pointer events.
648 pub fn can_target(self, can_target: bool) -> Self {
649 Self {
650 builder: self.builder.property("can-target", can_target),
651 }
652 }
653
654 /// A list of css classes applied to this widget.
655 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
656 Self {
657 builder: self.builder.property("css-classes", css_classes.into()),
658 }
659 }
660
661 /// The name of this widget in the CSS tree.
662 ///
663 /// This property is meant to be set by widget implementations,
664 /// typically in their instance init function.
665 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
666 Self {
667 builder: self.builder.property("css-name", css_name.into()),
668 }
669 }
670
671 /// The cursor used by @widget.
672 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
673 Self {
674 builder: self.builder.property("cursor", cursor.clone()),
675 }
676 }
677
678 /// Whether the widget should grab focus when it is clicked with the mouse.
679 ///
680 /// This property is only relevant for widgets that can take focus.
681 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
682 Self {
683 builder: self.builder.property("focus-on-click", focus_on_click),
684 }
685 }
686
687 /// Whether this widget itself will accept the input focus.
688 pub fn focusable(self, focusable: bool) -> Self {
689 Self {
690 builder: self.builder.property("focusable", focusable),
691 }
692 }
693
694 /// How to distribute horizontal space if widget gets extra space.
695 pub fn halign(self, halign: Align) -> Self {
696 Self {
697 builder: self.builder.property("halign", halign),
698 }
699 }
700
701 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
702 /// signal on @widget.
703 ///
704 /// A true value indicates that @widget can have a tooltip, in this case
705 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
706 /// determine whether it will provide a tooltip or not.
707 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
708 Self {
709 builder: self.builder.property("has-tooltip", has_tooltip),
710 }
711 }
712
713 /// Overrides for height request of the widget.
714 ///
715 /// If this is -1, the natural request will be used.
716 pub fn height_request(self, height_request: i32) -> Self {
717 Self {
718 builder: self.builder.property("height-request", height_request),
719 }
720 }
721
722 /// Whether to expand horizontally.
723 pub fn hexpand(self, hexpand: bool) -> Self {
724 Self {
725 builder: self.builder.property("hexpand", hexpand),
726 }
727 }
728
729 /// Whether to use the `hexpand` property.
730 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
731 Self {
732 builder: self.builder.property("hexpand-set", hexpand_set),
733 }
734 }
735
736 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
737 /// the preferred size of the widget, and allocate its children.
738 ///
739 /// This property is meant to be set by widget implementations,
740 /// typically in their instance init function.
741 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
742 Self {
743 builder: self
744 .builder
745 .property("layout-manager", layout_manager.clone().upcast()),
746 }
747 }
748
749 /// Makes this widget act like a modal dialog, with respect to
750 /// event delivery.
751 ///
752 /// Global event controllers will not handle events with targets
753 /// inside the widget, unless they are set up to ignore propagation
754 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
755 #[cfg(feature = "v4_18")]
756 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
757 pub fn limit_events(self, limit_events: bool) -> Self {
758 Self {
759 builder: self.builder.property("limit-events", limit_events),
760 }
761 }
762
763 /// Margin on bottom side of widget.
764 ///
765 /// This property adds margin outside of the widget's normal size
766 /// request, the margin will be added in addition to the size from
767 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
768 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
769 Self {
770 builder: self.builder.property("margin-bottom", margin_bottom),
771 }
772 }
773
774 /// Margin on end of widget, horizontally.
775 ///
776 /// This property supports left-to-right and right-to-left text
777 /// directions.
778 ///
779 /// This property adds margin outside of the widget's normal size
780 /// request, the margin will be added in addition to the size from
781 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
782 pub fn margin_end(self, margin_end: i32) -> Self {
783 Self {
784 builder: self.builder.property("margin-end", margin_end),
785 }
786 }
787
788 /// Margin on start of widget, horizontally.
789 ///
790 /// This property supports left-to-right and right-to-left text
791 /// directions.
792 ///
793 /// This property adds margin outside of the widget's normal size
794 /// request, the margin will be added in addition to the size from
795 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
796 pub fn margin_start(self, margin_start: i32) -> Self {
797 Self {
798 builder: self.builder.property("margin-start", margin_start),
799 }
800 }
801
802 /// Margin on top side of widget.
803 ///
804 /// This property adds margin outside of the widget's normal size
805 /// request, the margin will be added in addition to the size from
806 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
807 pub fn margin_top(self, margin_top: i32) -> Self {
808 Self {
809 builder: self.builder.property("margin-top", margin_top),
810 }
811 }
812
813 /// The name of the widget.
814 pub fn name(self, name: impl Into<glib::GString>) -> Self {
815 Self {
816 builder: self.builder.property("name", name.into()),
817 }
818 }
819
820 /// The requested opacity of the widget.
821 pub fn opacity(self, opacity: f64) -> Self {
822 Self {
823 builder: self.builder.property("opacity", opacity),
824 }
825 }
826
827 /// How content outside the widget's content area is treated.
828 ///
829 /// This property is meant to be set by widget implementations,
830 /// typically in their instance init function.
831 pub fn overflow(self, overflow: Overflow) -> Self {
832 Self {
833 builder: self.builder.property("overflow", overflow),
834 }
835 }
836
837 /// Whether the widget will receive the default action when it is focused.
838 pub fn receives_default(self, receives_default: bool) -> Self {
839 Self {
840 builder: self.builder.property("receives-default", receives_default),
841 }
842 }
843
844 /// Whether the widget responds to input.
845 pub fn sensitive(self, sensitive: bool) -> Self {
846 Self {
847 builder: self.builder.property("sensitive", sensitive),
848 }
849 }
850
851 /// Sets the text of tooltip to be the given string, which is marked up
852 /// with Pango markup.
853 ///
854 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
855 ///
856 /// This is a convenience property which will take care of getting the
857 /// tooltip shown if the given string is not `NULL`:
858 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
859 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
860 /// the default signal handler.
861 ///
862 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
863 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
864 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
865 Self {
866 builder: self
867 .builder
868 .property("tooltip-markup", tooltip_markup.into()),
869 }
870 }
871
872 /// Sets the text of tooltip to be the given string.
873 ///
874 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
875 ///
876 /// This is a convenience property which will take care of getting the
877 /// tooltip shown if the given string is not `NULL`:
878 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
879 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
880 /// the default signal handler.
881 ///
882 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
883 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
884 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
885 Self {
886 builder: self.builder.property("tooltip-text", tooltip_text.into()),
887 }
888 }
889
890 /// How to distribute vertical space if widget gets extra space.
891 pub fn valign(self, valign: Align) -> Self {
892 Self {
893 builder: self.builder.property("valign", valign),
894 }
895 }
896
897 /// Whether to expand vertically.
898 pub fn vexpand(self, vexpand: bool) -> Self {
899 Self {
900 builder: self.builder.property("vexpand", vexpand),
901 }
902 }
903
904 /// Whether to use the `vexpand` property.
905 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
906 Self {
907 builder: self.builder.property("vexpand-set", vexpand_set),
908 }
909 }
910
911 /// Whether the widget is visible.
912 pub fn visible(self, visible: bool) -> Self {
913 Self {
914 builder: self.builder.property("visible", visible),
915 }
916 }
917
918 /// Overrides for width request of the widget.
919 ///
920 /// If this is -1, the natural request will be used.
921 pub fn width_request(self, width_request: i32) -> Self {
922 Self {
923 builder: self.builder.property("width-request", width_request),
924 }
925 }
926
927 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
928 ///
929 /// The accessible role cannot be changed once set.
930 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
931 Self {
932 builder: self.builder.property("accessible-role", accessible_role),
933 }
934 }
935
936 // rustdoc-stripper-ignore-next
937 /// Build the [`GraphicsOffload`].
938 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
939 pub fn build(self) -> GraphicsOffload {
940 assert_initialized_main_thread!();
941 self.builder.build()
942 }
943}