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 = "SpiceInputsChannel")]
pub struct InputsChannel(Object<ffi::SpiceInputsChannel, ffi::SpiceInputsChannelClass>) @extends Channel;
match fn {
type_ => || ffi::spice_inputs_channel_get_type(),
}
}
impl InputsChannel {
#[doc(alias = "spice_inputs_channel_button_press")]
pub fn button_press(&self, button: i32, button_state: i32) {
unsafe {
ffi::spice_inputs_channel_button_press(self.to_glib_none().0, button, button_state);
}
}
#[doc(alias = "spice_inputs_channel_button_release")]
pub fn button_release(&self, button: i32, button_state: i32) {
unsafe {
ffi::spice_inputs_channel_button_release(self.to_glib_none().0, button, button_state);
}
}
#[doc(alias = "spice_inputs_channel_key_press")]
pub fn key_press(&self, scancode: u32) {
unsafe {
ffi::spice_inputs_channel_key_press(self.to_glib_none().0, scancode);
}
}
#[doc(alias = "spice_inputs_channel_key_press_and_release")]
pub fn key_press_and_release(&self, scancode: u32) {
unsafe {
ffi::spice_inputs_channel_key_press_and_release(self.to_glib_none().0, scancode);
}
}
#[doc(alias = "spice_inputs_channel_key_release")]
pub fn key_release(&self, scancode: u32) {
unsafe {
ffi::spice_inputs_channel_key_release(self.to_glib_none().0, scancode);
}
}
#[doc(alias = "spice_inputs_channel_motion")]
pub fn motion(&self, dx: i32, dy: i32, button_state: i32) {
unsafe {
ffi::spice_inputs_channel_motion(self.to_glib_none().0, dx, dy, button_state);
}
}
#[doc(alias = "spice_inputs_channel_position")]
pub fn position(&self, x: i32, y: i32, display: i32, button_state: i32) {
unsafe {
ffi::spice_inputs_channel_position(self.to_glib_none().0, x, y, display, button_state);
}
}
#[doc(alias = "spice_inputs_channel_set_key_locks")]
pub fn set_key_locks(&self, locks: u32) {
unsafe {
ffi::spice_inputs_channel_set_key_locks(self.to_glib_none().0, locks);
}
}
#[doc(alias = "key-modifiers")]
pub fn key_modifiers(&self) -> i32 {
ObjectExt::property(self, "key-modifiers")
}
#[doc(alias = "inputs-modifiers")]
pub fn connect_inputs_modifiers<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn inputs_modifiers_trampoline<F: Fn(&InputsChannel) + 'static>(
this: *mut ffi::SpiceInputsChannel,
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"inputs-modifiers".as_ptr(),
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
inputs_modifiers_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "key-modifiers")]
pub fn connect_key_modifiers_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_key_modifiers_trampoline<F: Fn(&InputsChannel) + 'static>(
this: *mut ffi::SpiceInputsChannel,
_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::key-modifiers".as_ptr(),
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_key_modifiers_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}