gtk4/
editable_label.rs
1use std::{boxed::Box as Box_, mem::transmute};
4
5use glib::{
6 signal::{connect_raw, SignalHandlerId},
7 translate::*,
8};
9
10use crate::{ffi, prelude::*, EditableLabel};
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 let f: &F = &*(f as *const F);
21 f(&from_glib_borrow(this))
22 }
23 unsafe {
24 let f: Box_<F> = Box_::new(f);
25 connect_raw(
26 self.as_ptr() as *mut _,
27 b"notify::editing\0".as_ptr() as *const _,
28 Some(transmute::<*const (), unsafe extern "C" fn()>(
29 notify_editing_trampoline::<F> as *const (),
30 )),
31 Box_::into_raw(f),
32 )
33 }
34 }
35}