Beispiel #1
0
func Connect(obj unsafe.Pointer, signal string, cb interface{}) uint64 {
	cbp := &cb
	refHolderLock.Lock()
	refHolder = append(refHolder, cbp) //FIXME deref
	refHolderLock.Unlock()
	closure := C.new_closure(unsafe.Pointer(cbp))
	cSignal := (*C.gchar)(unsafe.Pointer(C.CString(signal)))
	defer C.free(unsafe.Pointer(cSignal))
	id := C.g_signal_connect_closure(C.gpointer(obj), cSignal, closure, C.gboolean(0))
	return uint64(id)
}
Beispiel #2
0
func ObjConnect(obj *C.GObject, signal string, cb interface{}) C.gulong {
	cbp := &cb
	refHolderLock.Lock()
	refHolder = append(refHolder, cbp) //TODO deref
	refHolderLock.Unlock()
	closure := C.new_closure(unsafe.Pointer(cbp))
	cSignal := (*C.gchar)(unsafe.Pointer(C.CString(signal)))
	defer C.free(unsafe.Pointer(cSignal))
	id := C.g_signal_connect_closure(asGPtr(obj), cSignal, closure, False())
	return id
}