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

glib::wrapper! {
    /// A GObject-derived object to express data for subscription between ports.
    ///
    /// A [`SubscribeData`][crate::SubscribeData] is a GObject-derived object to express data for subscription between
    /// a pair of ports. The call of [`subscription_list()`][crate::subscription_list()] returns the list of data. The call of
    /// [`UserClientExt::operate_subscription()`][crate::prelude::UserClientExt::operate_subscription()] requires the instance of object.
    ///
    /// The object wraps `struct snd_seq_port_subscribe` in UAPI of Linux sound subsystem.
    ///
    /// ## Properties
    ///
    ///
    /// #### `dest`
    ///  The address of destination.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `has-tstamp`
    ///  Any event for the subscription has time stamp,
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `is-exclusive`
    ///  Whether the subscription can be changed by originator only,
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `queue-id`
    ///  The numeric ID of queue to deliver. One of ALSASeqSpecificQueueId is available as well as
    /// any numeric value.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `sender`
    ///  The address of sender.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `tstamp-mode`
    ///  The type of time stamp. This is effective when the has-tstamp property enabled.
    ///
    /// Readable | Writeable
    ///
    /// # Implements
    ///
    /// [`SubscribeDataExt`][trait@crate::prelude::SubscribeDataExt]
    #[doc(alias = "ALSASeqSubscribeData")]
    pub struct SubscribeData(Object<ffi::ALSASeqSubscribeData, ffi::ALSASeqSubscribeDataClass>);

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

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

    /// Allocates and returns the instance of [`SubscribeData`][crate::SubscribeData].
    ///
    /// # Returns
    ///
    /// A [`SubscribeData`][crate::SubscribeData].
    #[doc(alias = "alsaseq_subscribe_data_new")]
    pub fn new() -> SubscribeData {
        unsafe { from_glib_full(ffi::alsaseq_subscribe_data_new()) }
    }
}

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

/// Trait containing all [`struct@SubscribeData`] methods.
///
/// # Implementors
///
/// [`SubscribeData`][struct@crate::SubscribeData]
pub trait SubscribeDataExt: IsA<SubscribeData> + 'static {
    /// The address of destination.
    fn dest(&self) -> Option<Addr> {
        ObjectExt::property(self.as_ref(), "dest")
    }

    /// The address of destination.
    fn set_dest(&self, dest: Option<&Addr>) {
        ObjectExt::set_property(self.as_ref(), "dest", dest)
    }

    /// Any event for the subscription has time stamp,
    #[doc(alias = "has-tstamp")]
    fn has_tstamp(&self) -> bool {
        ObjectExt::property(self.as_ref(), "has-tstamp")
    }

    /// Any event for the subscription has time stamp,
    #[doc(alias = "has-tstamp")]
    fn set_has_tstamp(&self, has_tstamp: bool) {
        ObjectExt::set_property(self.as_ref(), "has-tstamp", has_tstamp)
    }

    /// Whether the subscription can be changed by originator only,
    #[doc(alias = "is-exclusive")]
    fn is_exclusive(&self) -> bool {
        ObjectExt::property(self.as_ref(), "is-exclusive")
    }

    /// Whether the subscription can be changed by originator only,
    #[doc(alias = "is-exclusive")]
    fn set_is_exclusive(&self, is_exclusive: bool) {
        ObjectExt::set_property(self.as_ref(), "is-exclusive", is_exclusive)
    }

    /// The numeric ID of queue to deliver. One of ALSASeqSpecificQueueId is available as well as
    /// any numeric value.
    #[doc(alias = "queue-id")]
    fn queue_id(&self) -> u8 {
        ObjectExt::property(self.as_ref(), "queue-id")
    }

    /// The numeric ID of queue to deliver. One of ALSASeqSpecificQueueId is available as well as
    /// any numeric value.
    #[doc(alias = "queue-id")]
    fn set_queue_id(&self, queue_id: u8) {
        ObjectExt::set_property(self.as_ref(), "queue-id", queue_id)
    }

    /// The address of sender.
    fn sender(&self) -> Option<Addr> {
        ObjectExt::property(self.as_ref(), "sender")
    }

    /// The address of sender.
    fn set_sender(&self, sender: Option<&Addr>) {
        ObjectExt::set_property(self.as_ref(), "sender", sender)
    }

    /// The type of time stamp. This is effective when the has-tstamp property enabled.
    #[doc(alias = "tstamp-mode")]
    fn tstamp_mode(&self) -> EventTstampMode {
        ObjectExt::property(self.as_ref(), "tstamp-mode")
    }

    /// The type of time stamp. This is effective when the has-tstamp property enabled.
    #[doc(alias = "tstamp-mode")]
    fn set_tstamp_mode(&self, tstamp_mode: EventTstampMode) {
        ObjectExt::set_property(self.as_ref(), "tstamp-mode", tstamp_mode)
    }

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

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

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

    #[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<SubscribeData>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::ALSASeqSubscribeData,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(SubscribeData::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 = "sender")]
    fn connect_sender_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_sender_trampoline<
            P: IsA<SubscribeData>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::ALSASeqSubscribeData,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(SubscribeData::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::sender".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_sender_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

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

impl<O: IsA<SubscribeData>> SubscribeDataExt for O {}