Skip to main content

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