gtk4/auto/picture.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#![allow(deprecated)]
5
6#[cfg(feature = "v4_8")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
8use crate::ContentFit;
9use crate::{
10 ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow,
11 Widget,
12};
13use glib::{
14 prelude::*,
15 signal::{connect_raw, SignalHandlerId},
16 translate::*,
17};
18use std::boxed::Box as Box_;
19
20glib::wrapper! {
21 /// Displays a [`gdk::Paintable`][crate::gdk::Paintable].
22 ///
23 /// picture>
24 /// <source srcset="picture-dark.png" media="(prefers-color-scheme: dark)">
25 /// <img alt="An example GtkPicture" src="picture.png">
26 /// </picture>
27 ///
28 /// Many convenience functions are provided to make pictures simple to use.
29 /// For example, if you want to load an image from a file, and then display
30 /// it, there’s a convenience function to do this:
31 ///
32 /// **⚠️ The following code is in c ⚠️**
33 ///
34 /// ```c
35 /// GtkWidget *widget = gtk_picture_new_for_filename ("myfile.png");
36 /// ```
37 ///
38 /// If the file isn’t loaded successfully, the picture will contain a
39 /// “broken image” icon similar to that used in many web browsers.
40 /// If you want to handle errors in loading the file yourself,
41 /// for example by displaying an error message, then load the image with
42 /// [`gdk::Texture::from_file()`][crate::gdk::Texture::from_file()], then create the [`Picture`][crate::Picture] with
43 /// [`for_paintable()`][Self::for_paintable()].
44 ///
45 /// Sometimes an application will want to avoid depending on external data
46 /// files, such as image files. See the documentation of `GResource` for details.
47 /// In this case, [`for_resource()`][Self::for_resource()] and
48 /// [`set_resource()`][Self::set_resource()] should be used.
49 ///
50 /// [`Picture`][crate::Picture] displays an image at its natural size. See [`Image`][crate::Image]
51 /// if you want to display a fixed-size image, such as an icon.
52 ///
53 /// ## Sizing the paintable
54 ///
55 /// You can influence how the paintable is displayed inside the [`Picture`][crate::Picture]
56 /// by changing [`content-fit`][struct@crate::Picture#content-fit]. See [`ContentFit`][crate::ContentFit]
57 /// for details. [`can-shrink`][struct@crate::Picture#can-shrink] can be unset to make sure
58 /// that paintables are never made smaller than their ideal size - but
59 /// be careful if you do not know the size of the paintable in use (like
60 /// when displaying user-loaded images). This can easily cause the picture to
61 /// grow larger than the screen. And [`halign`][struct@crate::Widget#halign] and
62 /// [`valign`][struct@crate::Widget#valign] can be used to make sure the paintable doesn't
63 /// fill all available space but is instead displayed at its original size.
64 ///
65 /// ## CSS nodes
66 ///
67 /// [`Picture`][crate::Picture] has a single CSS node with the name `picture`.
68 ///
69 /// ## Accessibility
70 ///
71 /// [`Picture`][crate::Picture] uses the [enum@Gtk.AccessibleRole.img] role.
72 ///
73 /// ## Properties
74 ///
75 ///
76 /// #### `alternative-text`
77 /// The alternative textual description for the picture.
78 ///
79 /// Readable | Writeable
80 ///
81 ///
82 /// #### `can-shrink`
83 /// If the [`Picture`][crate::Picture] can be made smaller than the natural size of its contents.
84 ///
85 /// Readable | Writeable
86 ///
87 ///
88 /// #### `content-fit`
89 /// How the content should be resized to fit inside the [`Picture`][crate::Picture].
90 ///
91 /// Readable | Writeable
92 ///
93 ///
94 /// #### `file`
95 /// The `GFile` that is displayed or [`None`] if none.
96 ///
97 /// Readable | Writeable
98 ///
99 ///
100 /// #### `keep-aspect-ratio`
101 /// Whether the GtkPicture will render its contents trying to preserve the aspect
102 /// ratio.
103 ///
104 /// Readable | Writeable
105 ///
106 ///
107 /// #### `paintable`
108 /// The [`gdk::Paintable`][crate::gdk::Paintable] to be displayed by this [`Picture`][crate::Picture].
109 ///
110 /// Readable | Writeable
111 /// <details><summary><h4>Widget</h4></summary>
112 ///
113 ///
114 /// #### `can-focus`
115 /// Whether the widget or any of its descendents can accept
116 /// the input focus.
117 ///
118 /// This property is meant to be set by widget implementations,
119 /// typically in their instance init function.
120 ///
121 /// Readable | Writeable
122 ///
123 ///
124 /// #### `can-target`
125 /// Whether the widget can receive pointer events.
126 ///
127 /// Readable | Writeable
128 ///
129 ///
130 /// #### `css-classes`
131 /// A list of css classes applied to this widget.
132 ///
133 /// Readable | Writeable
134 ///
135 ///
136 /// #### `css-name`
137 /// The name of this widget in the CSS tree.
138 ///
139 /// This property is meant to be set by widget implementations,
140 /// typically in their instance init function.
141 ///
142 /// Readable | Writeable | Construct Only
143 ///
144 ///
145 /// #### `cursor`
146 /// The cursor used by @widget.
147 ///
148 /// Readable | Writeable
149 ///
150 ///
151 /// #### `focus-on-click`
152 /// Whether the widget should grab focus when it is clicked with the mouse.
153 ///
154 /// This property is only relevant for widgets that can take focus.
155 ///
156 /// Readable | Writeable
157 ///
158 ///
159 /// #### `focusable`
160 /// Whether this widget itself will accept the input focus.
161 ///
162 /// Readable | Writeable
163 ///
164 ///
165 /// #### `halign`
166 /// How to distribute horizontal space if widget gets extra space.
167 ///
168 /// Readable | Writeable
169 ///
170 ///
171 /// #### `has-default`
172 /// Whether the widget is the default widget.
173 ///
174 /// Readable
175 ///
176 ///
177 /// #### `has-focus`
178 /// Whether the widget has the input focus.
179 ///
180 /// Readable
181 ///
182 ///
183 /// #### `has-tooltip`
184 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
185 /// signal on @widget.
186 ///
187 /// A true value indicates that @widget can have a tooltip, in this case
188 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
189 /// determine whether it will provide a tooltip or not.
190 ///
191 /// Readable | Writeable
192 ///
193 ///
194 /// #### `height-request`
195 /// Overrides for height request of the widget.
196 ///
197 /// If this is -1, the natural request will be used.
198 ///
199 /// Readable | Writeable
200 ///
201 ///
202 /// #### `hexpand`
203 /// Whether to expand horizontally.
204 ///
205 /// Readable | Writeable
206 ///
207 ///
208 /// #### `hexpand-set`
209 /// Whether to use the `hexpand` property.
210 ///
211 /// Readable | Writeable
212 ///
213 ///
214 /// #### `layout-manager`
215 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
216 /// the preferred size of the widget, and allocate its children.
217 ///
218 /// This property is meant to be set by widget implementations,
219 /// typically in their instance init function.
220 ///
221 /// Readable | Writeable
222 ///
223 ///
224 /// #### `limit-events`
225 /// Makes this widget act like a modal dialog, with respect to
226 /// event delivery.
227 ///
228 /// Global event controllers will not handle events with targets
229 /// inside the widget, unless they are set up to ignore propagation
230 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
231 ///
232 /// Readable | Writeable
233 ///
234 ///
235 /// #### `margin-bottom`
236 /// Margin on bottom side of widget.
237 ///
238 /// This property adds margin outside of the widget's normal size
239 /// request, the margin will be added in addition to the size from
240 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
241 ///
242 /// Readable | Writeable
243 ///
244 ///
245 /// #### `margin-end`
246 /// Margin on end of widget, horizontally.
247 ///
248 /// This property supports left-to-right and right-to-left text
249 /// directions.
250 ///
251 /// This property adds margin outside of the widget's normal size
252 /// request, the margin will be added in addition to the size from
253 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
254 ///
255 /// Readable | Writeable
256 ///
257 ///
258 /// #### `margin-start`
259 /// Margin on start of widget, horizontally.
260 ///
261 /// This property supports left-to-right and right-to-left text
262 /// directions.
263 ///
264 /// This property adds margin outside of the widget's normal size
265 /// request, the margin will be added in addition to the size from
266 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
267 ///
268 /// Readable | Writeable
269 ///
270 ///
271 /// #### `margin-top`
272 /// Margin on top side of widget.
273 ///
274 /// This property adds margin outside of the widget's normal size
275 /// request, the margin will be added in addition to the size from
276 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
277 ///
278 /// Readable | Writeable
279 ///
280 ///
281 /// #### `name`
282 /// The name of the widget.
283 ///
284 /// Readable | Writeable
285 ///
286 ///
287 /// #### `opacity`
288 /// The requested opacity of the widget.
289 ///
290 /// Readable | Writeable
291 ///
292 ///
293 /// #### `overflow`
294 /// How content outside the widget's content area is treated.
295 ///
296 /// This property is meant to be set by widget implementations,
297 /// typically in their instance init function.
298 ///
299 /// Readable | Writeable
300 ///
301 ///
302 /// #### `parent`
303 /// The parent widget of this widget.
304 ///
305 /// Readable
306 ///
307 ///
308 /// #### `receives-default`
309 /// Whether the widget will receive the default action when it is focused.
310 ///
311 /// Readable | Writeable
312 ///
313 ///
314 /// #### `root`
315 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
316 ///
317 /// This will be `NULL` if the widget is not contained in a root widget.
318 ///
319 /// Readable
320 ///
321 ///
322 /// #### `scale-factor`
323 /// The scale factor of the widget.
324 ///
325 /// Readable
326 ///
327 ///
328 /// #### `sensitive`
329 /// Whether the widget responds to input.
330 ///
331 /// Readable | Writeable
332 ///
333 ///
334 /// #### `tooltip-markup`
335 /// Sets the text of tooltip to be the given string, which is marked up
336 /// with Pango markup.
337 ///
338 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
339 ///
340 /// This is a convenience property which will take care of getting the
341 /// tooltip shown if the given string is not `NULL`:
342 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
343 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
344 /// the default signal handler.
345 ///
346 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
347 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
348 ///
349 /// Readable | Writeable
350 ///
351 ///
352 /// #### `tooltip-text`
353 /// Sets the text of tooltip to be the given string.
354 ///
355 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
356 ///
357 /// This is a convenience property which will take care of getting the
358 /// tooltip shown if the given string is not `NULL`:
359 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
360 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
361 /// the default signal handler.
362 ///
363 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
364 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
365 ///
366 /// Readable | Writeable
367 ///
368 ///
369 /// #### `valign`
370 /// How to distribute vertical space if widget gets extra space.
371 ///
372 /// Readable | Writeable
373 ///
374 ///
375 /// #### `vexpand`
376 /// Whether to expand vertically.
377 ///
378 /// Readable | Writeable
379 ///
380 ///
381 /// #### `vexpand-set`
382 /// Whether to use the `vexpand` property.
383 ///
384 /// Readable | Writeable
385 ///
386 ///
387 /// #### `visible`
388 /// Whether the widget is visible.
389 ///
390 /// Readable | Writeable
391 ///
392 ///
393 /// #### `width-request`
394 /// Overrides for width request of the widget.
395 ///
396 /// If this is -1, the natural request will be used.
397 ///
398 /// Readable | Writeable
399 /// </details>
400 /// <details><summary><h4>Accessible</h4></summary>
401 ///
402 ///
403 /// #### `accessible-role`
404 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
405 ///
406 /// The accessible role cannot be changed once set.
407 ///
408 /// Readable | Writeable
409 /// </details>
410 ///
411 /// # Implements
412 ///
413 /// [`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]
414 #[doc(alias = "GtkPicture")]
415 pub struct Picture(Object<ffi::GtkPicture, ffi::GtkPictureClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
416
417 match fn {
418 type_ => || ffi::gtk_picture_get_type(),
419 }
420}
421
422impl Picture {
423 /// Creates a new empty [`Picture`][crate::Picture] widget.
424 ///
425 /// # Returns
426 ///
427 /// a newly created [`Picture`][crate::Picture] widget.
428 #[doc(alias = "gtk_picture_new")]
429 pub fn new() -> Picture {
430 assert_initialized_main_thread!();
431 unsafe { Widget::from_glib_none(ffi::gtk_picture_new()).unsafe_cast() }
432 }
433
434 /// Creates a new [`Picture`][crate::Picture] displaying the given @file.
435 ///
436 /// If the file isn’t found or can’t be loaded, the resulting
437 /// [`Picture`][crate::Picture] is empty.
438 ///
439 /// If you need to detect failures to load the file, use
440 /// [`gdk::Texture::from_file()`][crate::gdk::Texture::from_file()] to load the file yourself,
441 /// then create the [`Picture`][crate::Picture] from the texture.
442 /// ## `file`
443 /// a `GFile`
444 ///
445 /// # Returns
446 ///
447 /// a new [`Picture`][crate::Picture]
448 #[doc(alias = "gtk_picture_new_for_file")]
449 #[doc(alias = "new_for_file")]
450 pub fn for_file(file: &impl IsA<gio::File>) -> Picture {
451 assert_initialized_main_thread!();
452 unsafe {
453 Widget::from_glib_none(ffi::gtk_picture_new_for_file(
454 file.as_ref().to_glib_none().0,
455 ))
456 .unsafe_cast()
457 }
458 }
459
460 /// Creates a new [`Picture`][crate::Picture] displaying the file @filename.
461 ///
462 /// This is a utility function that calls [`for_file()`][Self::for_file()].
463 /// See that function for details.
464 /// ## `filename`
465 /// a filename
466 ///
467 /// # Returns
468 ///
469 /// a new [`Picture`][crate::Picture]
470 #[doc(alias = "gtk_picture_new_for_filename")]
471 #[doc(alias = "new_for_filename")]
472 pub fn for_filename(filename: impl AsRef<std::path::Path>) -> Picture {
473 assert_initialized_main_thread!();
474 unsafe {
475 Widget::from_glib_none(ffi::gtk_picture_new_for_filename(
476 filename.as_ref().to_glib_none().0,
477 ))
478 .unsafe_cast()
479 }
480 }
481
482 /// Creates a new [`Picture`][crate::Picture] displaying @paintable.
483 ///
484 /// The [`Picture`][crate::Picture] will track changes to the @paintable and update
485 /// its size and contents in response to it.
486 /// ## `paintable`
487 /// a [`gdk::Paintable`][crate::gdk::Paintable]
488 ///
489 /// # Returns
490 ///
491 /// a new [`Picture`][crate::Picture]
492 #[doc(alias = "gtk_picture_new_for_paintable")]
493 #[doc(alias = "new_for_paintable")]
494 pub fn for_paintable(paintable: &impl IsA<gdk::Paintable>) -> Picture {
495 assert_initialized_main_thread!();
496 unsafe {
497 Widget::from_glib_none(ffi::gtk_picture_new_for_paintable(
498 paintable.as_ref().to_glib_none().0,
499 ))
500 .unsafe_cast()
501 }
502 }
503
504 /// Creates a new [`Picture`][crate::Picture] displaying @pixbuf.
505 ///
506 /// This is a utility function that calls [`for_paintable()`][Self::for_paintable()],
507 /// See that function for details.
508 ///
509 /// The pixbuf must not be modified after passing it to this function.
510 ///
511 /// # Deprecated since 4.12
512 ///
513 /// Use [`for_paintable()`][Self::for_paintable()] and
514 /// [`gdk::Texture::for_pixbuf()`][crate::gdk::Texture::for_pixbuf()] instead
515 /// ## `pixbuf`
516 /// a [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf]
517 ///
518 /// # Returns
519 ///
520 /// a new [`Picture`][crate::Picture]
521 #[cfg_attr(feature = "v4_12", deprecated = "Since 4.12")]
522 #[allow(deprecated)]
523 #[doc(alias = "gtk_picture_new_for_pixbuf")]
524 #[doc(alias = "new_for_pixbuf")]
525 pub fn for_pixbuf(pixbuf: &gdk_pixbuf::Pixbuf) -> Picture {
526 assert_initialized_main_thread!();
527 unsafe {
528 Widget::from_glib_none(ffi::gtk_picture_new_for_pixbuf(pixbuf.to_glib_none().0))
529 .unsafe_cast()
530 }
531 }
532
533 /// Creates a new [`Picture`][crate::Picture] displaying the resource at @resource_path.
534 ///
535 /// This is a utility function that calls [`for_file()`][Self::for_file()].
536 /// See that function for details.
537 /// ## `resource_path`
538 /// resource path to play back
539 ///
540 /// # Returns
541 ///
542 /// a new [`Picture`][crate::Picture]
543 #[doc(alias = "gtk_picture_new_for_resource")]
544 #[doc(alias = "new_for_resource")]
545 pub fn for_resource(resource_path: &str) -> Picture {
546 assert_initialized_main_thread!();
547 unsafe {
548 Widget::from_glib_none(ffi::gtk_picture_new_for_resource(
549 resource_path.to_glib_none().0,
550 ))
551 .unsafe_cast()
552 }
553 }
554
555 // rustdoc-stripper-ignore-next
556 /// Creates a new builder-pattern struct instance to construct [`Picture`] objects.
557 ///
558 /// This method returns an instance of [`PictureBuilder`](crate::builders::PictureBuilder) which can be used to create [`Picture`] objects.
559 pub fn builder() -> PictureBuilder {
560 PictureBuilder::new()
561 }
562
563 /// Gets the alternative textual description of the picture.
564 ///
565 /// The returned string will be [`None`] if the picture cannot be described textually.
566 ///
567 /// # Returns
568 ///
569 /// the alternative textual description of @self.
570 #[doc(alias = "gtk_picture_get_alternative_text")]
571 #[doc(alias = "get_alternative_text")]
572 #[doc(alias = "alternative-text")]
573 pub fn alternative_text(&self) -> Option<glib::GString> {
574 unsafe { from_glib_none(ffi::gtk_picture_get_alternative_text(self.to_glib_none().0)) }
575 }
576
577 /// Returns whether the [`Picture`][crate::Picture] respects its contents size.
578 ///
579 /// # Returns
580 ///
581 /// [`true`] if the picture can be made smaller than its contents
582 #[doc(alias = "gtk_picture_get_can_shrink")]
583 #[doc(alias = "get_can_shrink")]
584 #[doc(alias = "can-shrink")]
585 pub fn can_shrink(&self) -> bool {
586 unsafe { from_glib(ffi::gtk_picture_get_can_shrink(self.to_glib_none().0)) }
587 }
588
589 /// Returns the fit mode for the content of the [`Picture`][crate::Picture].
590 ///
591 /// See [`ContentFit`][crate::ContentFit] for details.
592 ///
593 /// # Returns
594 ///
595 /// the content fit mode
596 #[cfg(feature = "v4_8")]
597 #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
598 #[doc(alias = "gtk_picture_get_content_fit")]
599 #[doc(alias = "get_content_fit")]
600 #[doc(alias = "content-fit")]
601 pub fn content_fit(&self) -> ContentFit {
602 unsafe { from_glib(ffi::gtk_picture_get_content_fit(self.to_glib_none().0)) }
603 }
604
605 /// Gets the `GFile` currently displayed if @self is displaying a file.
606 ///
607 /// If @self is not displaying a file, for example when
608 /// [`set_paintable()`][Self::set_paintable()] was used, then [`None`] is returned.
609 ///
610 /// # Returns
611 ///
612 /// The `GFile` displayed by @self.
613 #[doc(alias = "gtk_picture_get_file")]
614 #[doc(alias = "get_file")]
615 pub fn file(&self) -> Option<gio::File> {
616 unsafe { from_glib_none(ffi::gtk_picture_get_file(self.to_glib_none().0)) }
617 }
618
619 /// Returns whether the [`Picture`][crate::Picture] preserves its contents aspect ratio.
620 ///
621 /// # Deprecated since 4.8
622 ///
623 /// Use [`content_fit()`][Self::content_fit()] instead. This will
624 /// now return `FALSE` only if [`content-fit`][struct@crate::Picture#content-fit] is
625 /// `GTK_CONTENT_FIT_FILL`. Returns `TRUE` otherwise.
626 ///
627 /// # Returns
628 ///
629 /// [`true`] if the self tries to keep the contents' aspect ratio
630 #[cfg_attr(feature = "v4_8", deprecated = "Since 4.8")]
631 #[allow(deprecated)]
632 #[doc(alias = "gtk_picture_get_keep_aspect_ratio")]
633 #[doc(alias = "get_keep_aspect_ratio")]
634 #[doc(alias = "keep-aspect-ratio")]
635 pub fn is_keep_aspect_ratio(&self) -> bool {
636 unsafe {
637 from_glib(ffi::gtk_picture_get_keep_aspect_ratio(
638 self.to_glib_none().0,
639 ))
640 }
641 }
642
643 /// Gets the [`gdk::Paintable`][crate::gdk::Paintable] being displayed by the [`Picture`][crate::Picture].
644 ///
645 /// # Returns
646 ///
647 /// the displayed paintable
648 #[doc(alias = "gtk_picture_get_paintable")]
649 #[doc(alias = "get_paintable")]
650 pub fn paintable(&self) -> Option<gdk::Paintable> {
651 unsafe { from_glib_none(ffi::gtk_picture_get_paintable(self.to_glib_none().0)) }
652 }
653
654 /// Sets an alternative textual description for the picture contents.
655 ///
656 /// It is equivalent to the "alt" attribute for images on websites.
657 ///
658 /// This text will be made available to accessibility tools.
659 ///
660 /// If the picture cannot be described textually, set this property to [`None`].
661 /// ## `alternative_text`
662 /// a textual description of the contents
663 #[doc(alias = "gtk_picture_set_alternative_text")]
664 #[doc(alias = "alternative-text")]
665 pub fn set_alternative_text(&self, alternative_text: Option<&str>) {
666 unsafe {
667 ffi::gtk_picture_set_alternative_text(
668 self.to_glib_none().0,
669 alternative_text.to_glib_none().0,
670 );
671 }
672 }
673
674 /// If set to [`true`], the @self can be made smaller than its contents.
675 ///
676 /// The contents will then be scaled down when rendering.
677 ///
678 /// If you want to still force a minimum size manually, consider using
679 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()].
680 ///
681 /// Also of note is that a similar function for growing does not exist
682 /// because the grow behavior can be controlled via
683 /// [`WidgetExt::set_halign()`][crate::prelude::WidgetExt::set_halign()] and [`WidgetExt::set_valign()`][crate::prelude::WidgetExt::set_valign()].
684 /// ## `can_shrink`
685 /// if @self can be made smaller than its contents
686 #[doc(alias = "gtk_picture_set_can_shrink")]
687 #[doc(alias = "can-shrink")]
688 pub fn set_can_shrink(&self, can_shrink: bool) {
689 unsafe {
690 ffi::gtk_picture_set_can_shrink(self.to_glib_none().0, can_shrink.into_glib());
691 }
692 }
693
694 /// Sets how the content should be resized to fit the [`Picture`][crate::Picture].
695 ///
696 /// See [`ContentFit`][crate::ContentFit] for details.
697 /// ## `content_fit`
698 /// the content fit mode
699 #[cfg(feature = "v4_8")]
700 #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
701 #[doc(alias = "gtk_picture_set_content_fit")]
702 #[doc(alias = "content-fit")]
703 pub fn set_content_fit(&self, content_fit: ContentFit) {
704 unsafe {
705 ffi::gtk_picture_set_content_fit(self.to_glib_none().0, content_fit.into_glib());
706 }
707 }
708
709 /// Makes @self load and display @file.
710 ///
711 /// See [`for_file()`][Self::for_file()] for details.
712 /// ## `file`
713 /// a `GFile`
714 #[doc(alias = "gtk_picture_set_file")]
715 #[doc(alias = "file")]
716 pub fn set_file(&self, file: Option<&impl IsA<gio::File>>) {
717 unsafe {
718 ffi::gtk_picture_set_file(
719 self.to_glib_none().0,
720 file.map(|p| p.as_ref()).to_glib_none().0,
721 );
722 }
723 }
724
725 /// Makes @self load and display the given @filename.
726 ///
727 /// This is a utility function that calls [`set_file()`][Self::set_file()].
728 /// ## `filename`
729 /// the filename to play
730 #[doc(alias = "gtk_picture_set_filename")]
731 pub fn set_filename(&self, filename: Option<impl AsRef<std::path::Path>>) {
732 unsafe {
733 ffi::gtk_picture_set_filename(
734 self.to_glib_none().0,
735 filename.as_ref().map(|p| p.as_ref()).to_glib_none().0,
736 );
737 }
738 }
739
740 /// If set to [`true`], the @self will render its contents according to
741 /// their aspect ratio.
742 ///
743 /// That means that empty space may show up at the top/bottom or
744 /// left/right of @self.
745 ///
746 /// If set to [`false`] or if the contents provide no aspect ratio,
747 /// the contents will be stretched over the picture's whole area.
748 ///
749 /// # Deprecated since 4.8
750 ///
751 /// Use [`set_content_fit()`][Self::set_content_fit()] instead. If still
752 /// used, this method will always set the [`content-fit`][struct@crate::Picture#content-fit]
753 /// property to `GTK_CONTENT_FIT_CONTAIN` if @keep_aspect_ratio is true,
754 /// otherwise it will set it to `GTK_CONTENT_FIT_FILL`.
755 /// ## `keep_aspect_ratio`
756 /// whether to keep aspect ratio
757 #[cfg_attr(feature = "v4_8", deprecated = "Since 4.8")]
758 #[allow(deprecated)]
759 #[doc(alias = "gtk_picture_set_keep_aspect_ratio")]
760 #[doc(alias = "keep-aspect-ratio")]
761 pub fn set_keep_aspect_ratio(&self, keep_aspect_ratio: bool) {
762 unsafe {
763 ffi::gtk_picture_set_keep_aspect_ratio(
764 self.to_glib_none().0,
765 keep_aspect_ratio.into_glib(),
766 );
767 }
768 }
769
770 /// Makes @self display the given @paintable.
771 ///
772 /// If @paintable is [`None`], nothing will be displayed.
773 ///
774 /// See [`for_paintable()`][Self::for_paintable()] for details.
775 /// ## `paintable`
776 /// a [`gdk::Paintable`][crate::gdk::Paintable]
777 #[doc(alias = "gtk_picture_set_paintable")]
778 #[doc(alias = "paintable")]
779 pub fn set_paintable(&self, paintable: Option<&impl IsA<gdk::Paintable>>) {
780 unsafe {
781 ffi::gtk_picture_set_paintable(
782 self.to_glib_none().0,
783 paintable.map(|p| p.as_ref()).to_glib_none().0,
784 );
785 }
786 }
787
788 /// Sets a [`Picture`][crate::Picture] to show a [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf].
789 ///
790 /// See [`for_pixbuf()`][Self::for_pixbuf()] for details.
791 ///
792 /// This is a utility function that calls [`set_paintable()`][Self::set_paintable()].
793 ///
794 /// # Deprecated since 4.12
795 ///
796 /// Use [`set_paintable()`][Self::set_paintable()] instead
797 /// ## `pixbuf`
798 /// a [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf]
799 #[cfg_attr(feature = "v4_12", deprecated = "Since 4.12")]
800 #[allow(deprecated)]
801 #[doc(alias = "gtk_picture_set_pixbuf")]
802 pub fn set_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>) {
803 unsafe {
804 ffi::gtk_picture_set_pixbuf(self.to_glib_none().0, pixbuf.to_glib_none().0);
805 }
806 }
807
808 /// Makes @self load and display the resource at the given
809 /// @resource_path.
810 ///
811 /// This is a utility function that calls [`set_file()`][Self::set_file()].
812 /// ## `resource_path`
813 /// the resource to set
814 #[doc(alias = "gtk_picture_set_resource")]
815 pub fn set_resource(&self, resource_path: Option<&str>) {
816 unsafe {
817 ffi::gtk_picture_set_resource(self.to_glib_none().0, resource_path.to_glib_none().0);
818 }
819 }
820
821 #[doc(alias = "alternative-text")]
822 pub fn connect_alternative_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
823 unsafe extern "C" fn notify_alternative_text_trampoline<F: Fn(&Picture) + 'static>(
824 this: *mut ffi::GtkPicture,
825 _param_spec: glib::ffi::gpointer,
826 f: glib::ffi::gpointer,
827 ) {
828 let f: &F = &*(f as *const F);
829 f(&from_glib_borrow(this))
830 }
831 unsafe {
832 let f: Box_<F> = Box_::new(f);
833 connect_raw(
834 self.as_ptr() as *mut _,
835 c"notify::alternative-text".as_ptr() as *const _,
836 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
837 notify_alternative_text_trampoline::<F> as *const (),
838 )),
839 Box_::into_raw(f),
840 )
841 }
842 }
843
844 #[doc(alias = "can-shrink")]
845 pub fn connect_can_shrink_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
846 unsafe extern "C" fn notify_can_shrink_trampoline<F: Fn(&Picture) + 'static>(
847 this: *mut ffi::GtkPicture,
848 _param_spec: glib::ffi::gpointer,
849 f: glib::ffi::gpointer,
850 ) {
851 let f: &F = &*(f as *const F);
852 f(&from_glib_borrow(this))
853 }
854 unsafe {
855 let f: Box_<F> = Box_::new(f);
856 connect_raw(
857 self.as_ptr() as *mut _,
858 c"notify::can-shrink".as_ptr() as *const _,
859 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
860 notify_can_shrink_trampoline::<F> as *const (),
861 )),
862 Box_::into_raw(f),
863 )
864 }
865 }
866
867 #[cfg(feature = "v4_8")]
868 #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
869 #[doc(alias = "content-fit")]
870 pub fn connect_content_fit_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
871 unsafe extern "C" fn notify_content_fit_trampoline<F: Fn(&Picture) + 'static>(
872 this: *mut ffi::GtkPicture,
873 _param_spec: glib::ffi::gpointer,
874 f: glib::ffi::gpointer,
875 ) {
876 let f: &F = &*(f as *const F);
877 f(&from_glib_borrow(this))
878 }
879 unsafe {
880 let f: Box_<F> = Box_::new(f);
881 connect_raw(
882 self.as_ptr() as *mut _,
883 c"notify::content-fit".as_ptr() as *const _,
884 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
885 notify_content_fit_trampoline::<F> as *const (),
886 )),
887 Box_::into_raw(f),
888 )
889 }
890 }
891
892 #[doc(alias = "file")]
893 pub fn connect_file_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
894 unsafe extern "C" fn notify_file_trampoline<F: Fn(&Picture) + 'static>(
895 this: *mut ffi::GtkPicture,
896 _param_spec: glib::ffi::gpointer,
897 f: glib::ffi::gpointer,
898 ) {
899 let f: &F = &*(f as *const F);
900 f(&from_glib_borrow(this))
901 }
902 unsafe {
903 let f: Box_<F> = Box_::new(f);
904 connect_raw(
905 self.as_ptr() as *mut _,
906 c"notify::file".as_ptr() as *const _,
907 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
908 notify_file_trampoline::<F> as *const (),
909 )),
910 Box_::into_raw(f),
911 )
912 }
913 }
914
915 #[cfg_attr(feature = "v4_8", deprecated = "Since 4.8")]
916 #[doc(alias = "keep-aspect-ratio")]
917 pub fn connect_keep_aspect_ratio_notify<F: Fn(&Self) + 'static>(
918 &self,
919 f: F,
920 ) -> SignalHandlerId {
921 unsafe extern "C" fn notify_keep_aspect_ratio_trampoline<F: Fn(&Picture) + 'static>(
922 this: *mut ffi::GtkPicture,
923 _param_spec: glib::ffi::gpointer,
924 f: glib::ffi::gpointer,
925 ) {
926 let f: &F = &*(f as *const F);
927 f(&from_glib_borrow(this))
928 }
929 unsafe {
930 let f: Box_<F> = Box_::new(f);
931 connect_raw(
932 self.as_ptr() as *mut _,
933 c"notify::keep-aspect-ratio".as_ptr() as *const _,
934 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
935 notify_keep_aspect_ratio_trampoline::<F> as *const (),
936 )),
937 Box_::into_raw(f),
938 )
939 }
940 }
941
942 #[doc(alias = "paintable")]
943 pub fn connect_paintable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
944 unsafe extern "C" fn notify_paintable_trampoline<F: Fn(&Picture) + 'static>(
945 this: *mut ffi::GtkPicture,
946 _param_spec: glib::ffi::gpointer,
947 f: glib::ffi::gpointer,
948 ) {
949 let f: &F = &*(f as *const F);
950 f(&from_glib_borrow(this))
951 }
952 unsafe {
953 let f: Box_<F> = Box_::new(f);
954 connect_raw(
955 self.as_ptr() as *mut _,
956 c"notify::paintable".as_ptr() as *const _,
957 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
958 notify_paintable_trampoline::<F> as *const (),
959 )),
960 Box_::into_raw(f),
961 )
962 }
963 }
964}
965
966impl Default for Picture {
967 fn default() -> Self {
968 Self::new()
969 }
970}
971
972// rustdoc-stripper-ignore-next
973/// A [builder-pattern] type to construct [`Picture`] objects.
974///
975/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
976#[must_use = "The builder must be built to be used"]
977pub struct PictureBuilder {
978 builder: glib::object::ObjectBuilder<'static, Picture>,
979}
980
981impl PictureBuilder {
982 fn new() -> Self {
983 Self {
984 builder: glib::object::Object::builder(),
985 }
986 }
987
988 /// The alternative textual description for the picture.
989 pub fn alternative_text(self, alternative_text: impl Into<glib::GString>) -> Self {
990 Self {
991 builder: self
992 .builder
993 .property("alternative-text", alternative_text.into()),
994 }
995 }
996
997 /// If the [`Picture`][crate::Picture] can be made smaller than the natural size of its contents.
998 pub fn can_shrink(self, can_shrink: bool) -> Self {
999 Self {
1000 builder: self.builder.property("can-shrink", can_shrink),
1001 }
1002 }
1003
1004 /// How the content should be resized to fit inside the [`Picture`][crate::Picture].
1005 #[cfg(feature = "v4_8")]
1006 #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
1007 pub fn content_fit(self, content_fit: ContentFit) -> Self {
1008 Self {
1009 builder: self.builder.property("content-fit", content_fit),
1010 }
1011 }
1012
1013 /// The `GFile` that is displayed or [`None`] if none.
1014 pub fn file(self, file: &impl IsA<gio::File>) -> Self {
1015 Self {
1016 builder: self.builder.property("file", file.clone().upcast()),
1017 }
1018 }
1019
1020 /// Whether the GtkPicture will render its contents trying to preserve the aspect
1021 /// ratio.
1022 /// Use [`content-fit`][struct@crate::Picture#content-fit] instead.
1023 #[cfg_attr(feature = "v4_8", deprecated = "Since 4.8")]
1024 pub fn keep_aspect_ratio(self, keep_aspect_ratio: bool) -> Self {
1025 Self {
1026 builder: self
1027 .builder
1028 .property("keep-aspect-ratio", keep_aspect_ratio),
1029 }
1030 }
1031
1032 /// The [`gdk::Paintable`][crate::gdk::Paintable] to be displayed by this [`Picture`][crate::Picture].
1033 pub fn paintable(self, paintable: &impl IsA<gdk::Paintable>) -> Self {
1034 Self {
1035 builder: self
1036 .builder
1037 .property("paintable", paintable.clone().upcast()),
1038 }
1039 }
1040
1041 /// Whether the widget or any of its descendents can accept
1042 /// the input focus.
1043 ///
1044 /// This property is meant to be set by widget implementations,
1045 /// typically in their instance init function.
1046 pub fn can_focus(self, can_focus: bool) -> Self {
1047 Self {
1048 builder: self.builder.property("can-focus", can_focus),
1049 }
1050 }
1051
1052 /// Whether the widget can receive pointer events.
1053 pub fn can_target(self, can_target: bool) -> Self {
1054 Self {
1055 builder: self.builder.property("can-target", can_target),
1056 }
1057 }
1058
1059 /// A list of css classes applied to this widget.
1060 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1061 Self {
1062 builder: self.builder.property("css-classes", css_classes.into()),
1063 }
1064 }
1065
1066 /// The name of this widget in the CSS tree.
1067 ///
1068 /// This property is meant to be set by widget implementations,
1069 /// typically in their instance init function.
1070 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1071 Self {
1072 builder: self.builder.property("css-name", css_name.into()),
1073 }
1074 }
1075
1076 /// The cursor used by @widget.
1077 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1078 Self {
1079 builder: self.builder.property("cursor", cursor.clone()),
1080 }
1081 }
1082
1083 /// Whether the widget should grab focus when it is clicked with the mouse.
1084 ///
1085 /// This property is only relevant for widgets that can take focus.
1086 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1087 Self {
1088 builder: self.builder.property("focus-on-click", focus_on_click),
1089 }
1090 }
1091
1092 /// Whether this widget itself will accept the input focus.
1093 pub fn focusable(self, focusable: bool) -> Self {
1094 Self {
1095 builder: self.builder.property("focusable", focusable),
1096 }
1097 }
1098
1099 /// How to distribute horizontal space if widget gets extra space.
1100 pub fn halign(self, halign: Align) -> Self {
1101 Self {
1102 builder: self.builder.property("halign", halign),
1103 }
1104 }
1105
1106 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1107 /// signal on @widget.
1108 ///
1109 /// A true value indicates that @widget can have a tooltip, in this case
1110 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1111 /// determine whether it will provide a tooltip or not.
1112 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1113 Self {
1114 builder: self.builder.property("has-tooltip", has_tooltip),
1115 }
1116 }
1117
1118 /// Overrides for height request of the widget.
1119 ///
1120 /// If this is -1, the natural request will be used.
1121 pub fn height_request(self, height_request: i32) -> Self {
1122 Self {
1123 builder: self.builder.property("height-request", height_request),
1124 }
1125 }
1126
1127 /// Whether to expand horizontally.
1128 pub fn hexpand(self, hexpand: bool) -> Self {
1129 Self {
1130 builder: self.builder.property("hexpand", hexpand),
1131 }
1132 }
1133
1134 /// Whether to use the `hexpand` property.
1135 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1136 Self {
1137 builder: self.builder.property("hexpand-set", hexpand_set),
1138 }
1139 }
1140
1141 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1142 /// the preferred size of the widget, and allocate its children.
1143 ///
1144 /// This property is meant to be set by widget implementations,
1145 /// typically in their instance init function.
1146 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1147 Self {
1148 builder: self
1149 .builder
1150 .property("layout-manager", layout_manager.clone().upcast()),
1151 }
1152 }
1153
1154 /// Makes this widget act like a modal dialog, with respect to
1155 /// event delivery.
1156 ///
1157 /// Global event controllers will not handle events with targets
1158 /// inside the widget, unless they are set up to ignore propagation
1159 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1160 #[cfg(feature = "v4_18")]
1161 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1162 pub fn limit_events(self, limit_events: bool) -> Self {
1163 Self {
1164 builder: self.builder.property("limit-events", limit_events),
1165 }
1166 }
1167
1168 /// Margin on bottom side of widget.
1169 ///
1170 /// This property adds margin outside of the widget's normal size
1171 /// request, the margin will be added in addition to the size from
1172 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1173 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1174 Self {
1175 builder: self.builder.property("margin-bottom", margin_bottom),
1176 }
1177 }
1178
1179 /// Margin on end of widget, horizontally.
1180 ///
1181 /// This property supports left-to-right and right-to-left text
1182 /// directions.
1183 ///
1184 /// This property adds margin outside of the widget's normal size
1185 /// request, the margin will be added in addition to the size from
1186 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1187 pub fn margin_end(self, margin_end: i32) -> Self {
1188 Self {
1189 builder: self.builder.property("margin-end", margin_end),
1190 }
1191 }
1192
1193 /// Margin on start of widget, horizontally.
1194 ///
1195 /// This property supports left-to-right and right-to-left text
1196 /// directions.
1197 ///
1198 /// This property adds margin outside of the widget's normal size
1199 /// request, the margin will be added in addition to the size from
1200 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1201 pub fn margin_start(self, margin_start: i32) -> Self {
1202 Self {
1203 builder: self.builder.property("margin-start", margin_start),
1204 }
1205 }
1206
1207 /// Margin on top side of widget.
1208 ///
1209 /// This property adds margin outside of the widget's normal size
1210 /// request, the margin will be added in addition to the size from
1211 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1212 pub fn margin_top(self, margin_top: i32) -> Self {
1213 Self {
1214 builder: self.builder.property("margin-top", margin_top),
1215 }
1216 }
1217
1218 /// The name of the widget.
1219 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1220 Self {
1221 builder: self.builder.property("name", name.into()),
1222 }
1223 }
1224
1225 /// The requested opacity of the widget.
1226 pub fn opacity(self, opacity: f64) -> Self {
1227 Self {
1228 builder: self.builder.property("opacity", opacity),
1229 }
1230 }
1231
1232 /// How content outside the widget's content area is treated.
1233 ///
1234 /// This property is meant to be set by widget implementations,
1235 /// typically in their instance init function.
1236 pub fn overflow(self, overflow: Overflow) -> Self {
1237 Self {
1238 builder: self.builder.property("overflow", overflow),
1239 }
1240 }
1241
1242 /// Whether the widget will receive the default action when it is focused.
1243 pub fn receives_default(self, receives_default: bool) -> Self {
1244 Self {
1245 builder: self.builder.property("receives-default", receives_default),
1246 }
1247 }
1248
1249 /// Whether the widget responds to input.
1250 pub fn sensitive(self, sensitive: bool) -> Self {
1251 Self {
1252 builder: self.builder.property("sensitive", sensitive),
1253 }
1254 }
1255
1256 /// Sets the text of tooltip to be the given string, which is marked up
1257 /// with Pango markup.
1258 ///
1259 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1260 ///
1261 /// This is a convenience property which will take care of getting the
1262 /// tooltip shown if the given string is not `NULL`:
1263 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1264 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1265 /// the default signal handler.
1266 ///
1267 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1268 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1269 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1270 Self {
1271 builder: self
1272 .builder
1273 .property("tooltip-markup", tooltip_markup.into()),
1274 }
1275 }
1276
1277 /// Sets the text of tooltip to be the given string.
1278 ///
1279 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1280 ///
1281 /// This is a convenience property which will take care of getting the
1282 /// tooltip shown if the given string is not `NULL`:
1283 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1284 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1285 /// the default signal handler.
1286 ///
1287 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1288 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1289 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1290 Self {
1291 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1292 }
1293 }
1294
1295 /// How to distribute vertical space if widget gets extra space.
1296 pub fn valign(self, valign: Align) -> Self {
1297 Self {
1298 builder: self.builder.property("valign", valign),
1299 }
1300 }
1301
1302 /// Whether to expand vertically.
1303 pub fn vexpand(self, vexpand: bool) -> Self {
1304 Self {
1305 builder: self.builder.property("vexpand", vexpand),
1306 }
1307 }
1308
1309 /// Whether to use the `vexpand` property.
1310 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1311 Self {
1312 builder: self.builder.property("vexpand-set", vexpand_set),
1313 }
1314 }
1315
1316 /// Whether the widget is visible.
1317 pub fn visible(self, visible: bool) -> Self {
1318 Self {
1319 builder: self.builder.property("visible", visible),
1320 }
1321 }
1322
1323 /// Overrides for width request of the widget.
1324 ///
1325 /// If this is -1, the natural request will be used.
1326 pub fn width_request(self, width_request: i32) -> Self {
1327 Self {
1328 builder: self.builder.property("width-request", width_request),
1329 }
1330 }
1331
1332 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1333 ///
1334 /// The accessible role cannot be changed once set.
1335 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1336 Self {
1337 builder: self.builder.property("accessible-role", accessible_role),
1338 }
1339 }
1340
1341 // rustdoc-stripper-ignore-next
1342 /// Build the [`Picture`].
1343 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1344 pub fn build(self) -> Picture {
1345 assert_initialized_main_thread!();
1346 self.builder.build()
1347 }
1348}