use crate::{ffi, ElemAccessFlag, ElemId, ElemType};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
#[doc(alias = "ALSACtlElemInfoCommon")]
pub struct ElemInfoCommon(Interface<ffi::ALSACtlElemInfoCommon, ffi::ALSACtlElemInfoCommonInterface>);
match fn {
type_ => || ffi::alsactl_elem_info_common_get_type(),
}
}
impl ElemInfoCommon {
pub const NONE: Option<&'static ElemInfoCommon> = None;
}
pub trait ElemInfoCommonExt: IsA<ElemInfoCommon> + 'static {
fn access(&self) -> ElemAccessFlag {
ObjectExt::property(self.as_ref(), "access")
}
fn set_access(&self, access: ElemAccessFlag) {
ObjectExt::set_property(self.as_ref(), "access", access)
}
#[doc(alias = "elem-id")]
fn elem_id(&self) -> Option<ElemId> {
ObjectExt::property(self.as_ref(), "elem-id")
}
#[doc(alias = "elem-type")]
fn elem_type(&self) -> ElemType {
ObjectExt::property(self.as_ref(), "elem-type")
}
fn owner(&self) -> i32 {
ObjectExt::property(self.as_ref(), "owner")
}
#[doc(alias = "access")]
fn connect_access_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_access_trampoline<
P: IsA<ElemInfoCommon>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::ALSACtlElemInfoCommon,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(ElemInfoCommon::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::access".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_access_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "elem-id")]
fn connect_elem_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_elem_id_trampoline<
P: IsA<ElemInfoCommon>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::ALSACtlElemInfoCommon,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(ElemInfoCommon::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::elem-id".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_elem_id_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "owner")]
fn connect_owner_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_owner_trampoline<
P: IsA<ElemInfoCommon>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::ALSACtlElemInfoCommon,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(ElemInfoCommon::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::owner".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_owner_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<ElemInfoCommon>> ElemInfoCommonExt for O {}