alsactl 0.8.0

API binding for alsactl library
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

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

glib::wrapper! {
    /// An interface to express common features of element information.
    ///
    /// A [`ElemInfoCommon`][crate::ElemInfoCommon] should be implemented by any type of element information.
    ///
    /// ## Properties
    ///
    ///
    /// #### `access`
    ///  The access permission for the element with [`ElemAccessFlag`][crate::ElemAccessFlag].
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `elem-id`
    ///  The identifier of element.
    ///
    /// Readable
    ///
    ///
    /// #### `elem-type`
    ///  The type of element, one of [`ElemType`][crate::ElemType].
    ///
    /// Readable | Writeable | Construct Only
    ///
    ///
    /// #### `owner`
    ///  The value of PID for process to own the element.
    ///
    /// Readable
    ///
    /// # Implements
    ///
    /// [`ElemInfoCommonExt`][trait@crate::prelude::ElemInfoCommonExt]
    #[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;
}

/// Trait containing all [`struct@ElemInfoCommon`] methods.
///
/// # Implementors
///
/// [`ElemInfoBoolean`][struct@crate::ElemInfoBoolean], [`ElemInfoBytes`][struct@crate::ElemInfoBytes], [`ElemInfoCommon`][struct@crate::ElemInfoCommon], [`ElemInfoEnumerated`][struct@crate::ElemInfoEnumerated], [`ElemInfoIec60958`][struct@crate::ElemInfoIec60958], [`ElemInfoInteger64`][struct@crate::ElemInfoInteger64], [`ElemInfoInteger`][struct@crate::ElemInfoInteger], [`ElemInfoSingleArray`][struct@crate::ElemInfoSingleArray]
pub trait ElemInfoCommonExt: IsA<ElemInfoCommon> + 'static {
    /// The access permission for the element with [`ElemAccessFlag`][crate::ElemAccessFlag].
    fn access(&self) -> ElemAccessFlag {
        ObjectExt::property(self.as_ref(), "access")
    }

    /// The access permission for the element with [`ElemAccessFlag`][crate::ElemAccessFlag].
    fn set_access(&self, access: ElemAccessFlag) {
        ObjectExt::set_property(self.as_ref(), "access", access)
    }

    /// The identifier of element.
    #[doc(alias = "elem-id")]
    fn elem_id(&self) -> Option<ElemId> {
        ObjectExt::property(self.as_ref(), "elem-id")
    }

    /// The type of element, one of [`ElemType`][crate::ElemType].
    #[doc(alias = "elem-type")]
    fn elem_type(&self) -> ElemType {
        ObjectExt::property(self.as_ref(), "elem-type")
    }

    /// The value of PID for process to own the element.
    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 {}