libhelium 0.12.0

Rust bindings for libhelium
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use crate::{ffi, AnimationState, AnimationTarget};
use glib::{
    object::ObjectType as _,
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    #[doc(alias = "HeAnimation")]
    pub struct Animation(Object<ffi::HeAnimation, ffi::HeAnimationClass>);

    match fn {
        type_ => || ffi::he_animation_get_type(),
    }
}

impl Animation {
    pub const NONE: Option<&'static Animation> = None;
}

pub trait AnimationExt: IsA<Animation> + 'static {
    #[doc(alias = "he_animation_pause")]
    fn pause(&self) {
        unsafe {
            ffi::he_animation_pause(self.as_ref().to_glib_none().0);
        }
    }

    #[doc(alias = "he_animation_play")]
    fn play(&self) {
        unsafe {
            ffi::he_animation_play(self.as_ref().to_glib_none().0);
        }
    }

    #[doc(alias = "he_animation_reset")]
    fn reset(&self) {
        unsafe {
            ffi::he_animation_reset(self.as_ref().to_glib_none().0);
        }
    }

    #[doc(alias = "he_animation_resume")]
    fn resume(&self) {
        unsafe {
            ffi::he_animation_resume(self.as_ref().to_glib_none().0);
        }
    }

    #[doc(alias = "he_animation_skip")]
    fn skip(&self) {
        unsafe {
            ffi::he_animation_skip(self.as_ref().to_glib_none().0);
        }
    }

    #[doc(alias = "he_animation_estimate_duration")]
    fn estimate_duration(&self) -> u32 {
        unsafe { ffi::he_animation_estimate_duration(self.as_ref().to_glib_none().0) }
    }

    #[doc(alias = "he_animation_calculate_value")]
    fn calculate_value(&self, t: u32) -> f64 {
        unsafe { ffi::he_animation_calculate_value(self.as_ref().to_glib_none().0, t) }
    }

    #[doc(alias = "he_animation_get_state")]
    #[doc(alias = "get_state")]
    fn state(&self) -> AnimationState {
        unsafe { from_glib(ffi::he_animation_get_state(self.as_ref().to_glib_none().0)) }
    }

    #[doc(alias = "he_animation_set_state")]
    fn set_state(&self, value: AnimationState) {
        unsafe {
            ffi::he_animation_set_state(self.as_ref().to_glib_none().0, value.into_glib());
        }
    }

    #[doc(alias = "he_animation_get_target")]
    #[doc(alias = "get_target")]
    fn target(&self) -> AnimationTarget {
        unsafe { from_glib_none(ffi::he_animation_get_target(self.as_ref().to_glib_none().0)) }
    }

    #[doc(alias = "he_animation_set_target")]
    fn set_target(&self, value: &impl IsA<AnimationTarget>) {
        unsafe {
            ffi::he_animation_set_target(
                self.as_ref().to_glib_none().0,
                value.as_ref().to_glib_none().0,
            );
        }
    }

    #[doc(alias = "he_animation_get_widget")]
    #[doc(alias = "get_widget")]
    fn widget(&self) -> gtk::Widget {
        unsafe { from_glib_none(ffi::he_animation_get_widget(self.as_ref().to_glib_none().0)) }
    }

    #[doc(alias = "he_animation_set_widget")]
    fn set_widget(&self, value: &impl IsA<gtk::Widget>) {
        unsafe {
            ffi::he_animation_set_widget(
                self.as_ref().to_glib_none().0,
                value.as_ref().to_glib_none().0,
            );
        }
    }

    #[doc(alias = "he_animation_get_avalue")]
    #[doc(alias = "get_avalue")]
    fn avalue(&self) -> f64 {
        unsafe { ffi::he_animation_get_avalue(self.as_ref().to_glib_none().0) }
    }

    #[doc(alias = "he_animation_set_avalue")]
    fn set_avalue(&self, value: f64) {
        unsafe {
            ffi::he_animation_set_avalue(self.as_ref().to_glib_none().0, value);
        }
    }

    #[doc(alias = "done")]
    fn connect_done<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn done_trampoline<P: IsA<Animation>, F: Fn(&P) + 'static>(
            this: *mut ffi::HeAnimation,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Animation::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"done".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    done_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "state")]
    fn connect_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_state_trampoline<P: IsA<Animation>, F: Fn(&P) + 'static>(
            this: *mut ffi::HeAnimation,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Animation::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::state".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_state_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "target")]
    fn connect_target_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_target_trampoline<P: IsA<Animation>, F: Fn(&P) + 'static>(
            this: *mut ffi::HeAnimation,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Animation::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::target".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_target_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "widget")]
    fn connect_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_widget_trampoline<P: IsA<Animation>, F: Fn(&P) + 'static>(
            this: *mut ffi::HeAnimation,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Animation::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::widget".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_widget_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "avalue")]
    fn connect_avalue_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_avalue_trampoline<P: IsA<Animation>, F: Fn(&P) + 'static>(
            this: *mut ffi::HeAnimation,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Animation::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::avalue".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_avalue_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl<O: IsA<Animation>> AnimationExt for O {}