use crate::{ffi, AnimationTarget};
use glib::{prelude::*, translate::*};
use std::boxed::Box as Box_;
glib::wrapper! {
#[doc(alias = "BisCallbackAnimationTarget")]
pub struct CallbackAnimationTarget(Object<ffi::BisCallbackAnimationTarget, ffi::BisCallbackAnimationTargetClass>) @extends AnimationTarget;
match fn {
type_ => || ffi::bis_callback_animation_target_get_type(),
}
}
impl CallbackAnimationTarget {
#[doc(alias = "bis_callback_animation_target_new")]
pub fn new<P: Fn(f64) + 'static>(callback: P) -> CallbackAnimationTarget {
assert_initialized_main_thread!();
let callback_data: Box_<P> = Box_::new(callback);
unsafe extern "C" fn callback_func<P: Fn(f64) + 'static>(
value: libc::c_double,
user_data: glib::ffi::gpointer,
) {
let callback = &*(user_data as *mut P);
(*callback)(value)
}
let callback = Some(callback_func::<P> as _);
unsafe extern "C" fn destroy_func<P: Fn(f64) + 'static>(data: glib::ffi::gpointer) {
let _callback = Box_::from_raw(data as *mut P);
}
let destroy_call2 = Some(destroy_func::<P> as _);
let super_callback0: Box_<P> = callback_data;
unsafe {
AnimationTarget::from_glib_full(ffi::bis_callback_animation_target_new(
callback,
Box_::into_raw(super_callback0) as *mut _,
destroy_call2,
))
.unsafe_cast()
}
}
}