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 for protocol of TASCAM FireWire series.
    /// TASCAM FireWire series transfer image of device state by either isochronous or asynchronous
    /// packets. The [`TascamProtocol`][crate::TascamProtocol] is an object interface for the image and the change of state
    /// in the TASCAM FireWire protocol.
    ///
    /// ## Signals
    ///
    ///
    /// #### `changed`
    ///  Emitted when the part of image differed for the change of device state.
    ///
    /// Action
    ///
    /// # Implements
    ///
    /// [`TascamProtocolExt`][trait@crate::prelude::TascamProtocolExt], [`TascamProtocolExtManual`][trait@crate::prelude::TascamProtocolExtManual]
    #[doc(alias = "HitakiTascamProtocol")]
    pub struct TascamProtocol(Interface<ffi::HitakiTascamProtocol, ffi::HitakiTascamProtocolInterface>);

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

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

/// Trait containing the part of [`struct@TascamProtocol`] methods.
///
/// # Implementors
///
/// [`SndTascam`][struct@crate::SndTascam], [`TascamProtocol`][struct@crate::TascamProtocol]
pub trait TascamProtocolExt: IsA<TascamProtocol> + 'static {
    /// Emitted when the part of image differed for the change of device state.
    /// ## `index`
    /// the numeric index on image of status and control info.
    /// ## `before`
    /// the value of info before changed.
    /// ## `after`
    /// the value of info after changed.
    #[doc(alias = "changed")]
    fn connect_changed<F: Fn(&Self, u32, u32, u32) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn changed_trampoline<
            P: IsA<TascamProtocol>,
            F: Fn(&P, u32, u32, u32) + 'static,
        >(
            this: *mut ffi::HitakiTascamProtocol,
            index: std::ffi::c_uint,
            before: std::ffi::c_uint,
            after: std::ffi::c_uint,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                TascamProtocol::from_glib_borrow(this).unsafe_cast_ref(),
                index,
                before,
                after,
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"changed".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    changed_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn emit_changed(&self, index: u32, before: u32, after: u32) {
        self.emit_by_name::<()>("changed", &[&index, &before, &after]);
    }
}

impl<O: IsA<TascamProtocol>> TascamProtocolExt for O {}