Example #1
0
File: gobj.go Project: hwch/go-gtk
//--------------------------------------------------------------
// Object
//--------------------------------------------------------------
func objectFinalizer(obj *Object) {
	if FQueue.Push(unsafe.Pointer(obj), objectFinalizer2) {
		return
	}
	C.g_object_set_qdata((*C.GObject)(obj.C), C.GQuark(go_repr), nil)
	C.g_object_unref(C.gpointer(obj.C))
}
Example #2
0
File: gobj.go Project: hwch/go-gtk
func ObjectWrap(c unsafe.Pointer, grab bool) unsafe.Pointer {
	if c == nil {
		return nil
	}
	obj := (*Object)(C.g_object_get_qdata((*C.GObject)(c), C.GQuark(go_repr)))
	if obj != nil {
		return unsafe.Pointer(obj)
	}
	obj = &Object{c}
	if grab {
		C.g_object_ref_sink(C.gpointer(obj.C))
	}
	setObjectFinalizer(obj)
	C.g_object_set_qdata((*C.GObject)(obj.C),
		C.GQuark(go_repr), unsafe.Pointer(obj))
	return unsafe.Pointer(obj)
}
Example #3
0
File: gobj.go Project: hwch/go-gtk
func objectFinalizer2(objc unsafe.Pointer) {
	obj := (*Object)(objc)
	C.g_object_set_qdata((*C.GObject)(obj.C), C.GQuark(go_repr), nil)
	C.g_object_unref(C.gpointer(obj.C))
}
Example #4
0
/*
This sets an opaque, named pointer on an object.
The name is specified through a #GQuark (retrived e.g. via
g_quark_from_static_string()), and the pointer
can be gotten back from the @object with g_object_get_qdata()
until the @object is finalized.
Setting a previously set user data pointer, overrides (frees)
the old pointer set, using #NULL as pointer essentially
removes the data stored.
*/
func (self *TraitObject) SetQdata(quark C.GQuark, data unsafe.Pointer) {
	C.g_object_set_qdata(self.CPointer, quark, (C.gpointer)(data))
	return
}