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 user instance.
    ///
    /// A [`InstanceInfo`][crate::InstanceInfo] is a GObject-derived object to express information of user instance
    /// attached to any timer device or the other instance as slave. The call of
    /// [`UserInstanceExt::info()`][crate::prelude::UserInstanceExt::info()] returns the instance of object.
    ///
    /// The object wraps `struct snd_timer_info` in UAPI of Linux sound subsystem.
    ///
    /// ## Properties
    ///
    ///
    /// #### `card-id`
    ///  The numeric ID of sound card for attached timer.
    ///
    /// Readable
    ///
    ///
    /// #### `flags`
    ///  The flags for attached timer.
    ///
    /// Readable
    ///
    ///
    /// #### `id`
    ///  The string ID of attached timer.
    ///
    /// Readable
    ///
    ///
    /// #### `name`
    ///  The name of attached timer.
    ///
    /// Readable
    ///
    ///
    /// #### `resolution`
    ///  The resolution of attached timer in nano seconds.
    ///
    /// Readable
    ///
    /// # Implements
    ///
    /// [`InstanceInfoExt`][trait@crate::prelude::InstanceInfoExt]
    #[doc(alias = "ALSATimerInstanceInfo")]
    pub struct InstanceInfo(Object<ffi::ALSATimerInstanceInfo, ffi::ALSATimerInstanceInfoClass>);

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

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

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

    /// The flags for attached timer.
    fn flags(&self) -> DeviceInfoFlag {
        ObjectExt::property(self.as_ref(), "flags")
    }

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

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

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

    #[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<InstanceInfo>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::ALSATimerInstanceInfo,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(InstanceInfo::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<InstanceInfo>, F: Fn(&P) + 'static>(
            this: *mut ffi::ALSATimerInstanceInfo,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(InstanceInfo::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<InstanceInfo>, F: Fn(&P) + 'static>(
            this: *mut ffi::ALSATimerInstanceInfo,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(InstanceInfo::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 = "name")]
    fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_name_trampoline<P: IsA<InstanceInfo>, F: Fn(&P) + 'static>(
            this: *mut ffi::ALSATimerInstanceInfo,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(InstanceInfo::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<InstanceInfo>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::ALSATimerInstanceInfo,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(InstanceInfo::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),
            )
        }
    }
}

impl<O: IsA<InstanceInfo>> InstanceInfoExt for O {}