Skip to main content

gtk/auto/
image.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
5use crate::{Buildable, IconSize, ImageType, Misc, Widget};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::{boxed::Box as Box_, fmt, mem, mem::transmute, ptr};
12
13glib::wrapper! {
14    /// The [`Image`][crate::Image] widget displays an image. Various kinds of object
15    /// can be displayed as an image; most typically, you would load a
16    /// [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf] ("pixel buffer") from a file, and then display that.
17    /// There’s a convenience function to do this, [`from_file()`][Self::from_file()],
18    /// used as follows:
19    ///
20    ///
21    /// **⚠️ The following code is in C ⚠️**
22    ///
23    /// ```C
24    ///   GtkWidget *image;
25    ///   image = gtk_image_new_from_file ("myfile.png");
26    /// ```
27    /// If the file isn’t loaded successfully, the image will contain a
28    /// “broken image” icon similar to that used in many web browsers.
29    /// If you want to handle errors in loading the file yourself,
30    /// for example by displaying an error message, then load the image with
31    /// [`gdk_pixbuf::Pixbuf::from_file()`][crate::gdk_pixbuf::Pixbuf::from_file()], then create the [`Image`][crate::Image] with
32    /// [`from_pixbuf()`][Self::from_pixbuf()].
33    ///
34    /// The image file may contain an animation, if so the [`Image`][crate::Image] will
35    /// display an animation ([`gdk_pixbuf::PixbufAnimation`][crate::gdk_pixbuf::PixbufAnimation]) instead of a static image.
36    ///
37    /// [`Image`][crate::Image] is a subclass of [`Misc`][crate::Misc], which implies that you can
38    /// align it (center, left, right) and add padding to it, using
39    /// [`Misc`][crate::Misc] methods.
40    ///
41    /// [`Image`][crate::Image] is a “no window” widget (has no [`gdk::Window`][crate::gdk::Window] of its own),
42    /// so by default does not receive events. If you want to receive events
43    /// on the image, such as button clicks, place the image inside a
44    /// [`EventBox`][crate::EventBox], then connect to the event signals on the event box.
45    ///
46    /// ## Handling button press events on a [`Image`][crate::Image].
47    ///
48    ///
49    ///
50    /// **⚠️ The following code is in C ⚠️**
51    ///
52    /// ```C
53    ///   static gboolean
54    ///   button_press_callback (GtkWidget      *event_box,
55    ///                          GdkEventButton *event,
56    ///                          gpointer        data)
57    ///   {
58    ///     g_print ("Event box clicked at coordinates %f,%f\n",
59    ///              event->x, event->y);
60    ///
61    ///     // Returning TRUE means we handled the event, so the signal
62    ///     // emission should be stopped (don’t call any further callbacks
63    ///     // that may be connected). Return FALSE to continue invoking callbacks.
64    ///     return TRUE;
65    ///   }
66    ///
67    ///   static GtkWidget*
68    ///   create_image (void)
69    ///   {
70    ///     GtkWidget *image;
71    ///     GtkWidget *event_box;
72    ///
73    ///     image = gtk_image_new_from_file ("myfile.png");
74    ///
75    ///     event_box = gtk_event_box_new ();
76    ///
77    ///     gtk_container_add (GTK_CONTAINER (event_box), image);
78    ///
79    ///     g_signal_connect (G_OBJECT (event_box),
80    ///                       "button_press_event",
81    ///                       G_CALLBACK (button_press_callback),
82    ///                       image);
83    ///
84    ///     return image;
85    ///   }
86    /// ```
87    ///
88    /// When handling events on the event box, keep in mind that coordinates
89    /// in the image may be different from event box coordinates due to
90    /// the alignment and padding settings on the image (see [`Misc`][crate::Misc]).
91    /// The simplest way to solve this is to set the alignment to 0.0
92    /// (left/top), and set the padding to zero. Then the origin of
93    /// the image will be the same as the origin of the event box.
94    ///
95    /// Sometimes an application will want to avoid depending on external data
96    /// files, such as image files. GTK+ comes with a program to avoid this,
97    /// called “gdk-pixbuf-csource”. This library
98    /// allows you to convert an image into a C variable declaration, which
99    /// can then be loaded into a [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf] using
100    /// `gdk_pixbuf_new_from_inline()`.
101    ///
102    /// # CSS nodes
103    ///
104    /// GtkImage has a single CSS node with the name image. The style classes
105    /// may appear on image CSS nodes: .icon-dropshadow, .lowres-icon.
106    ///
107    /// ## Properties
108    ///
109    ///
110    /// #### `file`
111    ///  Readable | Writeable
112    ///
113    ///
114    /// #### `gicon`
115    ///  The GIcon displayed in the GtkImage. For themed icons,
116    /// If the icon theme is changed, the image will be updated
117    /// automatically.
118    ///
119    /// Readable | Writeable
120    ///
121    ///
122    /// #### `icon-name`
123    ///  The name of the icon in the icon theme. If the icon theme is
124    /// changed, the image will be updated automatically.
125    ///
126    /// Readable | Writeable
127    ///
128    ///
129    /// #### `icon-set`
130    ///  Readable | Writeable
131    ///
132    ///
133    /// #### `icon-size`
134    ///  Readable | Writeable
135    ///
136    ///
137    /// #### `pixbuf`
138    ///  Readable | Writeable
139    ///
140    ///
141    /// #### `pixbuf-animation`
142    ///  Readable | Writeable
143    ///
144    ///
145    /// #### `pixel-size`
146    ///  The "pixel-size" property can be used to specify a fixed size
147    /// overriding the [`icon-size`][struct@crate::Image#icon-size] property for images of type
148    /// [`ImageType::IconName`][crate::ImageType::IconName].
149    ///
150    /// Readable | Writeable
151    ///
152    ///
153    /// #### `resource`
154    ///  A path to a resource file to display.
155    ///
156    /// Readable | Writeable
157    ///
158    ///
159    /// #### `stock`
160    ///  Readable | Writeable
161    ///
162    ///
163    /// #### `storage-type`
164    ///  Readable
165    ///
166    ///
167    /// #### `surface`
168    ///  Readable | Writeable
169    ///
170    ///
171    /// #### `use-fallback`
172    ///  Whether the icon displayed in the GtkImage will use
173    /// standard icon names fallback. The value of this property
174    /// is only relevant for images of type [`ImageType::IconName`][crate::ImageType::IconName]
175    /// and [`ImageType::Gicon`][crate::ImageType::Gicon].
176    ///
177    /// Readable | Writeable
178    /// <details><summary><h4>Misc</h4></summary>
179    ///
180    ///
181    /// #### `xalign`
182    ///  The horizontal alignment. A value of 0.0 means left alignment (or right
183    /// on RTL locales); a value of 1.0 means right alignment (or left on RTL
184    /// locales).
185    ///
186    /// Readable | Writeable
187    ///
188    ///
189    /// #### `xpad`
190    ///  The amount of space to add on the left and right of the widget, in
191    /// pixels.
192    ///
193    /// Readable | Writeable
194    ///
195    ///
196    /// #### `yalign`
197    ///  The vertical alignment. A value of 0.0 means top alignment;
198    /// a value of 1.0 means bottom alignment.
199    ///
200    /// Readable | Writeable
201    ///
202    ///
203    /// #### `ypad`
204    ///  The amount of space to add on the top and bottom of the widget, in
205    /// pixels.
206    ///
207    /// Readable | Writeable
208    /// </details>
209    /// <details><summary><h4>Widget</h4></summary>
210    ///
211    ///
212    /// #### `app-paintable`
213    ///  Readable | Writeable
214    ///
215    ///
216    /// #### `can-default`
217    ///  Readable | Writeable
218    ///
219    ///
220    /// #### `can-focus`
221    ///  Readable | Writeable
222    ///
223    ///
224    /// #### `composite-child`
225    ///  Readable
226    ///
227    ///
228    /// #### `double-buffered`
229    ///  Whether the widget is double buffered.
230    ///
231    /// Readable | Writeable
232    ///
233    ///
234    /// #### `events`
235    ///  Readable | Writeable
236    ///
237    ///
238    /// #### `expand`
239    ///  Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
240    ///
241    /// Readable | Writeable
242    ///
243    ///
244    /// #### `focus-on-click`
245    ///  Whether the widget should grab focus when it is clicked with the mouse.
246    ///
247    /// This property is only relevant for widgets that can take focus.
248    ///
249    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
250    /// GtkComboBox) implemented this property individually.
251    ///
252    /// Readable | Writeable
253    ///
254    ///
255    /// #### `halign`
256    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
257    ///
258    /// Readable | Writeable
259    ///
260    ///
261    /// #### `has-default`
262    ///  Readable | Writeable
263    ///
264    ///
265    /// #### `has-focus`
266    ///  Readable | Writeable
267    ///
268    ///
269    /// #### `has-tooltip`
270    ///  Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
271    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
272    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
273    /// whether it will provide a tooltip or not.
274    ///
275    /// Note that setting this property to [`true`] for the first time will change
276    /// the event masks of the GdkWindows of this widget to include leave-notify
277    /// and motion-notify events. This cannot and will not be undone when the
278    /// property is set to [`false`] again.
279    ///
280    /// Readable | Writeable
281    ///
282    ///
283    /// #### `height-request`
284    ///  Readable | Writeable
285    ///
286    ///
287    /// #### `hexpand`
288    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
289    ///
290    /// Readable | Writeable
291    ///
292    ///
293    /// #### `hexpand-set`
294    ///  Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
295    ///
296    /// Readable | Writeable
297    ///
298    ///
299    /// #### `is-focus`
300    ///  Readable | Writeable
301    ///
302    ///
303    /// #### `margin`
304    ///  Sets all four sides' margin at once. If read, returns max
305    /// margin on any side.
306    ///
307    /// Readable | Writeable
308    ///
309    ///
310    /// #### `margin-bottom`
311    ///  Margin on bottom side of widget.
312    ///
313    /// This property adds margin outside of the widget's normal size
314    /// request, the margin will be added in addition to the size from
315    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
316    ///
317    /// Readable | Writeable
318    ///
319    ///
320    /// #### `margin-end`
321    ///  Margin on end of widget, horizontally. This property supports
322    /// left-to-right and right-to-left text directions.
323    ///
324    /// This property adds margin outside of the widget's normal size
325    /// request, the margin will be added in addition to the size from
326    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
327    ///
328    /// Readable | Writeable
329    ///
330    ///
331    /// #### `margin-left`
332    ///  Margin on left side of widget.
333    ///
334    /// This property adds margin outside of the widget's normal size
335    /// request, the margin will be added in addition to the size from
336    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
337    ///
338    /// Readable | Writeable
339    ///
340    ///
341    /// #### `margin-right`
342    ///  Margin on right side of widget.
343    ///
344    /// This property adds margin outside of the widget's normal size
345    /// request, the margin will be added in addition to the size from
346    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
347    ///
348    /// Readable | Writeable
349    ///
350    ///
351    /// #### `margin-start`
352    ///  Margin on start of widget, horizontally. This property supports
353    /// left-to-right and right-to-left text directions.
354    ///
355    /// This property adds margin outside of the widget's normal size
356    /// request, the margin will be added in addition to the size from
357    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
358    ///
359    /// Readable | Writeable
360    ///
361    ///
362    /// #### `margin-top`
363    ///  Margin on top side of widget.
364    ///
365    /// This property adds margin outside of the widget's normal size
366    /// request, the margin will be added in addition to the size from
367    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
368    ///
369    /// Readable | Writeable
370    ///
371    ///
372    /// #### `name`
373    ///  Readable | Writeable
374    ///
375    ///
376    /// #### `no-show-all`
377    ///  Readable | Writeable
378    ///
379    ///
380    /// #### `opacity`
381    ///  The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
382    /// more details about window opacity.
383    ///
384    /// Before 3.8 this was only available in GtkWindow
385    ///
386    /// Readable | Writeable
387    ///
388    ///
389    /// #### `parent`
390    ///  Readable | Writeable
391    ///
392    ///
393    /// #### `receives-default`
394    ///  Readable | Writeable
395    ///
396    ///
397    /// #### `scale-factor`
398    ///  The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
399    /// more details about widget scaling.
400    ///
401    /// Readable
402    ///
403    ///
404    /// #### `sensitive`
405    ///  Readable | Writeable
406    ///
407    ///
408    /// #### `style`
409    ///  The style of the widget, which contains information about how it will look (colors, etc).
410    ///
411    /// Readable | Writeable
412    ///
413    ///
414    /// #### `tooltip-markup`
415    ///  Sets the text of tooltip to be the given string, which is marked up
416    /// with the [Pango text markup language][PangoMarkupFormat].
417    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
418    ///
419    /// This is a convenience property which will take care of getting the
420    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
421    /// will automatically be set to [`true`] and there will be taken care of
422    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
423    ///
424    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
425    /// are set, the last one wins.
426    ///
427    /// Readable | Writeable
428    ///
429    ///
430    /// #### `tooltip-text`
431    ///  Sets the text of tooltip to be the given string.
432    ///
433    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
434    ///
435    /// This is a convenience property which will take care of getting the
436    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
437    /// will automatically be set to [`true`] and there will be taken care of
438    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
439    ///
440    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
441    /// are set, the last one wins.
442    ///
443    /// Readable | Writeable
444    ///
445    ///
446    /// #### `valign`
447    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
448    ///
449    /// Readable | Writeable
450    ///
451    ///
452    /// #### `vexpand`
453    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
454    ///
455    /// Readable | Writeable
456    ///
457    ///
458    /// #### `vexpand-set`
459    ///  Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
460    ///
461    /// Readable | Writeable
462    ///
463    ///
464    /// #### `visible`
465    ///  Readable | Writeable
466    ///
467    ///
468    /// #### `width-request`
469    ///  Readable | Writeable
470    ///
471    ///
472    /// #### `window`
473    ///  The widget's window if it is realized, [`None`] otherwise.
474    ///
475    /// Readable
476    /// </details>
477    ///
478    /// # Implements
479    ///
480    /// [`ImageExt`][trait@crate::prelude::ImageExt], [`MiscExt`][trait@crate::prelude::MiscExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ImageExtManual`][trait@crate::prelude::ImageExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
481    #[doc(alias = "GtkImage")]
482    pub struct Image(Object<ffi::GtkImage, ffi::GtkImageClass>) @extends Misc, Widget, @implements Buildable;
483
484    match fn {
485        type_ => || ffi::gtk_image_get_type(),
486    }
487}
488
489impl Image {
490    pub const NONE: Option<&'static Image> = None;
491
492    /// Creates a new empty [`Image`][crate::Image] widget.
493    ///
494    /// # Returns
495    ///
496    /// a newly created [`Image`][crate::Image] widget.
497    #[doc(alias = "gtk_image_new")]
498    pub fn new() -> Image {
499        assert_initialized_main_thread!();
500        unsafe { Widget::from_glib_none(ffi::gtk_image_new()).unsafe_cast() }
501    }
502
503    /// Creates a [`Image`][crate::Image] displaying the given animation.
504    /// The [`Image`][crate::Image] does not assume a reference to the
505    /// animation; you still need to unref it if you own references.
506    /// [`Image`][crate::Image] will add its own reference rather than adopting yours.
507    ///
508    /// Note that the animation frames are shown using a timeout with
509    /// `G_PRIORITY_DEFAULT`. When using animations to indicate busyness,
510    /// keep in mind that the animation will only be shown if the main loop
511    /// is not busy with something that has a higher priority.
512    /// ## `animation`
513    /// an animation
514    ///
515    /// # Returns
516    ///
517    /// a new [`Image`][crate::Image] widget
518    #[doc(alias = "gtk_image_new_from_animation")]
519    #[doc(alias = "new_from_animation")]
520    pub fn from_animation(animation: &impl IsA<gdk_pixbuf::PixbufAnimation>) -> Image {
521        assert_initialized_main_thread!();
522        unsafe {
523            Widget::from_glib_none(ffi::gtk_image_new_from_animation(
524                animation.as_ref().to_glib_none().0,
525            ))
526            .unsafe_cast()
527        }
528    }
529
530    /// Creates a new [`Image`][crate::Image] displaying the file `filename`. If the file
531    /// isn’t found or can’t be loaded, the resulting [`Image`][crate::Image] will
532    /// display a “broken image” icon. This function never returns [`None`],
533    /// it always returns a valid [`Image`][crate::Image] widget.
534    ///
535    /// If the file contains an animation, the image will contain an
536    /// animation.
537    ///
538    /// If you need to detect failures to load the file, use
539    /// [`gdk_pixbuf::Pixbuf::from_file()`][crate::gdk_pixbuf::Pixbuf::from_file()] to load the file yourself, then create
540    /// the [`Image`][crate::Image] from the pixbuf. (Or for animations, use
541    /// [`gdk_pixbuf::PixbufAnimation::from_file()`][crate::gdk_pixbuf::PixbufAnimation::from_file()]).
542    ///
543    /// The storage type ([`ImageExt::storage_type()`][crate::prelude::ImageExt::storage_type()]) of the returned
544    /// image is not defined, it will be whatever is appropriate for
545    /// displaying the file.
546    /// ## `filename`
547    /// a filename
548    ///
549    /// # Returns
550    ///
551    /// a new [`Image`][crate::Image]
552    #[doc(alias = "gtk_image_new_from_file")]
553    #[doc(alias = "new_from_file")]
554    pub fn from_file(filename: impl AsRef<std::path::Path>) -> Image {
555        assert_initialized_main_thread!();
556        unsafe {
557            Widget::from_glib_none(ffi::gtk_image_new_from_file(
558                filename.as_ref().to_glib_none().0,
559            ))
560            .unsafe_cast()
561        }
562    }
563
564    /// Creates a [`Image`][crate::Image] displaying an icon from the current icon theme.
565    /// If the icon name isn’t known, a “broken image” icon will be
566    /// displayed instead. If the current icon theme is changed, the icon
567    /// will be updated appropriately.
568    /// ## `icon`
569    /// an icon
570    /// ## `size`
571    /// a stock icon size ([`IconSize`][crate::IconSize])
572    ///
573    /// # Returns
574    ///
575    /// a new [`Image`][crate::Image] displaying the themed icon
576    #[doc(alias = "gtk_image_new_from_gicon")]
577    #[doc(alias = "new_from_gicon")]
578    pub fn from_gicon(icon: &impl IsA<gio::Icon>, size: IconSize) -> Image {
579        assert_initialized_main_thread!();
580        unsafe {
581            Widget::from_glib_none(ffi::gtk_image_new_from_gicon(
582                icon.as_ref().to_glib_none().0,
583                size.into_glib(),
584            ))
585            .unsafe_cast()
586        }
587    }
588
589    /// Creates a [`Image`][crate::Image] displaying an icon from the current icon theme.
590    /// If the icon name isn’t known, a “broken image” icon will be
591    /// displayed instead. If the current icon theme is changed, the icon
592    /// will be updated appropriately.
593    /// ## `icon_name`
594    /// an icon name or [`None`]
595    /// ## `size`
596    /// a stock icon size ([`IconSize`][crate::IconSize])
597    ///
598    /// # Returns
599    ///
600    /// a new [`Image`][crate::Image] displaying the themed icon
601    #[doc(alias = "gtk_image_new_from_icon_name")]
602    #[doc(alias = "new_from_icon_name")]
603    pub fn from_icon_name(icon_name: Option<&str>, size: IconSize) -> Image {
604        assert_initialized_main_thread!();
605        unsafe {
606            Widget::from_glib_none(ffi::gtk_image_new_from_icon_name(
607                icon_name.to_glib_none().0,
608                size.into_glib(),
609            ))
610            .unsafe_cast()
611        }
612    }
613
614    /// Creates a new [`Image`][crate::Image] displaying `pixbuf`.
615    /// The [`Image`][crate::Image] does not assume a reference to the
616    /// pixbuf; you still need to unref it if you own references.
617    /// [`Image`][crate::Image] will add its own reference rather than adopting yours.
618    ///
619    /// Note that this function just creates an [`Image`][crate::Image] from the pixbuf. The
620    /// [`Image`][crate::Image] created will not react to state changes. Should you want that,
621    /// you should use [`from_icon_name()`][Self::from_icon_name()].
622    /// ## `pixbuf`
623    /// a [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf], or [`None`]
624    ///
625    /// # Returns
626    ///
627    /// a new [`Image`][crate::Image]
628    #[doc(alias = "gtk_image_new_from_pixbuf")]
629    #[doc(alias = "new_from_pixbuf")]
630    pub fn from_pixbuf(pixbuf: Option<&gdk_pixbuf::Pixbuf>) -> Image {
631        assert_initialized_main_thread!();
632        unsafe {
633            Widget::from_glib_none(ffi::gtk_image_new_from_pixbuf(pixbuf.to_glib_none().0))
634                .unsafe_cast()
635        }
636    }
637
638    /// Creates a new [`Image`][crate::Image] displaying the resource file `resource_path`. If the file
639    /// isn’t found or can’t be loaded, the resulting [`Image`][crate::Image] will
640    /// display a “broken image” icon. This function never returns [`None`],
641    /// it always returns a valid [`Image`][crate::Image] widget.
642    ///
643    /// If the file contains an animation, the image will contain an
644    /// animation.
645    ///
646    /// If you need to detect failures to load the file, use
647    /// [`gdk_pixbuf::Pixbuf::from_file()`][crate::gdk_pixbuf::Pixbuf::from_file()] to load the file yourself, then create
648    /// the [`Image`][crate::Image] from the pixbuf. (Or for animations, use
649    /// [`gdk_pixbuf::PixbufAnimation::from_file()`][crate::gdk_pixbuf::PixbufAnimation::from_file()]).
650    ///
651    /// The storage type ([`ImageExt::storage_type()`][crate::prelude::ImageExt::storage_type()]) of the returned
652    /// image is not defined, it will be whatever is appropriate for
653    /// displaying the file.
654    /// ## `resource_path`
655    /// a resource path
656    ///
657    /// # Returns
658    ///
659    /// a new [`Image`][crate::Image]
660    #[doc(alias = "gtk_image_new_from_resource")]
661    #[doc(alias = "new_from_resource")]
662    pub fn from_resource(resource_path: &str) -> Image {
663        assert_initialized_main_thread!();
664        unsafe {
665            Widget::from_glib_none(ffi::gtk_image_new_from_resource(
666                resource_path.to_glib_none().0,
667            ))
668            .unsafe_cast()
669        }
670    }
671
672    /// Creates a new [`Image`][crate::Image] displaying `surface`.
673    /// The [`Image`][crate::Image] does not assume a reference to the
674    /// surface; you still need to unref it if you own references.
675    /// [`Image`][crate::Image] will add its own reference rather than adopting yours.
676    /// ## `surface`
677    /// a [`cairo::Surface`][crate::cairo::Surface], or [`None`]
678    ///
679    /// # Returns
680    ///
681    /// a new [`Image`][crate::Image]
682    #[doc(alias = "gtk_image_new_from_surface")]
683    #[doc(alias = "new_from_surface")]
684    pub fn from_surface(surface: Option<&cairo::Surface>) -> Image {
685        assert_initialized_main_thread!();
686        unsafe {
687            Widget::from_glib_none(ffi::gtk_image_new_from_surface(mut_override(
688                surface.to_glib_none().0,
689            )))
690            .unsafe_cast()
691        }
692    }
693}
694
695impl Default for Image {
696    fn default() -> Self {
697        Self::new()
698    }
699}
700
701mod sealed {
702    pub trait Sealed {}
703    impl<T: super::IsA<super::Image>> Sealed for T {}
704}
705
706/// Trait containing all [`struct@Image`] methods.
707///
708/// # Implementors
709///
710/// [`Image`][struct@crate::Image]
711pub trait ImageExt: IsA<Image> + sealed::Sealed + 'static {
712    /// Resets the image to be empty.
713    #[doc(alias = "gtk_image_clear")]
714    fn clear(&self) {
715        unsafe {
716            ffi::gtk_image_clear(self.as_ref().to_glib_none().0);
717        }
718    }
719
720    /// Gets the [`gdk_pixbuf::PixbufAnimation`][crate::gdk_pixbuf::PixbufAnimation] being displayed by the [`Image`][crate::Image].
721    /// The storage type of the image must be [`ImageType::Empty`][crate::ImageType::Empty] or
722    /// [`ImageType::Animation`][crate::ImageType::Animation] (see [`storage_type()`][Self::storage_type()]).
723    /// The caller of this function does not own a reference to the
724    /// returned animation.
725    ///
726    /// # Returns
727    ///
728    /// the displayed animation, or [`None`] if
729    /// the image is empty
730    #[doc(alias = "gtk_image_get_animation")]
731    #[doc(alias = "get_animation")]
732    fn animation(&self) -> Option<gdk_pixbuf::PixbufAnimation> {
733        unsafe { from_glib_none(ffi::gtk_image_get_animation(self.as_ref().to_glib_none().0)) }
734    }
735
736    /// Gets the [`gio::Icon`][crate::gio::Icon] and size being displayed by the [`Image`][crate::Image].
737    /// The storage type of the image must be [`ImageType::Empty`][crate::ImageType::Empty] or
738    /// [`ImageType::Gicon`][crate::ImageType::Gicon] (see [`storage_type()`][Self::storage_type()]).
739    /// The caller of this function does not own a reference to the
740    /// returned [`gio::Icon`][crate::gio::Icon].
741    ///
742    /// # Returns
743    ///
744    ///
745    /// ## `gicon`
746    /// place to store a
747    ///  [`gio::Icon`][crate::gio::Icon], or [`None`]
748    ///
749    /// ## `size`
750    /// place to store an icon size
751    ///  ([`IconSize`][crate::IconSize]), or [`None`]
752    #[doc(alias = "gtk_image_get_gicon")]
753    #[doc(alias = "get_gicon")]
754    fn gicon(&self) -> (gio::Icon, IconSize) {
755        unsafe {
756            let mut gicon = ptr::null_mut();
757            let mut size = mem::MaybeUninit::uninit();
758            ffi::gtk_image_get_gicon(
759                self.as_ref().to_glib_none().0,
760                &mut gicon,
761                size.as_mut_ptr(),
762            );
763            (from_glib_none(gicon), from_glib(size.assume_init()))
764        }
765    }
766
767    /// Gets the [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf] being displayed by the [`Image`][crate::Image].
768    /// The storage type of the image must be [`ImageType::Empty`][crate::ImageType::Empty] or
769    /// [`ImageType::Pixbuf`][crate::ImageType::Pixbuf] (see [`storage_type()`][Self::storage_type()]).
770    /// The caller of this function does not own a reference to the
771    /// returned pixbuf.
772    ///
773    /// # Returns
774    ///
775    /// the displayed pixbuf, or [`None`] if
776    /// the image is empty
777    #[doc(alias = "gtk_image_get_pixbuf")]
778    #[doc(alias = "get_pixbuf")]
779    fn pixbuf(&self) -> Option<gdk_pixbuf::Pixbuf> {
780        unsafe { from_glib_none(ffi::gtk_image_get_pixbuf(self.as_ref().to_glib_none().0)) }
781    }
782
783    /// Gets the pixel size used for named icons.
784    ///
785    /// # Returns
786    ///
787    /// the pixel size used for named icons.
788    #[doc(alias = "gtk_image_get_pixel_size")]
789    #[doc(alias = "get_pixel_size")]
790    fn pixel_size(&self) -> i32 {
791        unsafe { ffi::gtk_image_get_pixel_size(self.as_ref().to_glib_none().0) }
792    }
793
794    /// Gets the type of representation being used by the [`Image`][crate::Image]
795    /// to store image data. If the [`Image`][crate::Image] has no image data,
796    /// the return value will be [`ImageType::Empty`][crate::ImageType::Empty].
797    ///
798    /// # Returns
799    ///
800    /// image representation being used
801    #[doc(alias = "gtk_image_get_storage_type")]
802    #[doc(alias = "get_storage_type")]
803    fn storage_type(&self) -> ImageType {
804        unsafe {
805            from_glib(ffi::gtk_image_get_storage_type(
806                self.as_ref().to_glib_none().0,
807            ))
808        }
809    }
810
811    /// Causes the [`Image`][crate::Image] to display the given animation (or display
812    /// nothing, if you set the animation to [`None`]).
813    /// ## `animation`
814    /// the [`gdk_pixbuf::PixbufAnimation`][crate::gdk_pixbuf::PixbufAnimation]
815    #[doc(alias = "gtk_image_set_from_animation")]
816    fn set_from_animation(&self, animation: &impl IsA<gdk_pixbuf::PixbufAnimation>) {
817        unsafe {
818            ffi::gtk_image_set_from_animation(
819                self.as_ref().to_glib_none().0,
820                animation.as_ref().to_glib_none().0,
821            );
822        }
823    }
824
825    /// See [`Image::from_file()`][crate::Image::from_file()] for details.
826    /// ## `filename`
827    /// a filename or [`None`]
828    #[doc(alias = "gtk_image_set_from_file")]
829    fn set_from_file(&self, filename: Option<impl AsRef<std::path::Path>>) {
830        unsafe {
831            ffi::gtk_image_set_from_file(
832                self.as_ref().to_glib_none().0,
833                filename.as_ref().map(|p| p.as_ref()).to_glib_none().0,
834            );
835        }
836    }
837
838    /// See [`Image::from_gicon()`][crate::Image::from_gicon()] for details.
839    /// ## `icon`
840    /// an icon
841    /// ## `size`
842    /// an icon size ([`IconSize`][crate::IconSize])
843    #[doc(alias = "gtk_image_set_from_gicon")]
844    fn set_from_gicon(&self, icon: &impl IsA<gio::Icon>, size: IconSize) {
845        unsafe {
846            ffi::gtk_image_set_from_gicon(
847                self.as_ref().to_glib_none().0,
848                icon.as_ref().to_glib_none().0,
849                size.into_glib(),
850            );
851        }
852    }
853
854    /// See [`Image::from_icon_name()`][crate::Image::from_icon_name()] for details.
855    /// ## `icon_name`
856    /// an icon name or [`None`]
857    /// ## `size`
858    /// an icon size ([`IconSize`][crate::IconSize])
859    #[doc(alias = "gtk_image_set_from_icon_name")]
860    fn set_from_icon_name(&self, icon_name: Option<&str>, size: IconSize) {
861        unsafe {
862            ffi::gtk_image_set_from_icon_name(
863                self.as_ref().to_glib_none().0,
864                icon_name.to_glib_none().0,
865                size.into_glib(),
866            );
867        }
868    }
869
870    /// See [`Image::from_pixbuf()`][crate::Image::from_pixbuf()] for details.
871    /// ## `pixbuf`
872    /// a [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf] or [`None`]
873    #[doc(alias = "gtk_image_set_from_pixbuf")]
874    fn set_from_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>) {
875        unsafe {
876            ffi::gtk_image_set_from_pixbuf(self.as_ref().to_glib_none().0, pixbuf.to_glib_none().0);
877        }
878    }
879
880    /// See [`Image::from_resource()`][crate::Image::from_resource()] for details.
881    /// ## `resource_path`
882    /// a resource path or [`None`]
883    #[doc(alias = "gtk_image_set_from_resource")]
884    fn set_from_resource(&self, resource_path: Option<&str>) {
885        unsafe {
886            ffi::gtk_image_set_from_resource(
887                self.as_ref().to_glib_none().0,
888                resource_path.to_glib_none().0,
889            );
890        }
891    }
892
893    /// See [`Image::from_surface()`][crate::Image::from_surface()] for details.
894    /// ## `surface`
895    /// a cairo_surface_t or [`None`]
896    #[doc(alias = "gtk_image_set_from_surface")]
897    fn set_from_surface(&self, surface: Option<&cairo::Surface>) {
898        unsafe {
899            ffi::gtk_image_set_from_surface(
900                self.as_ref().to_glib_none().0,
901                mut_override(surface.to_glib_none().0),
902            );
903        }
904    }
905
906    /// Sets the pixel size to use for named icons. If the pixel size is set
907    /// to a value != -1, it is used instead of the icon size set by
908    /// [`set_from_icon_name()`][Self::set_from_icon_name()].
909    /// ## `pixel_size`
910    /// the new pixel size
911    #[doc(alias = "gtk_image_set_pixel_size")]
912    fn set_pixel_size(&self, pixel_size: i32) {
913        unsafe {
914            ffi::gtk_image_set_pixel_size(self.as_ref().to_glib_none().0, pixel_size);
915        }
916    }
917
918    fn file(&self) -> Option<glib::GString> {
919        ObjectExt::property(self.as_ref(), "file")
920    }
921
922    fn set_file(&self, file: Option<&str>) {
923        ObjectExt::set_property(self.as_ref(), "file", file)
924    }
925
926    /// The GIcon displayed in the GtkImage. For themed icons,
927    /// If the icon theme is changed, the image will be updated
928    /// automatically.
929    fn set_gicon<P: IsA<gio::Icon>>(&self, gicon: Option<&P>) {
930        ObjectExt::set_property(self.as_ref(), "gicon", gicon)
931    }
932
933    /// The name of the icon in the icon theme. If the icon theme is
934    /// changed, the image will be updated automatically.
935    #[doc(alias = "icon-name")]
936    fn icon_name(&self) -> Option<glib::GString> {
937        ObjectExt::property(self.as_ref(), "icon-name")
938    }
939
940    /// The name of the icon in the icon theme. If the icon theme is
941    /// changed, the image will be updated automatically.
942    #[doc(alias = "icon-name")]
943    fn set_icon_name(&self, icon_name: Option<&str>) {
944        ObjectExt::set_property(self.as_ref(), "icon-name", icon_name)
945    }
946
947    fn set_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>) {
948        ObjectExt::set_property(self.as_ref(), "pixbuf", pixbuf)
949    }
950
951    #[doc(alias = "pixbuf-animation")]
952    fn pixbuf_animation(&self) -> Option<gdk_pixbuf::PixbufAnimation> {
953        ObjectExt::property(self.as_ref(), "pixbuf-animation")
954    }
955
956    #[doc(alias = "pixbuf-animation")]
957    fn set_pixbuf_animation<P: IsA<gdk_pixbuf::PixbufAnimation>>(
958        &self,
959        pixbuf_animation: Option<&P>,
960    ) {
961        ObjectExt::set_property(self.as_ref(), "pixbuf-animation", pixbuf_animation)
962    }
963
964    /// A path to a resource file to display.
965    fn resource(&self) -> Option<glib::GString> {
966        ObjectExt::property(self.as_ref(), "resource")
967    }
968
969    /// A path to a resource file to display.
970    fn set_resource(&self, resource: Option<&str>) {
971        ObjectExt::set_property(self.as_ref(), "resource", resource)
972    }
973
974    fn surface(&self) -> Option<cairo::Surface> {
975        ObjectExt::property(self.as_ref(), "surface")
976    }
977
978    fn set_surface(&self, surface: Option<&cairo::Surface>) {
979        ObjectExt::set_property(self.as_ref(), "surface", surface)
980    }
981
982    /// Whether the icon displayed in the GtkImage will use
983    /// standard icon names fallback. The value of this property
984    /// is only relevant for images of type [`ImageType::IconName`][crate::ImageType::IconName]
985    /// and [`ImageType::Gicon`][crate::ImageType::Gicon].
986    #[doc(alias = "use-fallback")]
987    fn uses_fallback(&self) -> bool {
988        ObjectExt::property(self.as_ref(), "use-fallback")
989    }
990
991    /// Whether the icon displayed in the GtkImage will use
992    /// standard icon names fallback. The value of this property
993    /// is only relevant for images of type [`ImageType::IconName`][crate::ImageType::IconName]
994    /// and [`ImageType::Gicon`][crate::ImageType::Gicon].
995    #[doc(alias = "use-fallback")]
996    fn set_use_fallback(&self, use_fallback: bool) {
997        ObjectExt::set_property(self.as_ref(), "use-fallback", use_fallback)
998    }
999
1000    #[doc(alias = "file")]
1001    fn connect_file_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1002        unsafe extern "C" fn notify_file_trampoline<P: IsA<Image>, F: Fn(&P) + 'static>(
1003            this: *mut ffi::GtkImage,
1004            _param_spec: glib::ffi::gpointer,
1005            f: glib::ffi::gpointer,
1006        ) {
1007            let f: &F = &*(f as *const F);
1008            f(Image::from_glib_borrow(this).unsafe_cast_ref())
1009        }
1010        unsafe {
1011            let f: Box_<F> = Box_::new(f);
1012            connect_raw(
1013                self.as_ptr() as *mut _,
1014                b"notify::file\0".as_ptr() as *const _,
1015                Some(transmute::<_, unsafe extern "C" fn()>(
1016                    notify_file_trampoline::<Self, F> as *const (),
1017                )),
1018                Box_::into_raw(f),
1019            )
1020        }
1021    }
1022
1023    #[doc(alias = "gicon")]
1024    fn connect_gicon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1025        unsafe extern "C" fn notify_gicon_trampoline<P: IsA<Image>, F: Fn(&P) + 'static>(
1026            this: *mut ffi::GtkImage,
1027            _param_spec: glib::ffi::gpointer,
1028            f: glib::ffi::gpointer,
1029        ) {
1030            let f: &F = &*(f as *const F);
1031            f(Image::from_glib_borrow(this).unsafe_cast_ref())
1032        }
1033        unsafe {
1034            let f: Box_<F> = Box_::new(f);
1035            connect_raw(
1036                self.as_ptr() as *mut _,
1037                b"notify::gicon\0".as_ptr() as *const _,
1038                Some(transmute::<_, unsafe extern "C" fn()>(
1039                    notify_gicon_trampoline::<Self, F> as *const (),
1040                )),
1041                Box_::into_raw(f),
1042            )
1043        }
1044    }
1045
1046    #[doc(alias = "icon-name")]
1047    fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1048        unsafe extern "C" fn notify_icon_name_trampoline<P: IsA<Image>, F: Fn(&P) + 'static>(
1049            this: *mut ffi::GtkImage,
1050            _param_spec: glib::ffi::gpointer,
1051            f: glib::ffi::gpointer,
1052        ) {
1053            let f: &F = &*(f as *const F);
1054            f(Image::from_glib_borrow(this).unsafe_cast_ref())
1055        }
1056        unsafe {
1057            let f: Box_<F> = Box_::new(f);
1058            connect_raw(
1059                self.as_ptr() as *mut _,
1060                b"notify::icon-name\0".as_ptr() as *const _,
1061                Some(transmute::<_, unsafe extern "C" fn()>(
1062                    notify_icon_name_trampoline::<Self, F> as *const (),
1063                )),
1064                Box_::into_raw(f),
1065            )
1066        }
1067    }
1068
1069    #[doc(alias = "pixbuf")]
1070    fn connect_pixbuf_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1071        unsafe extern "C" fn notify_pixbuf_trampoline<P: IsA<Image>, F: Fn(&P) + 'static>(
1072            this: *mut ffi::GtkImage,
1073            _param_spec: glib::ffi::gpointer,
1074            f: glib::ffi::gpointer,
1075        ) {
1076            let f: &F = &*(f as *const F);
1077            f(Image::from_glib_borrow(this).unsafe_cast_ref())
1078        }
1079        unsafe {
1080            let f: Box_<F> = Box_::new(f);
1081            connect_raw(
1082                self.as_ptr() as *mut _,
1083                b"notify::pixbuf\0".as_ptr() as *const _,
1084                Some(transmute::<_, unsafe extern "C" fn()>(
1085                    notify_pixbuf_trampoline::<Self, F> as *const (),
1086                )),
1087                Box_::into_raw(f),
1088            )
1089        }
1090    }
1091
1092    #[doc(alias = "pixbuf-animation")]
1093    fn connect_pixbuf_animation_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1094        unsafe extern "C" fn notify_pixbuf_animation_trampoline<
1095            P: IsA<Image>,
1096            F: Fn(&P) + 'static,
1097        >(
1098            this: *mut ffi::GtkImage,
1099            _param_spec: glib::ffi::gpointer,
1100            f: glib::ffi::gpointer,
1101        ) {
1102            let f: &F = &*(f as *const F);
1103            f(Image::from_glib_borrow(this).unsafe_cast_ref())
1104        }
1105        unsafe {
1106            let f: Box_<F> = Box_::new(f);
1107            connect_raw(
1108                self.as_ptr() as *mut _,
1109                b"notify::pixbuf-animation\0".as_ptr() as *const _,
1110                Some(transmute::<_, unsafe extern "C" fn()>(
1111                    notify_pixbuf_animation_trampoline::<Self, F> as *const (),
1112                )),
1113                Box_::into_raw(f),
1114            )
1115        }
1116    }
1117
1118    #[doc(alias = "pixel-size")]
1119    fn connect_pixel_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1120        unsafe extern "C" fn notify_pixel_size_trampoline<P: IsA<Image>, F: Fn(&P) + 'static>(
1121            this: *mut ffi::GtkImage,
1122            _param_spec: glib::ffi::gpointer,
1123            f: glib::ffi::gpointer,
1124        ) {
1125            let f: &F = &*(f as *const F);
1126            f(Image::from_glib_borrow(this).unsafe_cast_ref())
1127        }
1128        unsafe {
1129            let f: Box_<F> = Box_::new(f);
1130            connect_raw(
1131                self.as_ptr() as *mut _,
1132                b"notify::pixel-size\0".as_ptr() as *const _,
1133                Some(transmute::<_, unsafe extern "C" fn()>(
1134                    notify_pixel_size_trampoline::<Self, F> as *const (),
1135                )),
1136                Box_::into_raw(f),
1137            )
1138        }
1139    }
1140
1141    #[doc(alias = "resource")]
1142    fn connect_resource_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1143        unsafe extern "C" fn notify_resource_trampoline<P: IsA<Image>, F: Fn(&P) + 'static>(
1144            this: *mut ffi::GtkImage,
1145            _param_spec: glib::ffi::gpointer,
1146            f: glib::ffi::gpointer,
1147        ) {
1148            let f: &F = &*(f as *const F);
1149            f(Image::from_glib_borrow(this).unsafe_cast_ref())
1150        }
1151        unsafe {
1152            let f: Box_<F> = Box_::new(f);
1153            connect_raw(
1154                self.as_ptr() as *mut _,
1155                b"notify::resource\0".as_ptr() as *const _,
1156                Some(transmute::<_, unsafe extern "C" fn()>(
1157                    notify_resource_trampoline::<Self, F> as *const (),
1158                )),
1159                Box_::into_raw(f),
1160            )
1161        }
1162    }
1163
1164    #[doc(alias = "storage-type")]
1165    fn connect_storage_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1166        unsafe extern "C" fn notify_storage_type_trampoline<P: IsA<Image>, F: Fn(&P) + 'static>(
1167            this: *mut ffi::GtkImage,
1168            _param_spec: glib::ffi::gpointer,
1169            f: glib::ffi::gpointer,
1170        ) {
1171            let f: &F = &*(f as *const F);
1172            f(Image::from_glib_borrow(this).unsafe_cast_ref())
1173        }
1174        unsafe {
1175            let f: Box_<F> = Box_::new(f);
1176            connect_raw(
1177                self.as_ptr() as *mut _,
1178                b"notify::storage-type\0".as_ptr() as *const _,
1179                Some(transmute::<_, unsafe extern "C" fn()>(
1180                    notify_storage_type_trampoline::<Self, F> as *const (),
1181                )),
1182                Box_::into_raw(f),
1183            )
1184        }
1185    }
1186
1187    #[doc(alias = "surface")]
1188    fn connect_surface_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1189        unsafe extern "C" fn notify_surface_trampoline<P: IsA<Image>, F: Fn(&P) + 'static>(
1190            this: *mut ffi::GtkImage,
1191            _param_spec: glib::ffi::gpointer,
1192            f: glib::ffi::gpointer,
1193        ) {
1194            let f: &F = &*(f as *const F);
1195            f(Image::from_glib_borrow(this).unsafe_cast_ref())
1196        }
1197        unsafe {
1198            let f: Box_<F> = Box_::new(f);
1199            connect_raw(
1200                self.as_ptr() as *mut _,
1201                b"notify::surface\0".as_ptr() as *const _,
1202                Some(transmute::<_, unsafe extern "C" fn()>(
1203                    notify_surface_trampoline::<Self, F> as *const (),
1204                )),
1205                Box_::into_raw(f),
1206            )
1207        }
1208    }
1209
1210    #[doc(alias = "use-fallback")]
1211    fn connect_use_fallback_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1212        unsafe extern "C" fn notify_use_fallback_trampoline<P: IsA<Image>, F: Fn(&P) + 'static>(
1213            this: *mut ffi::GtkImage,
1214            _param_spec: glib::ffi::gpointer,
1215            f: glib::ffi::gpointer,
1216        ) {
1217            let f: &F = &*(f as *const F);
1218            f(Image::from_glib_borrow(this).unsafe_cast_ref())
1219        }
1220        unsafe {
1221            let f: Box_<F> = Box_::new(f);
1222            connect_raw(
1223                self.as_ptr() as *mut _,
1224                b"notify::use-fallback\0".as_ptr() as *const _,
1225                Some(transmute::<_, unsafe extern "C" fn()>(
1226                    notify_use_fallback_trampoline::<Self, F> as *const (),
1227                )),
1228                Box_::into_raw(f),
1229            )
1230        }
1231    }
1232}
1233
1234impl<O: IsA<Image>> ImageExt for O {}
1235
1236impl fmt::Display for Image {
1237    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1238        f.write_str("Image")
1239    }
1240}