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