gdk_pixbuf/auto/
pixbuf_simple_anim.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
6use crate::{ffi, Pixbuf, PixbufAnimation};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// An opaque struct representing a simple animation.
16    ///
17    /// ## Properties
18    ///
19    ///
20    /// #### `loop`
21    ///  Whether the animation should loop when it reaches the end.
22    ///
23    /// Readable | Writeable
24    ///
25    /// # Implements
26    ///
27    /// [`PixbufAnimationExt`][trait@crate::prelude::PixbufAnimationExt], [`PixbufAnimationExtManual`][trait@crate::prelude::PixbufAnimationExtManual]
28    #[doc(alias = "GdkPixbufSimpleAnim")]
29    pub struct PixbufSimpleAnim(Object<ffi::GdkPixbufSimpleAnim, ffi::GdkPixbufSimpleAnimClass>) @extends PixbufAnimation;
30
31    match fn {
32        type_ => || ffi::gdk_pixbuf_simple_anim_get_type(),
33    }
34}
35
36impl PixbufSimpleAnim {
37    /// Creates a new, empty animation.
38    ///
39    /// # Deprecated since 2.44
40    ///
41    /// Use a different image loading library for animatable assets
42    /// ## `width`
43    /// the width of the animation
44    /// ## `height`
45    /// the height of the animation
46    /// ## `rate`
47    /// the speed of the animation, in frames per second
48    ///
49    /// # Returns
50    ///
51    /// a newly allocated #GdkPixbufSimpleAnim
52    #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")]
53    #[allow(deprecated)]
54    #[doc(alias = "gdk_pixbuf_simple_anim_new")]
55    pub fn new(width: i32, height: i32, rate: f32) -> PixbufSimpleAnim {
56        unsafe { from_glib_full(ffi::gdk_pixbuf_simple_anim_new(width, height, rate)) }
57    }
58
59    /// Adds a new frame to @self. The @pixbuf must
60    /// have the dimensions specified when the animation
61    /// was constructed.
62    ///
63    /// # Deprecated since 2.44
64    ///
65    /// Use a different image loading library for animatable assets
66    /// ## `pixbuf`
67    /// the pixbuf to add
68    #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")]
69    #[allow(deprecated)]
70    #[doc(alias = "gdk_pixbuf_simple_anim_add_frame")]
71    pub fn add_frame(&self, pixbuf: &Pixbuf) {
72        unsafe {
73            ffi::gdk_pixbuf_simple_anim_add_frame(self.to_glib_none().0, pixbuf.to_glib_none().0);
74        }
75    }
76
77    /// Gets whether @self should loop indefinitely when it reaches the end.
78    ///
79    /// # Deprecated since 2.44
80    ///
81    /// Use a different image loading library for animatable assets
82    ///
83    /// # Returns
84    ///
85    /// [`true`] if the animation loops forever, [`false`] otherwise
86    #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")]
87    #[allow(deprecated)]
88    #[doc(alias = "gdk_pixbuf_simple_anim_get_loop")]
89    #[doc(alias = "get_loop")]
90    #[doc(alias = "loop")]
91    pub fn is_loop(&self) -> bool {
92        unsafe { from_glib(ffi::gdk_pixbuf_simple_anim_get_loop(self.to_glib_none().0)) }
93    }
94
95    /// Sets whether @self should loop indefinitely when it reaches the end.
96    ///
97    /// # Deprecated since 2.44
98    ///
99    /// Use a different image loading library for animatable assets
100    /// ## `loop_`
101    /// whether to loop the animation
102    #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")]
103    #[allow(deprecated)]
104    #[doc(alias = "gdk_pixbuf_simple_anim_set_loop")]
105    #[doc(alias = "loop")]
106    pub fn set_loop(&self, loop_: bool) {
107        unsafe {
108            ffi::gdk_pixbuf_simple_anim_set_loop(self.to_glib_none().0, loop_.into_glib());
109        }
110    }
111
112    #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")]
113    #[doc(alias = "loop")]
114    pub fn connect_loop_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
115        unsafe extern "C" fn notify_loop_trampoline<F: Fn(&PixbufSimpleAnim) + 'static>(
116            this: *mut ffi::GdkPixbufSimpleAnim,
117            _param_spec: glib::ffi::gpointer,
118            f: glib::ffi::gpointer,
119        ) {
120            let f: &F = &*(f as *const F);
121            f(&from_glib_borrow(this))
122        }
123        unsafe {
124            let f: Box_<F> = Box_::new(f);
125            connect_raw(
126                self.as_ptr() as *mut _,
127                c"notify::loop".as_ptr() as *const _,
128                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
129                    notify_loop_trampoline::<F> as *const (),
130                )),
131                Box_::into_raw(f),
132            )
133        }
134    }
135}