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