Exemplo n.º 1
0
Arquivo: glib.go Projeto: mattn/go-gtk
func (v *GObject) SignalConnect(s string, f interface{}, data interface{}, flags ConnectFlags) int {
	ctx := &CallbackContext{reflect.ValueOf(f), nil, reflect.ValueOf(v), reflect.ValueOf(data)}
	ptr := C.CString(s)
	defer C.free_string(ptr)
	id := callback_contexts.Add(ctx)
	ctx.cbi = unsafe.Pointer(C._g_signal_connect(unsafe.Pointer(v.Object), C.to_gcharptr(ptr), C.int(id), C.int(flags)))
	return id
}
Exemplo n.º 2
0
Arquivo: glib.go Projeto: leif/go-gtk
func (v *GObject) Connect(s string, f interface{}, datas ...interface{}) {
	var data interface{}
	if len(datas) > 0 {
		data = datas[0]
	}
	ctx := &CallbackContext{f, nil, reflect.ValueOf(v), reflect.ValueOf(data)}
	ptr := C.CString(s)
	defer C.free_string(ptr)
	ctx.cbi = unsafe.Pointer(C._g_signal_connect(unsafe.Pointer(v.Object), C.to_gcharptr(ptr), C.int(len(callback_contexts))))
	callback_contexts = append(callback_contexts, ctx)
}
Exemplo n.º 3
0
// Return the handler call_id to use with HandlerBlock, HandlerUnblock and
// HandlerDisconnect.
//
func (v *GObject) Connect(s string, f interface{}, datas ...interface{}) int {
	var data interface{}
	if len(datas) > 0 {
		data = datas[0]
	}
	ctx := &CallbackContext{reflect.ValueOf(f), nil, reflect.ValueOf(v), reflect.ValueOf(data)}
	ptr := C.CString(s)
	defer C.free_string(ptr)
	id := callback_contexts.Add(ctx)
	ctx.cbi = unsafe.Pointer(C._g_signal_connect(unsafe.Pointer(v.Object), C.to_gcharptr(ptr), C.int(id)))
	return id
}
Exemplo n.º 4
0
Arquivo: glib.go Projeto: jrick/gotk3
func (v *Object) connectCtx(ctx *CallbackContext, s string) int {
	cstr := C.CString(s)
	defer C.free(unsafe.Pointer(cstr))
	callbackContexts.RLock()
	nCbCtxs := len(callbackContexts.s)
	callbackContexts.RUnlock()
	ctx.cbi = unsafe.Pointer(C._g_signal_connect(unsafe.Pointer(v.GObject),
		(*C.gchar)(cstr), C.int(nCbCtxs)))
	callbackContexts.Lock()
	callbackContexts.s = append(callbackContexts.s, ctx)
	callbackContexts.Unlock()
	return nCbCtxs
}