1use std::{boxed::Box as Box_, mem::transmute};
4
5use glib::{
6 signal::{SignalHandlerId, connect_raw},
7 translate::*,
8};
9
10use crate::{EditableLabel, ffi, prelude::*};
11
12impl EditableLabel {
13 #[doc(alias = "editing")]
14 pub fn connect_editing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
15 unsafe extern "C" fn notify_editing_trampoline<F: Fn(&EditableLabel) + 'static>(
16 this: *mut ffi::GtkEditableLabel,
17 _param_spec: glib::ffi::gpointer,
18 f: glib::ffi::gpointer,
19 ) {
20 unsafe {
21 let f: &F = &*(f as *const F);
22 f(&from_glib_borrow(this))
23 }
24 }
25 unsafe {
26 let f: Box_<F> = Box_::new(f);
27 connect_raw(
28 self.as_ptr() as *mut _,
29 c"notify::editing".as_ptr() as *const _,
30 Some(transmute::<*const (), unsafe extern "C" fn()>(
31 notify_editing_trampoline::<F> as *const (),
32 )),
33 Box_::into_raw(f),
34 )
35 }
36 }
37}