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 cairo;
6use gdk;
7use gdk_pixbuf;
8use gio;
9use glib::object::Cast;
10use glib::object::IsA;
11use glib::signal::connect_raw;
12use glib::signal::SignalHandlerId;
13use glib::translate::*;
14use glib::GString;
15use glib::StaticType;
16use glib::ToValue;
17use glib::Value;
18use glib_sys;
19use gobject_sys;
20use gtk_sys;
21use std;
22use std::boxed::Box as Box_;
23use std::fmt;
24use std::mem;
25use std::mem::transmute;
26use std::ptr;
27use Align;
28use Buildable;
29use Container;
30use IconSize;
31use ImageType;
32use Misc;
33use Widget;
34
35glib_wrapper! {
36    pub struct Image(Object<gtk_sys::GtkImage, gtk_sys::GtkImageClass, ImageClass>) @extends Misc, Widget, @implements Buildable;
37
38    match fn {
39        get_type => || gtk_sys::gtk_image_get_type(),
40    }
41}
42
43impl Image {
44    pub fn new() -> Image {
45        assert_initialized_main_thread!();
46        unsafe { Widget::from_glib_none(gtk_sys::gtk_image_new()).unsafe_cast() }
47    }
48
49    pub fn new_from_animation<P: IsA<gdk_pixbuf::PixbufAnimation>>(animation: &P) -> Image {
50        assert_initialized_main_thread!();
51        unsafe {
52            Widget::from_glib_none(gtk_sys::gtk_image_new_from_animation(
53                animation.as_ref().to_glib_none().0,
54            ))
55            .unsafe_cast()
56        }
57    }
58
59    pub fn new_from_file<P: AsRef<std::path::Path>>(filename: P) -> Image {
60        assert_initialized_main_thread!();
61        unsafe {
62            Widget::from_glib_none(gtk_sys::gtk_image_new_from_file(
63                filename.as_ref().to_glib_none().0,
64            ))
65            .unsafe_cast()
66        }
67    }
68
69    pub fn new_from_gicon<P: IsA<gio::Icon>>(icon: &P, size: IconSize) -> Image {
70        assert_initialized_main_thread!();
71        unsafe {
72            Widget::from_glib_none(gtk_sys::gtk_image_new_from_gicon(
73                icon.as_ref().to_glib_none().0,
74                size.to_glib(),
75            ))
76            .unsafe_cast()
77        }
78    }
79
80    pub fn new_from_icon_name(icon_name: Option<&str>, size: IconSize) -> Image {
81        assert_initialized_main_thread!();
82        unsafe {
83            Widget::from_glib_none(gtk_sys::gtk_image_new_from_icon_name(
84                icon_name.to_glib_none().0,
85                size.to_glib(),
86            ))
87            .unsafe_cast()
88        }
89    }
90
91    pub fn new_from_pixbuf(pixbuf: Option<&gdk_pixbuf::Pixbuf>) -> Image {
92        assert_initialized_main_thread!();
93        unsafe {
94            Widget::from_glib_none(gtk_sys::gtk_image_new_from_pixbuf(pixbuf.to_glib_none().0))
95                .unsafe_cast()
96        }
97    }
98
99    pub fn new_from_resource(resource_path: &str) -> Image {
100        assert_initialized_main_thread!();
101        unsafe {
102            Widget::from_glib_none(gtk_sys::gtk_image_new_from_resource(
103                resource_path.to_glib_none().0,
104            ))
105            .unsafe_cast()
106        }
107    }
108
109    pub fn new_from_surface(surface: Option<&cairo::Surface>) -> Image {
110        assert_initialized_main_thread!();
111        unsafe {
112            Widget::from_glib_none(gtk_sys::gtk_image_new_from_surface(mut_override(
113                surface.to_glib_none().0,
114            )))
115            .unsafe_cast()
116        }
117    }
118}
119
120impl Default for Image {
121    fn default() -> Self {
122        Self::new()
123    }
124}
125
126pub struct ImageBuilder {
127    file: Option<String>,
128    gicon: Option<gio::Icon>,
129    icon_name: Option<String>,
130    icon_size: Option<i32>,
131    pixbuf: Option<gdk_pixbuf::Pixbuf>,
132    pixbuf_animation: Option<gdk_pixbuf::PixbufAnimation>,
133    pixel_size: Option<i32>,
134    resource: Option<String>,
135    use_fallback: Option<bool>,
136    app_paintable: Option<bool>,
137    can_default: Option<bool>,
138    can_focus: Option<bool>,
139    events: Option<gdk::EventMask>,
140    expand: Option<bool>,
141    #[cfg(any(feature = "v3_20", feature = "dox"))]
142    focus_on_click: Option<bool>,
143    halign: Option<Align>,
144    has_default: Option<bool>,
145    has_focus: Option<bool>,
146    has_tooltip: Option<bool>,
147    height_request: Option<i32>,
148    hexpand: Option<bool>,
149    hexpand_set: Option<bool>,
150    is_focus: Option<bool>,
151    margin: Option<i32>,
152    margin_bottom: Option<i32>,
153    margin_end: Option<i32>,
154    margin_start: Option<i32>,
155    margin_top: Option<i32>,
156    name: Option<String>,
157    no_show_all: Option<bool>,
158    opacity: Option<f64>,
159    parent: Option<Container>,
160    receives_default: Option<bool>,
161    sensitive: Option<bool>,
162    //style: /*Unknown type*/,
163    tooltip_markup: Option<String>,
164    tooltip_text: Option<String>,
165    valign: Option<Align>,
166    vexpand: Option<bool>,
167    vexpand_set: Option<bool>,
168    visible: Option<bool>,
169    width_request: Option<i32>,
170}
171
172impl ImageBuilder {
173    pub fn new() -> Self {
174        Self {
175            file: None,
176            gicon: None,
177            icon_name: None,
178            icon_size: None,
179            pixbuf: None,
180            pixbuf_animation: None,
181            pixel_size: None,
182            resource: None,
183            use_fallback: None,
184            app_paintable: None,
185            can_default: None,
186            can_focus: None,
187            events: None,
188            expand: None,
189            #[cfg(any(feature = "v3_20", feature = "dox"))]
190            focus_on_click: None,
191            halign: None,
192            has_default: None,
193            has_focus: None,
194            has_tooltip: None,
195            height_request: None,
196            hexpand: None,
197            hexpand_set: None,
198            is_focus: None,
199            margin: None,
200            margin_bottom: None,
201            margin_end: None,
202            margin_start: None,
203            margin_top: None,
204            name: None,
205            no_show_all: None,
206            opacity: None,
207            parent: None,
208            receives_default: None,
209            sensitive: None,
210            tooltip_markup: None,
211            tooltip_text: None,
212            valign: None,
213            vexpand: None,
214            vexpand_set: None,
215            visible: None,
216            width_request: None,
217        }
218    }
219
220    pub fn build(self) -> Image {
221        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
222        if let Some(ref file) = self.file {
223            properties.push(("file", file));
224        }
225        if let Some(ref gicon) = self.gicon {
226            properties.push(("gicon", gicon));
227        }
228        if let Some(ref icon_name) = self.icon_name {
229            properties.push(("icon-name", icon_name));
230        }
231        if let Some(ref icon_size) = self.icon_size {
232            properties.push(("icon-size", icon_size));
233        }
234        if let Some(ref pixbuf) = self.pixbuf {
235            properties.push(("pixbuf", pixbuf));
236        }
237        if let Some(ref pixbuf_animation) = self.pixbuf_animation {
238            properties.push(("pixbuf-animation", pixbuf_animation));
239        }
240        if let Some(ref pixel_size) = self.pixel_size {
241            properties.push(("pixel-size", pixel_size));
242        }
243        if let Some(ref resource) = self.resource {
244            properties.push(("resource", resource));
245        }
246        if let Some(ref use_fallback) = self.use_fallback {
247            properties.push(("use-fallback", use_fallback));
248        }
249        if let Some(ref app_paintable) = self.app_paintable {
250            properties.push(("app-paintable", app_paintable));
251        }
252        if let Some(ref can_default) = self.can_default {
253            properties.push(("can-default", can_default));
254        }
255        if let Some(ref can_focus) = self.can_focus {
256            properties.push(("can-focus", can_focus));
257        }
258        if let Some(ref events) = self.events {
259            properties.push(("events", events));
260        }
261        if let Some(ref expand) = self.expand {
262            properties.push(("expand", expand));
263        }
264        #[cfg(any(feature = "v3_20", feature = "dox"))]
265        {
266            if let Some(ref focus_on_click) = self.focus_on_click {
267                properties.push(("focus-on-click", focus_on_click));
268            }
269        }
270        if let Some(ref halign) = self.halign {
271            properties.push(("halign", halign));
272        }
273        if let Some(ref has_default) = self.has_default {
274            properties.push(("has-default", has_default));
275        }
276        if let Some(ref has_focus) = self.has_focus {
277            properties.push(("has-focus", has_focus));
278        }
279        if let Some(ref has_tooltip) = self.has_tooltip {
280            properties.push(("has-tooltip", has_tooltip));
281        }
282        if let Some(ref height_request) = self.height_request {
283            properties.push(("height-request", height_request));
284        }
285        if let Some(ref hexpand) = self.hexpand {
286            properties.push(("hexpand", hexpand));
287        }
288        if let Some(ref hexpand_set) = self.hexpand_set {
289            properties.push(("hexpand-set", hexpand_set));
290        }
291        if let Some(ref is_focus) = self.is_focus {
292            properties.push(("is-focus", is_focus));
293        }
294        if let Some(ref margin) = self.margin {
295            properties.push(("margin", margin));
296        }
297        if let Some(ref margin_bottom) = self.margin_bottom {
298            properties.push(("margin-bottom", margin_bottom));
299        }
300        if let Some(ref margin_end) = self.margin_end {
301            properties.push(("margin-end", margin_end));
302        }
303        if let Some(ref margin_start) = self.margin_start {
304            properties.push(("margin-start", margin_start));
305        }
306        if let Some(ref margin_top) = self.margin_top {
307            properties.push(("margin-top", margin_top));
308        }
309        if let Some(ref name) = self.name {
310            properties.push(("name", name));
311        }
312        if let Some(ref no_show_all) = self.no_show_all {
313            properties.push(("no-show-all", no_show_all));
314        }
315        if let Some(ref opacity) = self.opacity {
316            properties.push(("opacity", opacity));
317        }
318        if let Some(ref parent) = self.parent {
319            properties.push(("parent", parent));
320        }
321        if let Some(ref receives_default) = self.receives_default {
322            properties.push(("receives-default", receives_default));
323        }
324        if let Some(ref sensitive) = self.sensitive {
325            properties.push(("sensitive", sensitive));
326        }
327        if let Some(ref tooltip_markup) = self.tooltip_markup {
328            properties.push(("tooltip-markup", tooltip_markup));
329        }
330        if let Some(ref tooltip_text) = self.tooltip_text {
331            properties.push(("tooltip-text", tooltip_text));
332        }
333        if let Some(ref valign) = self.valign {
334            properties.push(("valign", valign));
335        }
336        if let Some(ref vexpand) = self.vexpand {
337            properties.push(("vexpand", vexpand));
338        }
339        if let Some(ref vexpand_set) = self.vexpand_set {
340            properties.push(("vexpand-set", vexpand_set));
341        }
342        if let Some(ref visible) = self.visible {
343            properties.push(("visible", visible));
344        }
345        if let Some(ref width_request) = self.width_request {
346            properties.push(("width-request", width_request));
347        }
348        glib::Object::new(Image::static_type(), &properties)
349            .expect("object new")
350            .downcast()
351            .expect("downcast")
352    }
353
354    pub fn file(mut self, file: &str) -> Self {
355        self.file = Some(file.to_string());
356        self
357    }
358
359    pub fn gicon(mut self, gicon: &gio::Icon) -> Self {
360        self.gicon = Some(gicon.clone());
361        self
362    }
363
364    pub fn icon_name(mut self, icon_name: &str) -> Self {
365        self.icon_name = Some(icon_name.to_string());
366        self
367    }
368
369    pub fn icon_size(mut self, icon_size: i32) -> Self {
370        self.icon_size = Some(icon_size);
371        self
372    }
373
374    pub fn pixbuf(mut self, pixbuf: &gdk_pixbuf::Pixbuf) -> Self {
375        self.pixbuf = Some(pixbuf.clone());
376        self
377    }
378
379    pub fn pixbuf_animation(mut self, pixbuf_animation: &gdk_pixbuf::PixbufAnimation) -> Self {
380        self.pixbuf_animation = Some(pixbuf_animation.clone());
381        self
382    }
383
384    pub fn pixel_size(mut self, pixel_size: i32) -> Self {
385        self.pixel_size = Some(pixel_size);
386        self
387    }
388
389    pub fn resource(mut self, resource: &str) -> Self {
390        self.resource = Some(resource.to_string());
391        self
392    }
393
394    pub fn use_fallback(mut self, use_fallback: bool) -> Self {
395        self.use_fallback = Some(use_fallback);
396        self
397    }
398
399    pub fn app_paintable(mut self, app_paintable: bool) -> Self {
400        self.app_paintable = Some(app_paintable);
401        self
402    }
403
404    pub fn can_default(mut self, can_default: bool) -> Self {
405        self.can_default = Some(can_default);
406        self
407    }
408
409    pub fn can_focus(mut self, can_focus: bool) -> Self {
410        self.can_focus = Some(can_focus);
411        self
412    }
413
414    pub fn events(mut self, events: gdk::EventMask) -> Self {
415        self.events = Some(events);
416        self
417    }
418
419    pub fn expand(mut self, expand: bool) -> Self {
420        self.expand = Some(expand);
421        self
422    }
423
424    #[cfg(any(feature = "v3_20", feature = "dox"))]
425    pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
426        self.focus_on_click = Some(focus_on_click);
427        self
428    }
429
430    pub fn halign(mut self, halign: Align) -> Self {
431        self.halign = Some(halign);
432        self
433    }
434
435    pub fn has_default(mut self, has_default: bool) -> Self {
436        self.has_default = Some(has_default);
437        self
438    }
439
440    pub fn has_focus(mut self, has_focus: bool) -> Self {
441        self.has_focus = Some(has_focus);
442        self
443    }
444
445    pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
446        self.has_tooltip = Some(has_tooltip);
447        self
448    }
449
450    pub fn height_request(mut self, height_request: i32) -> Self {
451        self.height_request = Some(height_request);
452        self
453    }
454
455    pub fn hexpand(mut self, hexpand: bool) -> Self {
456        self.hexpand = Some(hexpand);
457        self
458    }
459
460    pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
461        self.hexpand_set = Some(hexpand_set);
462        self
463    }
464
465    pub fn is_focus(mut self, is_focus: bool) -> Self {
466        self.is_focus = Some(is_focus);
467        self
468    }
469
470    pub fn margin(mut self, margin: i32) -> Self {
471        self.margin = Some(margin);
472        self
473    }
474
475    pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
476        self.margin_bottom = Some(margin_bottom);
477        self
478    }
479
480    pub fn margin_end(mut self, margin_end: i32) -> Self {
481        self.margin_end = Some(margin_end);
482        self
483    }
484
485    pub fn margin_start(mut self, margin_start: i32) -> Self {
486        self.margin_start = Some(margin_start);
487        self
488    }
489
490    pub fn margin_top(mut self, margin_top: i32) -> Self {
491        self.margin_top = Some(margin_top);
492        self
493    }
494
495    pub fn name(mut self, name: &str) -> Self {
496        self.name = Some(name.to_string());
497        self
498    }
499
500    pub fn no_show_all(mut self, no_show_all: bool) -> Self {
501        self.no_show_all = Some(no_show_all);
502        self
503    }
504
505    pub fn opacity(mut self, opacity: f64) -> Self {
506        self.opacity = Some(opacity);
507        self
508    }
509
510    pub fn parent(mut self, parent: &Container) -> Self {
511        self.parent = Some(parent.clone());
512        self
513    }
514
515    pub fn receives_default(mut self, receives_default: bool) -> Self {
516        self.receives_default = Some(receives_default);
517        self
518    }
519
520    pub fn sensitive(mut self, sensitive: bool) -> Self {
521        self.sensitive = Some(sensitive);
522        self
523    }
524
525    pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
526        self.tooltip_markup = Some(tooltip_markup.to_string());
527        self
528    }
529
530    pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
531        self.tooltip_text = Some(tooltip_text.to_string());
532        self
533    }
534
535    pub fn valign(mut self, valign: Align) -> Self {
536        self.valign = Some(valign);
537        self
538    }
539
540    pub fn vexpand(mut self, vexpand: bool) -> Self {
541        self.vexpand = Some(vexpand);
542        self
543    }
544
545    pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
546        self.vexpand_set = Some(vexpand_set);
547        self
548    }
549
550    pub fn visible(mut self, visible: bool) -> Self {
551        self.visible = Some(visible);
552        self
553    }
554
555    pub fn width_request(mut self, width_request: i32) -> Self {
556        self.width_request = Some(width_request);
557        self
558    }
559}
560
561pub const NONE_IMAGE: Option<&Image> = None;
562
563pub trait ImageExt: 'static {
564    fn clear(&self);
565
566    fn get_animation(&self) -> Option<gdk_pixbuf::PixbufAnimation>;
567
568    fn get_gicon(&self) -> (gio::Icon, IconSize);
569
570    fn get_pixbuf(&self) -> Option<gdk_pixbuf::Pixbuf>;
571
572    fn get_pixel_size(&self) -> i32;
573
574    fn get_storage_type(&self) -> ImageType;
575
576    fn set_from_animation<P: IsA<gdk_pixbuf::PixbufAnimation>>(&self, animation: &P);
577
578    fn set_from_file<P: AsRef<std::path::Path>>(&self, filename: P);
579
580    fn set_from_gicon<P: IsA<gio::Icon>>(&self, icon: &P, size: IconSize);
581
582    fn set_from_icon_name(&self, icon_name: Option<&str>, size: IconSize);
583
584    fn set_from_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>);
585
586    fn set_from_resource(&self, resource_path: Option<&str>);
587
588    fn set_from_surface(&self, surface: Option<&cairo::Surface>);
589
590    fn set_pixel_size(&self, pixel_size: i32);
591
592    fn get_property_file(&self) -> Option<GString>;
593
594    fn set_property_file(&self, file: Option<&str>);
595
596    fn set_property_gicon(&self, gicon: Option<&gio::Icon>);
597
598    fn get_property_icon_name(&self) -> Option<GString>;
599
600    fn set_property_icon_name(&self, icon_name: Option<&str>);
601
602    fn get_property_icon_size(&self) -> i32;
603
604    fn set_property_icon_size(&self, icon_size: i32);
605
606    fn set_property_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>);
607
608    fn get_property_pixbuf_animation(&self) -> Option<gdk_pixbuf::PixbufAnimation>;
609
610    fn set_property_pixbuf_animation(&self, pixbuf_animation: Option<&gdk_pixbuf::PixbufAnimation>);
611
612    fn get_property_resource(&self) -> Option<GString>;
613
614    fn set_property_resource(&self, resource: Option<&str>);
615
616    fn get_property_use_fallback(&self) -> bool;
617
618    fn set_property_use_fallback(&self, use_fallback: bool);
619
620    fn connect_property_file_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
621
622    fn connect_property_gicon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
623
624    fn connect_property_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
625
626    fn connect_property_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
627
628    fn connect_property_pixbuf_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
629
630    fn connect_property_pixbuf_animation_notify<F: Fn(&Self) + 'static>(
631        &self,
632        f: F,
633    ) -> SignalHandlerId;
634
635    fn connect_property_pixel_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
636
637    fn connect_property_resource_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
638
639    fn connect_property_storage_type_notify<F: Fn(&Self) + 'static>(&self, f: F)
640        -> SignalHandlerId;
641
642    fn connect_property_use_fallback_notify<F: Fn(&Self) + 'static>(&self, f: F)
643        -> SignalHandlerId;
644}
645
646impl<O: IsA<Image>> ImageExt for O {
647    fn clear(&self) {
648        unsafe {
649            gtk_sys::gtk_image_clear(self.as_ref().to_glib_none().0);
650        }
651    }
652
653    fn get_animation(&self) -> Option<gdk_pixbuf::PixbufAnimation> {
654        unsafe {
655            from_glib_none(gtk_sys::gtk_image_get_animation(
656                self.as_ref().to_glib_none().0,
657            ))
658        }
659    }
660
661    fn get_gicon(&self) -> (gio::Icon, IconSize) {
662        unsafe {
663            let mut gicon = ptr::null_mut();
664            let mut size = mem::uninitialized();
665            gtk_sys::gtk_image_get_gicon(self.as_ref().to_glib_none().0, &mut gicon, &mut size);
666            (from_glib_none(gicon), from_glib(size))
667        }
668    }
669
670    fn get_pixbuf(&self) -> Option<gdk_pixbuf::Pixbuf> {
671        unsafe {
672            from_glib_none(gtk_sys::gtk_image_get_pixbuf(
673                self.as_ref().to_glib_none().0,
674            ))
675        }
676    }
677
678    fn get_pixel_size(&self) -> i32 {
679        unsafe { gtk_sys::gtk_image_get_pixel_size(self.as_ref().to_glib_none().0) }
680    }
681
682    fn get_storage_type(&self) -> ImageType {
683        unsafe {
684            from_glib(gtk_sys::gtk_image_get_storage_type(
685                self.as_ref().to_glib_none().0,
686            ))
687        }
688    }
689
690    fn set_from_animation<P: IsA<gdk_pixbuf::PixbufAnimation>>(&self, animation: &P) {
691        unsafe {
692            gtk_sys::gtk_image_set_from_animation(
693                self.as_ref().to_glib_none().0,
694                animation.as_ref().to_glib_none().0,
695            );
696        }
697    }
698
699    fn set_from_file<P: AsRef<std::path::Path>>(&self, filename: P) {
700        unsafe {
701            gtk_sys::gtk_image_set_from_file(
702                self.as_ref().to_glib_none().0,
703                filename.as_ref().to_glib_none().0,
704            );
705        }
706    }
707
708    fn set_from_gicon<P: IsA<gio::Icon>>(&self, icon: &P, size: IconSize) {
709        unsafe {
710            gtk_sys::gtk_image_set_from_gicon(
711                self.as_ref().to_glib_none().0,
712                icon.as_ref().to_glib_none().0,
713                size.to_glib(),
714            );
715        }
716    }
717
718    fn set_from_icon_name(&self, icon_name: Option<&str>, size: IconSize) {
719        unsafe {
720            gtk_sys::gtk_image_set_from_icon_name(
721                self.as_ref().to_glib_none().0,
722                icon_name.to_glib_none().0,
723                size.to_glib(),
724            );
725        }
726    }
727
728    fn set_from_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>) {
729        unsafe {
730            gtk_sys::gtk_image_set_from_pixbuf(
731                self.as_ref().to_glib_none().0,
732                pixbuf.to_glib_none().0,
733            );
734        }
735    }
736
737    fn set_from_resource(&self, resource_path: Option<&str>) {
738        unsafe {
739            gtk_sys::gtk_image_set_from_resource(
740                self.as_ref().to_glib_none().0,
741                resource_path.to_glib_none().0,
742            );
743        }
744    }
745
746    fn set_from_surface(&self, surface: Option<&cairo::Surface>) {
747        unsafe {
748            gtk_sys::gtk_image_set_from_surface(
749                self.as_ref().to_glib_none().0,
750                mut_override(surface.to_glib_none().0),
751            );
752        }
753    }
754
755    fn set_pixel_size(&self, pixel_size: i32) {
756        unsafe {
757            gtk_sys::gtk_image_set_pixel_size(self.as_ref().to_glib_none().0, pixel_size);
758        }
759    }
760
761    fn get_property_file(&self) -> Option<GString> {
762        unsafe {
763            let mut value = Value::from_type(<GString as StaticType>::static_type());
764            gobject_sys::g_object_get_property(
765                self.to_glib_none().0 as *mut gobject_sys::GObject,
766                b"file\0".as_ptr() as *const _,
767                value.to_glib_none_mut().0,
768            );
769            value.get()
770        }
771    }
772
773    fn set_property_file(&self, file: Option<&str>) {
774        unsafe {
775            gobject_sys::g_object_set_property(
776                self.to_glib_none().0 as *mut gobject_sys::GObject,
777                b"file\0".as_ptr() as *const _,
778                Value::from(file).to_glib_none().0,
779            );
780        }
781    }
782
783    fn set_property_gicon(&self, gicon: Option<&gio::Icon>) {
784        unsafe {
785            gobject_sys::g_object_set_property(
786                self.to_glib_none().0 as *mut gobject_sys::GObject,
787                b"gicon\0".as_ptr() as *const _,
788                Value::from(gicon).to_glib_none().0,
789            );
790        }
791    }
792
793    fn get_property_icon_name(&self) -> Option<GString> {
794        unsafe {
795            let mut value = Value::from_type(<GString as StaticType>::static_type());
796            gobject_sys::g_object_get_property(
797                self.to_glib_none().0 as *mut gobject_sys::GObject,
798                b"icon-name\0".as_ptr() as *const _,
799                value.to_glib_none_mut().0,
800            );
801            value.get()
802        }
803    }
804
805    fn set_property_icon_name(&self, icon_name: Option<&str>) {
806        unsafe {
807            gobject_sys::g_object_set_property(
808                self.to_glib_none().0 as *mut gobject_sys::GObject,
809                b"icon-name\0".as_ptr() as *const _,
810                Value::from(icon_name).to_glib_none().0,
811            );
812        }
813    }
814
815    fn get_property_icon_size(&self) -> i32 {
816        unsafe {
817            let mut value = Value::from_type(<i32 as StaticType>::static_type());
818            gobject_sys::g_object_get_property(
819                self.to_glib_none().0 as *mut gobject_sys::GObject,
820                b"icon-size\0".as_ptr() as *const _,
821                value.to_glib_none_mut().0,
822            );
823            value.get().unwrap()
824        }
825    }
826
827    fn set_property_icon_size(&self, icon_size: i32) {
828        unsafe {
829            gobject_sys::g_object_set_property(
830                self.to_glib_none().0 as *mut gobject_sys::GObject,
831                b"icon-size\0".as_ptr() as *const _,
832                Value::from(&icon_size).to_glib_none().0,
833            );
834        }
835    }
836
837    fn set_property_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>) {
838        unsafe {
839            gobject_sys::g_object_set_property(
840                self.to_glib_none().0 as *mut gobject_sys::GObject,
841                b"pixbuf\0".as_ptr() as *const _,
842                Value::from(pixbuf).to_glib_none().0,
843            );
844        }
845    }
846
847    fn get_property_pixbuf_animation(&self) -> Option<gdk_pixbuf::PixbufAnimation> {
848        unsafe {
849            let mut value =
850                Value::from_type(<gdk_pixbuf::PixbufAnimation as StaticType>::static_type());
851            gobject_sys::g_object_get_property(
852                self.to_glib_none().0 as *mut gobject_sys::GObject,
853                b"pixbuf-animation\0".as_ptr() as *const _,
854                value.to_glib_none_mut().0,
855            );
856            value.get()
857        }
858    }
859
860    fn set_property_pixbuf_animation(
861        &self,
862        pixbuf_animation: Option<&gdk_pixbuf::PixbufAnimation>,
863    ) {
864        unsafe {
865            gobject_sys::g_object_set_property(
866                self.to_glib_none().0 as *mut gobject_sys::GObject,
867                b"pixbuf-animation\0".as_ptr() as *const _,
868                Value::from(pixbuf_animation).to_glib_none().0,
869            );
870        }
871    }
872
873    fn get_property_resource(&self) -> Option<GString> {
874        unsafe {
875            let mut value = Value::from_type(<GString as StaticType>::static_type());
876            gobject_sys::g_object_get_property(
877                self.to_glib_none().0 as *mut gobject_sys::GObject,
878                b"resource\0".as_ptr() as *const _,
879                value.to_glib_none_mut().0,
880            );
881            value.get()
882        }
883    }
884
885    fn set_property_resource(&self, resource: Option<&str>) {
886        unsafe {
887            gobject_sys::g_object_set_property(
888                self.to_glib_none().0 as *mut gobject_sys::GObject,
889                b"resource\0".as_ptr() as *const _,
890                Value::from(resource).to_glib_none().0,
891            );
892        }
893    }
894
895    fn get_property_use_fallback(&self) -> bool {
896        unsafe {
897            let mut value = Value::from_type(<bool as StaticType>::static_type());
898            gobject_sys::g_object_get_property(
899                self.to_glib_none().0 as *mut gobject_sys::GObject,
900                b"use-fallback\0".as_ptr() as *const _,
901                value.to_glib_none_mut().0,
902            );
903            value.get().unwrap()
904        }
905    }
906
907    fn set_property_use_fallback(&self, use_fallback: bool) {
908        unsafe {
909            gobject_sys::g_object_set_property(
910                self.to_glib_none().0 as *mut gobject_sys::GObject,
911                b"use-fallback\0".as_ptr() as *const _,
912                Value::from(&use_fallback).to_glib_none().0,
913            );
914        }
915    }
916
917    fn connect_property_file_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
918        unsafe extern "C" fn notify_file_trampoline<P, F: Fn(&P) + 'static>(
919            this: *mut gtk_sys::GtkImage,
920            _param_spec: glib_sys::gpointer,
921            f: glib_sys::gpointer,
922        ) where
923            P: IsA<Image>,
924        {
925            let f: &F = &*(f as *const F);
926            f(&Image::from_glib_borrow(this).unsafe_cast())
927        }
928        unsafe {
929            let f: Box_<F> = Box_::new(f);
930            connect_raw(
931                self.as_ptr() as *mut _,
932                b"notify::file\0".as_ptr() as *const _,
933                Some(transmute(notify_file_trampoline::<Self, F> as usize)),
934                Box_::into_raw(f),
935            )
936        }
937    }
938
939    fn connect_property_gicon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
940        unsafe extern "C" fn notify_gicon_trampoline<P, F: Fn(&P) + 'static>(
941            this: *mut gtk_sys::GtkImage,
942            _param_spec: glib_sys::gpointer,
943            f: glib_sys::gpointer,
944        ) where
945            P: IsA<Image>,
946        {
947            let f: &F = &*(f as *const F);
948            f(&Image::from_glib_borrow(this).unsafe_cast())
949        }
950        unsafe {
951            let f: Box_<F> = Box_::new(f);
952            connect_raw(
953                self.as_ptr() as *mut _,
954                b"notify::gicon\0".as_ptr() as *const _,
955                Some(transmute(notify_gicon_trampoline::<Self, F> as usize)),
956                Box_::into_raw(f),
957            )
958        }
959    }
960
961    fn connect_property_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
962        unsafe extern "C" fn notify_icon_name_trampoline<P, F: Fn(&P) + 'static>(
963            this: *mut gtk_sys::GtkImage,
964            _param_spec: glib_sys::gpointer,
965            f: glib_sys::gpointer,
966        ) where
967            P: IsA<Image>,
968        {
969            let f: &F = &*(f as *const F);
970            f(&Image::from_glib_borrow(this).unsafe_cast())
971        }
972        unsafe {
973            let f: Box_<F> = Box_::new(f);
974            connect_raw(
975                self.as_ptr() as *mut _,
976                b"notify::icon-name\0".as_ptr() as *const _,
977                Some(transmute(notify_icon_name_trampoline::<Self, F> as usize)),
978                Box_::into_raw(f),
979            )
980        }
981    }
982
983    fn connect_property_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
984        unsafe extern "C" fn notify_icon_size_trampoline<P, F: Fn(&P) + 'static>(
985            this: *mut gtk_sys::GtkImage,
986            _param_spec: glib_sys::gpointer,
987            f: glib_sys::gpointer,
988        ) where
989            P: IsA<Image>,
990        {
991            let f: &F = &*(f as *const F);
992            f(&Image::from_glib_borrow(this).unsafe_cast())
993        }
994        unsafe {
995            let f: Box_<F> = Box_::new(f);
996            connect_raw(
997                self.as_ptr() as *mut _,
998                b"notify::icon-size\0".as_ptr() as *const _,
999                Some(transmute(notify_icon_size_trampoline::<Self, F> as usize)),
1000                Box_::into_raw(f),
1001            )
1002        }
1003    }
1004
1005    fn connect_property_pixbuf_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1006        unsafe extern "C" fn notify_pixbuf_trampoline<P, F: Fn(&P) + 'static>(
1007            this: *mut gtk_sys::GtkImage,
1008            _param_spec: glib_sys::gpointer,
1009            f: glib_sys::gpointer,
1010        ) where
1011            P: IsA<Image>,
1012        {
1013            let f: &F = &*(f as *const F);
1014            f(&Image::from_glib_borrow(this).unsafe_cast())
1015        }
1016        unsafe {
1017            let f: Box_<F> = Box_::new(f);
1018            connect_raw(
1019                self.as_ptr() as *mut _,
1020                b"notify::pixbuf\0".as_ptr() as *const _,
1021                Some(transmute(notify_pixbuf_trampoline::<Self, F> as usize)),
1022                Box_::into_raw(f),
1023            )
1024        }
1025    }
1026
1027    fn connect_property_pixbuf_animation_notify<F: Fn(&Self) + 'static>(
1028        &self,
1029        f: F,
1030    ) -> SignalHandlerId {
1031        unsafe extern "C" fn notify_pixbuf_animation_trampoline<P, F: Fn(&P) + 'static>(
1032            this: *mut gtk_sys::GtkImage,
1033            _param_spec: glib_sys::gpointer,
1034            f: glib_sys::gpointer,
1035        ) where
1036            P: IsA<Image>,
1037        {
1038            let f: &F = &*(f as *const F);
1039            f(&Image::from_glib_borrow(this).unsafe_cast())
1040        }
1041        unsafe {
1042            let f: Box_<F> = Box_::new(f);
1043            connect_raw(
1044                self.as_ptr() as *mut _,
1045                b"notify::pixbuf-animation\0".as_ptr() as *const _,
1046                Some(transmute(
1047                    notify_pixbuf_animation_trampoline::<Self, F> as usize,
1048                )),
1049                Box_::into_raw(f),
1050            )
1051        }
1052    }
1053
1054    fn connect_property_pixel_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1055        unsafe extern "C" fn notify_pixel_size_trampoline<P, F: Fn(&P) + 'static>(
1056            this: *mut gtk_sys::GtkImage,
1057            _param_spec: glib_sys::gpointer,
1058            f: glib_sys::gpointer,
1059        ) where
1060            P: IsA<Image>,
1061        {
1062            let f: &F = &*(f as *const F);
1063            f(&Image::from_glib_borrow(this).unsafe_cast())
1064        }
1065        unsafe {
1066            let f: Box_<F> = Box_::new(f);
1067            connect_raw(
1068                self.as_ptr() as *mut _,
1069                b"notify::pixel-size\0".as_ptr() as *const _,
1070                Some(transmute(notify_pixel_size_trampoline::<Self, F> as usize)),
1071                Box_::into_raw(f),
1072            )
1073        }
1074    }
1075
1076    fn connect_property_resource_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1077        unsafe extern "C" fn notify_resource_trampoline<P, F: Fn(&P) + 'static>(
1078            this: *mut gtk_sys::GtkImage,
1079            _param_spec: glib_sys::gpointer,
1080            f: glib_sys::gpointer,
1081        ) where
1082            P: IsA<Image>,
1083        {
1084            let f: &F = &*(f as *const F);
1085            f(&Image::from_glib_borrow(this).unsafe_cast())
1086        }
1087        unsafe {
1088            let f: Box_<F> = Box_::new(f);
1089            connect_raw(
1090                self.as_ptr() as *mut _,
1091                b"notify::resource\0".as_ptr() as *const _,
1092                Some(transmute(notify_resource_trampoline::<Self, F> as usize)),
1093                Box_::into_raw(f),
1094            )
1095        }
1096    }
1097
1098    fn connect_property_storage_type_notify<F: Fn(&Self) + 'static>(
1099        &self,
1100        f: F,
1101    ) -> SignalHandlerId {
1102        unsafe extern "C" fn notify_storage_type_trampoline<P, F: Fn(&P) + 'static>(
1103            this: *mut gtk_sys::GtkImage,
1104            _param_spec: glib_sys::gpointer,
1105            f: glib_sys::gpointer,
1106        ) where
1107            P: IsA<Image>,
1108        {
1109            let f: &F = &*(f as *const F);
1110            f(&Image::from_glib_borrow(this).unsafe_cast())
1111        }
1112        unsafe {
1113            let f: Box_<F> = Box_::new(f);
1114            connect_raw(
1115                self.as_ptr() as *mut _,
1116                b"notify::storage-type\0".as_ptr() as *const _,
1117                Some(transmute(
1118                    notify_storage_type_trampoline::<Self, F> as usize,
1119                )),
1120                Box_::into_raw(f),
1121            )
1122        }
1123    }
1124
1125    fn connect_property_use_fallback_notify<F: Fn(&Self) + 'static>(
1126        &self,
1127        f: F,
1128    ) -> SignalHandlerId {
1129        unsafe extern "C" fn notify_use_fallback_trampoline<P, F: Fn(&P) + 'static>(
1130            this: *mut gtk_sys::GtkImage,
1131            _param_spec: glib_sys::gpointer,
1132            f: glib_sys::gpointer,
1133        ) where
1134            P: IsA<Image>,
1135        {
1136            let f: &F = &*(f as *const F);
1137            f(&Image::from_glib_borrow(this).unsafe_cast())
1138        }
1139        unsafe {
1140            let f: Box_<F> = Box_::new(f);
1141            connect_raw(
1142                self.as_ptr() as *mut _,
1143                b"notify::use-fallback\0".as_ptr() as *const _,
1144                Some(transmute(
1145                    notify_use_fallback_trampoline::<Self, F> as usize,
1146                )),
1147                Box_::into_raw(f),
1148            )
1149        }
1150    }
1151}
1152
1153impl fmt::Display for Image {
1154    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1155        write!(f, "Image")
1156    }
1157}