use crate::{Calendar, ffi};
use glib::{
prelude::*,
signal::{SignalHandlerId, connect_raw},
translate::*,
};
use std::boxed::Box;
pub trait CalendarExtManual: IsA<Calendar> + 'static {
#[doc(alias = "color")]
fn connect_color_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_color_trampoline<P: IsA<Calendar>, F: Fn(&P) + 'static>(
this: *mut ffi::ClepsydreCalendar,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
unsafe {
let f: &F = &*(f as *const F);
f(Calendar::from_glib_borrow(this).unsafe_cast_ref())
}
}
unsafe {
let f: Box<F> = Box::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::color".as_ptr(),
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_color_trampoline::<Self, F> as *const (),
)),
Box::into_raw(f),
)
}
}
#[doc(alias = "event-creation-enabled")]
fn connect_event_creation_enabled_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_event_creation_enabled_trampoline<
P: IsA<Calendar>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::ClepsydreCalendar,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
unsafe {
let f: &F = &*(f as *const F);
f(Calendar::from_glib_borrow(this).unsafe_cast_ref())
}
}
unsafe {
let f: Box<F> = Box::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::event-creation-enabled".as_ptr(),
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_event_creation_enabled_trampoline::<Self, F> as *const (),
)),
Box::into_raw(f),
)
}
}
#[doc(alias = "name")]
fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_name_trampoline<P: IsA<Calendar>, F: Fn(&P) + 'static>(
this: *mut ffi::ClepsydreCalendar,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
unsafe {
let f: &F = &*(f as *const F);
f(Calendar::from_glib_borrow(this).unsafe_cast_ref())
}
}
unsafe {
let f: Box<F> = Box::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::name".as_ptr(),
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_name_trampoline::<Self, F> as *const (),
)),
Box::into_raw(f),
)
}
}
#[doc(alias = "removable")]
fn connect_removable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_removable_trampoline<P: IsA<Calendar>, F: Fn(&P) + 'static>(
this: *mut ffi::ClepsydreCalendar,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
unsafe {
let f: &F = &*(f as *const F);
f(Calendar::from_glib_borrow(this).unsafe_cast_ref())
}
}
unsafe {
let f: Box<F> = Box::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::removable".as_ptr(),
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_removable_trampoline::<Self, F> as *const (),
)),
Box::into_raw(f),
)
}
}
#[doc(alias = "visible")]
fn connect_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_visible_trampoline<P: IsA<Calendar>, F: Fn(&P) + 'static>(
this: *mut ffi::ClepsydreCalendar,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
unsafe {
let f: &F = &*(f as *const F);
f(Calendar::from_glib_borrow(this).unsafe_cast_ref())
}
}
unsafe {
let f: Box<F> = Box::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::visible".as_ptr(),
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_visible_trampoline::<Self, F> as *const (),
)),
Box::into_raw(f),
)
}
}
}
impl<T: IsA<Calendar>> CalendarExtManual for T {}