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