spice-client-glib 0.8.0

Rust bindings for the Spice client 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.git)
// DO NOT EDIT

use crate::{ffi, Channel};
use glib::{
    object::ObjectType as _,
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    #[doc(alias = "SpicePlaybackChannel")]
    pub struct PlaybackChannel(Object<ffi::SpicePlaybackChannel, ffi::SpicePlaybackChannelClass>) @extends Channel;

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

impl PlaybackChannel {
    #[doc(alias = "spice_playback_channel_set_delay")]
    pub fn set_delay(&self, delay_ms: u32) {
        unsafe {
            ffi::spice_playback_channel_set_delay(self.to_glib_none().0, delay_ms);
        }
    }

    #[doc(alias = "min-latency")]
    pub fn min_latency(&self) -> u32 {
        ObjectExt::property(self, "min-latency")
    }

    #[doc(alias = "min-latency")]
    pub fn set_min_latency(&self, min_latency: u32) {
        ObjectExt::set_property(self, "min-latency", min_latency)
    }

    pub fn is_muted(&self) -> bool {
        ObjectExt::property(self, "mute")
    }

    pub fn set_mute(&self, mute: bool) {
        ObjectExt::set_property(self, "mute", mute)
    }

    pub fn nchannels(&self) -> u32 {
        ObjectExt::property(self, "nchannels")
    }

    pub fn set_nchannels(&self, nchannels: u32) {
        ObjectExt::set_property(self, "nchannels", nchannels)
    }

    //pub fn volume(&self) -> /*Unimplemented*/Basic: Pointer {
    //    ObjectExt::property(self, "volume")
    //}

    //pub fn set_volume(&self, volume: /*Unimplemented*/Basic: Pointer) {
    //    ObjectExt::set_property(self,"volume", volume)
    //}

    //#[doc(alias = "playback-data")]
    //pub fn connect_playback_data<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
    //    Unimplemented data: *.Pointer
    //}

    #[doc(alias = "playback-get-delay")]
    pub fn connect_playback_get_delay<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn playback_get_delay_trampoline<F: Fn(&PlaybackChannel) + 'static>(
            this: *mut ffi::SpicePlaybackChannel,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this))
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"playback-get-delay".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    playback_get_delay_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "playback-start")]
    pub fn connect_playback_start<F: Fn(&Self, i32, i32, i32) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn playback_start_trampoline<
            F: Fn(&PlaybackChannel, i32, i32, i32) + 'static,
        >(
            this: *mut ffi::SpicePlaybackChannel,
            format: std::ffi::c_int,
            channels: std::ffi::c_int,
            rate: std::ffi::c_int,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this), format, channels, rate)
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"playback-start".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    playback_start_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "playback-stop")]
    pub fn connect_playback_stop<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn playback_stop_trampoline<F: Fn(&PlaybackChannel) + 'static>(
            this: *mut ffi::SpicePlaybackChannel,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this))
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"playback-stop".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    playback_stop_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "min-latency")]
    pub fn connect_min_latency_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_min_latency_trampoline<F: Fn(&PlaybackChannel) + 'static>(
            this: *mut ffi::SpicePlaybackChannel,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this))
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::min-latency".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_min_latency_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "mute")]
    pub fn connect_mute_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_mute_trampoline<F: Fn(&PlaybackChannel) + 'static>(
            this: *mut ffi::SpicePlaybackChannel,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this))
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::mute".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_mute_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "nchannels")]
    pub fn connect_nchannels_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_nchannels_trampoline<F: Fn(&PlaybackChannel) + 'static>(
            this: *mut ffi::SpicePlaybackChannel,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this))
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::nchannels".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_nchannels_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "volume")]
    pub fn connect_volume_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_volume_trampoline<F: Fn(&PlaybackChannel) + 'static>(
            this: *mut ffi::SpicePlaybackChannel,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this))
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::volume".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_volume_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}