hitaki 0.7.0

API bindings for hitaki 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! {
    /// An interface to operate notification with quadlet message.
    ///
    /// Some of units supported by drivers in ALSA firewire stack have the function to notify quadlet
    /// message for specific purposes. The [`QuadletNotification`][crate::QuadletNotification] is an interface to operate
    /// the notification.
    ///
    /// ## Signals
    ///
    ///
    /// #### `notified`
    ///  Emitted when the target unit transfers notification.
    ///
    /// Action
    ///
    /// # Implements
    ///
    /// [`QuadletNotificationExt`][trait@crate::prelude::QuadletNotificationExt]
    #[doc(alias = "HitakiQuadletNotification")]
    pub struct QuadletNotification(Interface<ffi::HitakiQuadletNotification, ffi::HitakiQuadletNotificationInterface>);

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

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

/// Trait containing all [`struct@QuadletNotification`] methods.
///
/// # Implementors
///
/// [`QuadletNotification`][struct@crate::QuadletNotification], [`SndDice`][struct@crate::SndDice], [`SndDigi00x`][struct@crate::SndDigi00x], [`SndMotu`][struct@crate::SndMotu]
pub trait QuadletNotificationExt: IsA<QuadletNotification> + 'static {
    /// Emitted when the target unit transfers notification.
    /// ## `message`
    /// A quadlet message in notification.
    #[doc(alias = "notified")]
    fn connect_notified<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notified_trampoline<
            P: IsA<QuadletNotification>,
            F: Fn(&P, u32) + 'static,
        >(
            this: *mut ffi::HitakiQuadletNotification,
            message: std::ffi::c_uint,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                QuadletNotification::from_glib_borrow(this).unsafe_cast_ref(),
                message,
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notified".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notified_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn emit_notified(&self, message: u32) {
        self.emit_by_name::<()>("notified", &[&message]);
    }
}

impl<O: IsA<QuadletNotification>> QuadletNotificationExt for O {}