alsatimer 0.8.0

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

glib::wrapper! {
    /// A GObject-derived object to express information of timer device.
    ///
    /// A [`DeviceInfo`][crate::DeviceInfo] is a GObject-derived object to express information of timer device.
    /// The call of alsatimer_get_device_info() returns an instance of the object according to the
    /// identifier of timer device.
    ///
    /// The object wraps `struct snd_timer_ginfo` in UAPI of Linux sound subsystem.
    ///
    /// ## Properties
    ///
    ///
    /// #### `card-id`
    ///  The numeric ID of sound card.
    ///
    /// Readable
    ///
    ///
    /// #### `flags`
    ///  The flags of timer, one of [`DeviceInfoFlag`][crate::DeviceInfoFlag].
    ///
    /// Readable
    ///
    ///
    /// #### `id`
    ///  The string ID of timer.
    ///
    /// Readable
    ///
    ///
    /// #### `instance-count`
    ///  The number of instances for the timer.
    ///
    /// Readable
    ///
    ///
    /// #### `name`
    ///  The name of timer.
    ///
    /// Readable
    ///
    ///
    /// #### `resolution`
    ///  The resolution in nano seconds.
    ///
    /// Readable
    ///
    ///
    /// #### `resolution-max`
    ///  The maximum resolution in nano seconds.
    ///
    /// Readable
    ///
    ///
    /// #### `resolution-min`
    ///  The minimum resolution in nano seconds.
    ///
    /// Readable
    ///
    /// # Implements
    ///
    /// [`DeviceInfoExt`][trait@crate::prelude::DeviceInfoExt]
    #[doc(alias = "ALSATimerDeviceInfo")]
    pub struct DeviceInfo(Object<ffi::ALSATimerDeviceInfo, ffi::ALSATimerDeviceInfoClass>);

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

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

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

    /// The flags of timer, one of [`DeviceInfoFlag`][crate::DeviceInfoFlag].
    fn flags(&self) -> DeviceInfoFlag {
        ObjectExt::property(self.as_ref(), "flags")
    }

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

    /// The number of instances for the timer.
    #[doc(alias = "instance-count")]
    fn instance_count(&self) -> u32 {
        ObjectExt::property(self.as_ref(), "instance-count")
    }

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

    /// The resolution in nano seconds.
    fn resolution(&self) -> u64 {
        ObjectExt::property(self.as_ref(), "resolution")
    }

    /// The maximum resolution in nano seconds.
    #[doc(alias = "resolution-max")]
    fn resolution_max(&self) -> u64 {
        ObjectExt::property(self.as_ref(), "resolution-max")
    }

    /// The minimum resolution in nano seconds.
    #[doc(alias = "resolution-min")]
    fn resolution_min(&self) -> u64 {
        ObjectExt::property(self.as_ref(), "resolution-min")
    }

    #[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<DeviceInfo>, F: Fn(&P) + 'static>(
            this: *mut ffi::ALSATimerDeviceInfo,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(DeviceInfo::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 = "flags")]
    fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_flags_trampoline<P: IsA<DeviceInfo>, F: Fn(&P) + 'static>(
            this: *mut ffi::ALSATimerDeviceInfo,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(DeviceInfo::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::flags".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_flags_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<DeviceInfo>, F: Fn(&P) + 'static>(
            this: *mut ffi::ALSATimerDeviceInfo,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(DeviceInfo::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 = "instance-count")]
    fn connect_instance_count_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_instance_count_trampoline<
            P: IsA<DeviceInfo>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::ALSATimerDeviceInfo,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(DeviceInfo::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::instance-count".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_instance_count_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<DeviceInfo>, F: Fn(&P) + 'static>(
            this: *mut ffi::ALSATimerDeviceInfo,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(DeviceInfo::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),
            )
        }
    }

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

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

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

impl<O: IsA<DeviceInfo>> DeviceInfoExt for O {}