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