1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use libc::c_void;
use ffi::{self, gpointer, GCallback};
use translate::ToGlibPtr;
pub unsafe fn connect(receiver: gpointer, signal_name: &str, trampoline: GCallback,
closure: *mut Box<Fn() + 'static>) -> u64 {
let handle = ffi::g_signal_connect_data(receiver, signal_name.to_glib_none().0,
trampoline, closure as gpointer, destroy_closure, 0) as u64;
assert!(handle > 0);
handle
}
extern "C" fn destroy_closure(ptr: *mut c_void, _: *mut c_void) {
unsafe {
let ptr = ptr as *mut Box<Fn()>;
let _: Box<Box<Fn()>> = ::std::mem::transmute(ptr);
}
}