gdk_pixbuf/auto/
pixbuf_simple_anim.rs1use gdk_pixbuf_sys;
6use glib::object::ObjectType as ObjectType_;
7use glib::signal::connect_raw;
8use glib::signal::SignalHandlerId;
9use glib::translate::*;
10use glib_sys;
11use std::boxed::Box as Box_;
12use std::fmt;
13use std::mem::transmute;
14use Pixbuf;
15use PixbufAnimation;
16
17glib_wrapper! {
18 pub struct PixbufSimpleAnim(Object<gdk_pixbuf_sys::GdkPixbufSimpleAnim, gdk_pixbuf_sys::GdkPixbufSimpleAnimClass, PixbufSimpleAnimClass>) @extends PixbufAnimation;
19
20 match fn {
21 get_type => || gdk_pixbuf_sys::gdk_pixbuf_simple_anim_get_type(),
22 }
23}
24
25impl PixbufSimpleAnim {
26 pub fn new(width: i32, height: i32, rate: f32) -> PixbufSimpleAnim {
27 unsafe {
28 from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_simple_anim_new(
29 width, height, rate,
30 ))
31 }
32 }
33
34 pub fn add_frame(&self, pixbuf: &Pixbuf) {
35 unsafe {
36 gdk_pixbuf_sys::gdk_pixbuf_simple_anim_add_frame(
37 self.to_glib_none().0,
38 pixbuf.to_glib_none().0,
39 );
40 }
41 }
42
43 pub fn get_loop(&self) -> bool {
44 unsafe {
45 from_glib(gdk_pixbuf_sys::gdk_pixbuf_simple_anim_get_loop(
46 self.to_glib_none().0,
47 ))
48 }
49 }
50
51 pub fn set_loop(&self, loop_: bool) {
52 unsafe {
53 gdk_pixbuf_sys::gdk_pixbuf_simple_anim_set_loop(self.to_glib_none().0, loop_.to_glib());
54 }
55 }
56
57 pub fn connect_property_loop_notify<F: Fn(&PixbufSimpleAnim) + 'static>(
58 &self,
59 f: F,
60 ) -> SignalHandlerId {
61 unsafe extern "C" fn notify_loop_trampoline<F: Fn(&PixbufSimpleAnim) + 'static>(
62 this: *mut gdk_pixbuf_sys::GdkPixbufSimpleAnim,
63 _param_spec: glib_sys::gpointer,
64 f: glib_sys::gpointer,
65 ) {
66 let f: &F = &*(f as *const F);
67 f(&from_glib_borrow(this))
68 }
69 unsafe {
70 let f: Box_<F> = Box_::new(f);
71 connect_raw(
72 self.as_ptr() as *mut _,
73 b"notify::loop\0".as_ptr() as *const _,
74 Some(transmute(notify_loop_trampoline::<F> as usize)),
75 Box_::into_raw(f),
76 )
77 }
78 }
79}
80
81impl fmt::Display for PixbufSimpleAnim {
82 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
83 write!(f, "PixbufSimpleAnim")
84 }
85}