alsaseq 0.8.0

API binding for alsaseq 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 tempo of queue.
    ///
    /// A [`QueueTempo`][crate::QueueTempo] is a GObject-derived object to express tempo of queue.
    ///
    /// The object wraps `struct snd_seq_queue_tempo` in UAPI of Linux sound subsystem.
    ///
    /// ## Properties
    ///
    ///
    /// #### `queue-id`
    ///  The numeric ID of queue. An entry of ALSASeqSpecificClientId is available as well,
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `resolution`
    ///  The number of pulse per quarter as resolution.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `tempo`
    ///  The number of micro second per tick as tempo.
    ///
    /// Readable | Writeable
    ///
    /// # Implements
    ///
    /// [`QueueTempoExt`][trait@crate::prelude::QueueTempoExt], [`QueueTempoExtManual`][trait@crate::prelude::QueueTempoExtManual]
    #[doc(alias = "ALSASeqQueueTempo")]
    pub struct QueueTempo(Object<ffi::ALSASeqQueueTempo, ffi::ALSASeqQueueTempoClass>);

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

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

    /// Allocate and return an instance of [`QueueTempo`][crate::QueueTempo].
    ///
    /// # Returns
    ///
    /// An instance of [`QueueTempo`][crate::QueueTempo].
    #[doc(alias = "alsaseq_queue_tempo_new")]
    pub fn new() -> QueueTempo {
        unsafe { from_glib_full(ffi::alsaseq_queue_tempo_new()) }
    }
}

impl Default for QueueTempo {
    fn default() -> Self {
        Self::new()
    }
}

/// Trait containing the part of [`struct@QueueTempo`] methods.
///
/// # Implementors
///
/// [`QueueTempo`][struct@crate::QueueTempo]
pub trait QueueTempoExt: IsA<QueueTempo> + 'static {
    /// The numeric ID of queue. An entry of ALSASeqSpecificClientId is available as well.
    #[doc(alias = "queue-id")]
    fn queue_id(&self) -> u8 {
        ObjectExt::property(self.as_ref(), "queue-id")
    }

    /// The numeric ID of queue. An entry of ALSASeqSpecificClientId is available as well,
    #[doc(alias = "queue-id")]
    fn set_queue_id(&self, queue_id: u8) {
        ObjectExt::set_property(self.as_ref(), "queue-id", queue_id)
    }

    /// The number of pulse per quarter as resolution.
    fn resolution(&self) -> i32 {
        ObjectExt::property(self.as_ref(), "resolution")
    }

    /// The number of pulse per quarter as resolution.
    fn set_resolution(&self, resolution: i32) {
        ObjectExt::set_property(self.as_ref(), "resolution", resolution)
    }

    /// The number of micro second per tick as tempo.
    fn tempo(&self) -> u32 {
        ObjectExt::property(self.as_ref(), "tempo")
    }

    /// The number of micro second per tick as tempo.
    fn set_tempo(&self, tempo: u32) {
        ObjectExt::set_property(self.as_ref(), "tempo", tempo)
    }

    #[doc(alias = "queue-id")]
    fn connect_queue_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_queue_id_trampoline<P: IsA<QueueTempo>, F: Fn(&P) + 'static>(
            this: *mut ffi::ALSASeqQueueTempo,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(QueueTempo::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::queue-id".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_queue_id_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<QueueTempo>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::ALSASeqQueueTempo,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(QueueTempo::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 = "tempo")]
    fn connect_tempo_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_tempo_trampoline<P: IsA<QueueTempo>, F: Fn(&P) + 'static>(
            this: *mut ffi::ALSASeqQueueTempo,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(QueueTempo::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::tempo".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_tempo_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl<O: IsA<QueueTempo>> QueueTempoExt for O {}