// This file was generated by gir (https://github.com/gtk-rs/gir)
// from 
// from ../gir-files-gstreamer
// from ../gir-files-gtk
// from ../libclapper-rs
// DO NOT EDIT

use crate::{ffi,Av};
use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
use std::{boxed::Box as Box_};

glib::wrapper! {
    #[doc(alias = "ClapperGtkAudio")]
    pub struct Audio(Object<ffi::ClapperGtkAudio, ffi::ClapperGtkAudioClass>) @extends Av, gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;

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

impl Audio {
    #[doc(alias = "clapper_gtk_audio_new")]
    pub fn new() -> Audio {
        assert_initialized_main_thread!();
        unsafe {
            gtk::Widget::from_glib_none(ffi::clapper_gtk_audio_new()).unsafe_cast()
        }
    }

    #[doc(alias = "clapper_gtk_audio_get_child")]
    #[doc(alias = "get_child")]
    pub fn child(&self) -> Option<gtk::Widget> {
        unsafe {
            from_glib_none(ffi::clapper_gtk_audio_get_child(self.to_glib_none().0))
        }
    }

    #[doc(alias = "clapper_gtk_audio_set_child")]
    #[doc(alias = "child")]
    pub fn set_child(&self, child: Option<&impl IsA<gtk::Widget>>) {
        unsafe {
            ffi::clapper_gtk_audio_set_child(self.to_glib_none().0, child.map(|p| p.as_ref()).to_glib_none().0);
        }
    }

    #[cfg(not(feature = "v0_10"))]
    #[cfg_attr(docsrs, doc(cfg(not(feature = "v0_10"))))]
    pub fn child(&self) -> Option<gtk::Widget> {
        ObjectExt::property(self, "child")
    }

    #[cfg(not(feature = "v0_10"))]
    #[cfg_attr(docsrs, doc(cfg(not(feature = "v0_10"))))]
    pub fn set_child<P: IsA<gtk::Widget>>(&self, child: Option<&P>) {
        ObjectExt::set_property(self,"child", child)
    }

    #[doc(alias = "child")]
    pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_child_trampoline<F: Fn(&Audio) + 'static>(this: *mut ffi::ClapperGtkAudio, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::child".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_child_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }
}

impl Default for Audio {
                     fn default() -> Self {
                         Self::new()
                     }
                 }
