Esempio n. 1
0
func (v *DOMDocument) GetElementsByTagName(tagName string) []*DOMNode {
	CtagName := C.CString(tagName)
	defer C.free_string(CtagName)
	GtagName := C.to_gcharptr(CtagName)

	list := C.webkit_dom_document_get_elements_by_tag_name(v.getDOMDocument(), GtagName)
	length := C.webkit_dom_node_list_get_length(list)

	//log.Fatal(length)

	nodes := []*DOMNode{}
	for i := C.gulong(0); i < length; i++ {
		domNode := &DOMNode{glib.GObject{unsafe.Pointer(C.webkit_dom_node_list_item(list, C.gulong(i)))}}
		nodes = append(nodes, domNode)
	}
	return nodes
}
Esempio n. 2
0
File: value.go Progetto: ziutek/glib
// Set value to i
func (v *Value) Set(i interface{}) {
	if vg, ok := i.(ValueGetter); ok {
		vg.Value().Copy(v)
		return
	}
	// Other types
	r := reflect.ValueOf(i)
	switch r.Kind() {
	case reflect.Invalid:
		C.g_value_reset(v.g())

	case reflect.Bool:
		C.g_value_set_boolean(v.g(), gBoolean(r.Bool()))

	case reflect.Int:
		C.g_value_set_long(v.g(), C.glong(i.(int)))

	case reflect.Int8:
		C.g_value_set_schar(v.g(), C.gint8(i.(int8)))

	case reflect.Int32:
		C.g_value_set_int(v.g(), C.gint(i.(int32)))

	case reflect.Int64:
		C.g_value_set_int64(v.g(), C.gint64(i.(int64)))

	case reflect.Uint:
		C.g_value_set_ulong(v.g(), C.gulong(i.(uint)))

	case reflect.Uint8:
		C.g_value_set_uchar(v.g(), C.guchar(i.(uint8)))

	case reflect.Uint32:
		C.g_value_set_uint(v.g(), C.guint(i.(uint32)))

	case reflect.Uint64:
		C.g_value_set_uint64(v.g(), C.guint64(i.(uint64)))

	case reflect.Float32:
		C.g_value_set_float(v.g(), C.gfloat(i.(float32)))

	case reflect.Float64:
		C.g_value_set_double(v.g(), C.gdouble(i.(float64)))

	case reflect.Ptr:
		C.g_value_set_pointer(v.g(), C.gpointer(r.Pointer()))

	case reflect.String:
		C.g_value_set_static_string(v.g(), (*C.gchar)(C.CString(r.String())))

	default:
		panic("Can't represent Go value in Glib type system.")
	}
}
Esempio n. 3
0
/*
Retrieves a portion of the contents of a property. If the
property does not exist, then the function returns %FALSE,
and %GDK_NONE will be stored in @actual_property_type.

The XGetWindowProperty() function that gdk_property_get()
uses has a very confusing and complicated set of semantics.
Unfortunately, gdk_property_get() makes the situation
worse instead of better (the semantics should be considered
undefined), and also prints warnings to stderr in cases where it
should return a useful error to the program. You are advised to use
XGetWindowProperty() directly until a replacement function for
gdk_property_get() is provided.
*/
func PropertyGet(window IsWindow, property C.GdkAtom, type_ C.GdkAtom, offset uint64, length uint64, pdelete int) (actual_property_type C.GdkAtom, actual_format int, actual_length int, data string, return__ bool) {
	var __cgo__actual_format C.gint
	var __cgo__actual_length C.gint
	var __cgo__data *C.guchar
	var __cgo__return__ C.gboolean
	__cgo__return__ = C.gdk_property_get(window.GetWindowPointer(), property, type_, C.gulong(offset), C.gulong(length), C.gint(pdelete), &actual_property_type, &__cgo__actual_format, &__cgo__actual_length, &__cgo__data)
	actual_format = int(__cgo__actual_format)
	actual_length = int(__cgo__actual_length)
	data = C.GoString((*C.char)(unsafe.Pointer(__cgo__data)))
	return__ = __cgo__return__ == C.gboolean(1)
	return
}
Esempio n. 4
0
File: glib.go Progetto: vvanpo/gotk3
// HandlerDisconnect is a wrapper around g_signal_handler_disconnect().
func (v *Object) HandlerDisconnect(handle SignalHandle) {
	C.g_signal_handler_disconnect(C.gpointer(v.GObject), C.gulong(handle))
	C.g_closure_invalidate(signals[handle])
	delete(closures.m, signals[handle])
	delete(signals, handle)
}
Esempio n. 5
0
File: glib.go Progetto: vvanpo/gotk3
// HandlerUnblock is a wrapper around g_signal_handler_unblock().
func (v *Object) HandlerUnblock(handle SignalHandle) {
	C.g_signal_handler_unblock(C.gpointer(v.GObject), C.gulong(handle))
}
Esempio n. 6
0
func GlibULong(l uint64) C.gulong {
	return C.gulong(l)
}
Esempio n. 7
0
func GULong(val interface{}) *GValue {
	ui := val.(uint32)
	ul := C.gulong(ui)
	return CreateCGValue(G_TYPE_ULONG, unsafe.Pointer(&ul))
}