// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

use crate::{
    BaseTransitionClip, Clip, Container, Extractable, MetaContainer, OperationClip,
    TimelineElement, VideoStandardTransitionType,
};
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    #[doc(alias = "GESTransitionClip")]
    pub struct TransitionClip(Object<ffi::GESTransitionClip, ffi::GESTransitionClipClass>) @extends BaseTransitionClip, OperationClip, Clip, Container, TimelineElement, @implements Extractable, MetaContainer;

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

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

    #[doc(alias = "ges_transition_clip_new")]
    pub fn new(vtype: VideoStandardTransitionType) -> Option<TransitionClip> {
        assert_initialized_main_thread!();
        unsafe { from_glib_none(ffi::ges_transition_clip_new(vtype.into_glib())) }
    }

    #[doc(alias = "ges_transition_clip_new_for_nick")]
    #[doc(alias = "new_for_nick")]
    pub fn for_nick(nick: &str) -> Option<TransitionClip> {
        assert_initialized_main_thread!();
        unsafe { from_glib_none(ffi::ges_transition_clip_new_for_nick(nick.to_glib_none().0)) }
    }
}

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::TransitionClip>> Sealed for T {}
}

pub trait TransitionClipExt: IsA<TransitionClip> + sealed::Sealed + 'static {
    fn vtype(&self) -> VideoStandardTransitionType {
        ObjectExt::property(self.as_ref(), "vtype")
    }

    fn set_vtype(&self, vtype: VideoStandardTransitionType) {
        ObjectExt::set_property(self.as_ref(), "vtype", vtype)
    }

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

impl<O: IsA<TransitionClip>> TransitionClipExt for O {}
