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;
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    /// A GObject-derived object to express information of sound card.
    ///
    /// A [`CardInfo`][crate::CardInfo] is information of sound card. The call of [`CardExt::info()`][crate::prelude::CardExt::info()] returns an
    /// instance of the object.
    ///
    /// The object wraps `struct snd_ctl_card_info` in UAPI of Linux sound subsystem.
    ///
    /// ## Properties
    ///
    ///
    /// #### `card-id`
    ///  The numeric ID of sound card.
    ///
    /// Readable
    ///
    ///
    /// #### `components`
    ///  The The string with space-separated components for the sound card.,
    ///
    /// Readable
    ///
    ///
    /// #### `driver`
    ///  The name of driver bound to the sound card.
    ///
    /// Readable
    ///
    ///
    /// #### `id`
    ///  The string ID of sound card.
    ///
    /// Readable
    ///
    ///
    /// #### `long-name`
    ///  The long name of sound card.
    ///
    /// Readable
    ///
    ///
    /// #### `mixer-name`
    ///  The name of mixer for the sound card.
    ///
    /// Readable
    ///
    ///
    /// #### `name`
    ///  The name of sound card.
    ///
    /// Readable
    ///
    /// # Implements
    ///
    /// [`CardInfoExt`][trait@crate::prelude::CardInfoExt]
    #[doc(alias = "ALSACtlCardInfo")]
    pub struct CardInfo(Object<ffi::ALSACtlCardInfo, ffi::ALSACtlCardInfoClass>);

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

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

/// Trait containing all [`struct@CardInfo`] methods.
///
/// # Implementors
///
/// [`CardInfo`][struct@crate::CardInfo]
pub trait CardInfoExt: IsA<CardInfo> + 'static {
    /// The numeric ID of sound card.
    #[doc(alias = "card-id")]
    fn card_id(&self) -> i32 {
        ObjectExt::property(self.as_ref(), "card-id")
    }

    /// The The string with space-separated components for the sound card.,
    fn components(&self) -> Option<glib::GString> {
        ObjectExt::property(self.as_ref(), "components")
    }

    /// The name of driver bound to the sound card.
    fn driver(&self) -> Option<glib::GString> {
        ObjectExt::property(self.as_ref(), "driver")
    }

    /// The string ID of sound card.
    fn id(&self) -> Option<glib::GString> {
        ObjectExt::property(self.as_ref(), "id")
    }

    /// The long name of sound card.
    #[doc(alias = "long-name")]
    fn long_name(&self) -> Option<glib::GString> {
        ObjectExt::property(self.as_ref(), "long-name")
    }

    /// The name of mixer for the sound card.
    #[doc(alias = "mixer-name")]
    fn mixer_name(&self) -> Option<glib::GString> {
        ObjectExt::property(self.as_ref(), "mixer-name")
    }

    /// The name of sound card.
    fn name(&self) -> Option<glib::GString> {
        ObjectExt::property(self.as_ref(), "name")
    }

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

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

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

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

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

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

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

impl<O: IsA<CardInfo>> CardInfoExt for O {}