use crate::{ffi, Channel, CursorShape};
use glib::{
object::ObjectType as _,
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
#[doc(alias = "SpiceCursorChannel")]
pub struct CursorChannel(Object<ffi::SpiceCursorChannel, ffi::SpiceCursorChannelClass>) @extends Channel;
match fn {
type_ => || ffi::spice_cursor_channel_get_type(),
}
}
impl CursorChannel {
pub fn cursor(&self) -> Option<CursorShape> {
ObjectExt::property(self, "cursor")
}
#[doc(alias = "cursor-hide")]
pub fn connect_cursor_hide<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn cursor_hide_trampoline<F: Fn(&CursorChannel) + 'static>(
this: *mut ffi::SpiceCursorChannel,
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"cursor-hide".as_ptr(),
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
cursor_hide_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "cursor-move")]
pub fn connect_cursor_move<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn cursor_move_trampoline<F: Fn(&CursorChannel, i32, i32) + 'static>(
this: *mut ffi::SpiceCursorChannel,
x: std::ffi::c_int,
y: std::ffi::c_int,
f: glib::ffi::gpointer,
) {
unsafe {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), x, y)
}
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"cursor-move".as_ptr(),
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
cursor_move_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "cursor-reset")]
pub fn connect_cursor_reset<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn cursor_reset_trampoline<F: Fn(&CursorChannel) + 'static>(
this: *mut ffi::SpiceCursorChannel,
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"cursor-reset".as_ptr(),
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
cursor_reset_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "cursor")]
pub fn connect_cursor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_cursor_trampoline<F: Fn(&CursorChannel) + 'static>(
this: *mut ffi::SpiceCursorChannel,
_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::cursor".as_ptr(),
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_cursor_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}