Exemplo n.º 1
0
// xmlSaveFormatFileEnc
func (doc *Document) SaveFormatFileEnc(filename string, encoding string, format int) int {
	ptrf := C.CString(filename)
	defer C.free_string(ptrf)
	ptre := C.CString(encoding)
	defer C.free_string(ptre)
	return int(C.xmlSaveFormatFileEnc(ptrf, doc.Ptr, ptre, C.int(format)))
}
Exemplo n.º 2
0
func (v *WebKitWebView) LoadHtmlString(content, base_uri string) {
	pcontent := C.CString(content)
	defer C.free_string(pcontent)
	pbase_uri := C.CString(base_uri)
	defer C.free_string(pbase_uri)
	C.webkit_web_view_load_html_string(v.getWebView(), C.to_gcharptr(pcontent), C.to_gcharptr(pbase_uri))
}
Exemplo n.º 3
0
// htmlSaveFileEnc
func (doc *HTMLDocument) SaveFileEnc(filename string, encoding string) int {
	ptrf := C.CString(filename)
	defer C.free_string(ptrf)
	ptre := C.CString(encoding)
	defer C.free_string(ptre)
	return int(C.htmlSaveFileEnc(ptrf, doc.Ptr, ptre))
}
Exemplo n.º 4
0
// xmlNewNs
func (node *Node) NewNs(href string, prefix string) *Namespace {
	ptrh := C.CString(href)
	defer C.free_string(ptrh)
	ptrp := C.CString(prefix)
	defer C.free_string(ptrp)
	return makeNamespace(C.xmlNewNs(node.Ptr, C.to_xmlcharptr(ptrh), C.to_xmlcharptr(ptrp)))
}
Exemplo n.º 5
0
func loadHtmlString(webview *C.GtkWidget, content, base_uri string) {
	pcontent := C.CString(content)
	defer C.free_string(pcontent)
	pbase_uri := C.CString(base_uri)
	defer C.free_string(pbase_uri)
	C.loadHtmlString(webview, C.to_gcharptr(pcontent), C.to_gcharptr(pbase_uri))
}
Exemplo n.º 6
0
// xmlNewDocProp
func (doc *Document) NewProp(name string, value string) *Attribute {
	ptrn := C.CString(name)
	defer C.free_string(ptrn)
	ptrv := C.CString(value)
	defer C.free_string(ptrv)
	cattr := C.xmlNewDocProp(doc.Ptr, C.to_xmlcharptr(ptrn), C.to_xmlcharptr(ptrv))
	return makeAttribute(cattr)
}
Exemplo n.º 7
0
// htmlParseFile
func ParseHTMLFile(filename string, encoding string) *HTMLDocument {
	ptrf := C.CString(filename)
	defer C.free_string(ptrf)
	ptre := C.CString(encoding)
	defer C.free_string(ptre)
	doc := C.htmlParseFile(ptrf, ptre)
	return makeHTMLDoc(doc)
}
Exemplo n.º 8
0
// htmlParseDoc
func ParseHTMLDoc(cur string, encoding string) *HTMLDocument {
	ptrc := C.CString(cur)
	defer C.free_string(ptrc)
	ptre := C.CString(encoding)
	defer C.free_string(ptre)
	doc := C.htmlParseDoc(C.to_xmlcharptr(ptrc), ptre)
	return makeHTMLDoc(doc)
}
Exemplo n.º 9
0
// xmlReadFile
func ReadFile(filename string, encoding string, options ParserOption) *Document {
	ptrf := C.CString(filename)
	defer C.free_string(ptrf)
	ptre := C.CString(encoding)
	defer C.free_string(ptre)
	doc := C.xmlReadFile(ptrf, ptre, C.int(options))
	return makeDoc(doc)
}
Exemplo n.º 10
0
// xmlReadMemory
func ReadMemory(buffer []byte, url string, encoding string, options ParserOption) *Document {
	ptru := C.CString(url)
	defer C.free_string(ptru)
	ptre := C.CString(encoding)
	defer C.free_string(ptre)
	doc := C.xmlReadMemory((*C.char)(unsafe.Pointer(&buffer[0])), C.int(len(buffer)), ptru, ptre, C.int(options))
	return makeDoc(doc)
}
Exemplo n.º 11
0
// xmlSetProp
func (node *Node) SetAttribute(name string, value string) *Attribute {
	ptrn := C.CString(name)
	defer C.free_string(ptrn)
	ptrv := C.CString(value)
	defer C.free_string(ptrv)
	cattr := C.xmlSetProp(node.Ptr, C.to_xmlcharptr(ptrn), C.to_xmlcharptr(ptrv))
	return makeAttribute(cattr)
}
Exemplo n.º 12
0
// htmlNewDoc
func NewHTMLDoc(uri string, external_id string) *HTMLDocument {
	ptru := C.CString(uri)
	defer C.free_string(ptru)
	ptre := C.CString(external_id)
	defer C.free_string(ptre)
	doc := C.htmlNewDoc(C.to_xmlcharptr(ptru), C.to_xmlcharptr(ptre))
	return makeHTMLDoc(doc)
}
Exemplo n.º 13
0
// xmlParseDTD
func ParseDTD(ExternalID string, SystemID string) *Dtd {
	ptre := C.CString(ExternalID)
	defer C.free_string(ptre)
	ptrs := C.CString(SystemID)
	defer C.free_string(ptrs)
	cdtd := C.xmlParseDTD(C.to_xmlcharptr(ptre), C.to_xmlcharptr(ptrs))
	return makeDtd(cdtd)
}
Exemplo n.º 14
0
Arquivo: glib.go Projeto: mattn/go-gtk
func (v *GObject) Set(name string, value interface{}) {
	ptr := C.CString(name)
	defer C.free_string(ptr)

	if _, ok := value.(WrappedObject); ok {
		value = value.(WrappedObject).GetInternalValue()
	}
	if _, ok := value.(GObject); ok {
		value = value.(GObject).Object
	}
	if _, ok := value.(GValue); ok {
		value = value.(GValue).Value
	}

	switch value.(type) {
	case bool:
		bval := gbool(value.(bool))
		C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&bval))
	case byte:
		bval := C.gchar(value.(byte))
		C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&bval))
		//C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.ValueOf(C.gchar(value.(byte))).UnsafeAddr()))
	case int:
		ival := C.int(value.(int))
		C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&ival))
	case uint:
		uval := C.guint(value.(uint))
		C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&uval))
		//C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.ValueOf(C.guint(value.(uint))).UnsafeAddr()))
	case float32:
		f32val := C.gfloat(value.(float32))
		C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&f32val))
		//C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.ValueOf(C.gfloat(value.(float64))).UnsafeAddr()))
	case float64:
		f64val := C.gfloat(value.(float64))
		C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&f64val))
		//C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.ValueOf(C.gfloat(value.(float64))).UnsafeAddr()))
	case string:
		pval := C.CString(value.(string))
		defer C.free_string(pval)
		C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&pval))
	default:
		if pv, ok := value.(*[0]uint8); ok {
			C._g_object_set_ptr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(pv))
		} else {
			av := reflect.ValueOf(value)
			if av.Kind() == reflect.Ptr {
				C._g_object_set_ptr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(av.Pointer()))
			} else if av.CanAddr() {
				C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(av.UnsafeAddr()))
			} else {
				C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&value))
			}
		}
	}
}
Exemplo n.º 15
0
// xmlNewTextChild
func (node *Node) NewTextChild(ns *Namespace, name string, content string) *TextNode {
	ptrn := C.CString(name)
	defer C.free_string(ptrn)
	ptrc := C.CString(content)
	defer C.free_string(ptrc)
	if ns == nil {
		return makeTextNode(C.xmlNewTextChild(node.Ptr, nil, C.to_xmlcharptr(ptrn), C.to_xmlcharptr(ptrc)))
	}
	return makeTextNode(C.xmlNewTextChild(node.Ptr, ns.Ptr, C.to_xmlcharptr(ptrn), C.to_xmlcharptr(ptrc)))
}
Exemplo n.º 16
0
// xmlCtxtReadDoc
func (p *Parser) ReadDoc(input string, url string, encoding string, options ParserOption) *Document {
	ptri := C.CString(input)
	defer C.free_string(ptri)
	ptru := C.CString(url)
	defer C.free_string(ptru)
	ptre := C.CString(encoding)
	defer C.free_string(ptre)
	doc := C.xmlCtxtReadDoc(p.Ptr, C.to_xmlcharptr(ptri), ptru, ptre, C.int(options))
	return makeDoc(doc)
}
Exemplo n.º 17
0
// htmlReadDoc
func ReadHTMLDoc(cur string, url string, encoding string, options HTMLParserOption) *HTMLDocument {
	ptrc := C.CString(cur)
	defer C.free_string(ptrc)
	ptru := C.CString(url)
	defer C.free_string(ptru)
	ptre := C.CString(encoding)
	defer C.free_string(ptre)
	doc := C.htmlReadDoc(C.to_xmlcharptr(ptrc), ptru, ptre, C.int(options))
	return makeHTMLDoc(doc)
}
Exemplo n.º 18
0
func (v *GtkSourceLanguageManager) GuessLanguage(filename string, contentType string) *GtkSourceLanguage {
	if filename == "" {
		cct := C.CString(contentType)
		defer C.free_string(cct)
		return &GtkSourceLanguage{C.gtk_source_language_manager_guess_language(v.LanguageManager, nil, C.to_gcharptr(cct))}
	}
	cfn := C.CString(filename)
	defer C.free_string(cfn)
	return &GtkSourceLanguage{C.gtk_source_language_manager_guess_language(v.LanguageManager, C.to_gcharptr(cfn), nil)}
}
Exemplo n.º 19
0
// xmlNewDocRawNode
func (doc *Document) NewRawNode(ns *Namespace, name string, content string) *Node {
	ptrn := C.CString(name)
	defer C.free_string(ptrn)
	ptrc := C.CString(content)
	defer C.free_string(ptrc)
	if ns != nil {
		return makeNode(C.xmlNewDocRawNode(doc.Ptr, ns.Ptr, C.to_xmlcharptr(ptrn), C.to_xmlcharptr(ptrc)))
	}
	return makeNode(C.xmlNewDocRawNode(doc.Ptr, nil, C.to_xmlcharptr(ptrn), C.to_xmlcharptr(ptrc)))
}
Exemplo n.º 20
0
// xmlNewDtd
func (doc *Document) NewDtd(name string, ExternalID string, SystemID string) *Dtd {
	ptrn := C.CString(name)
	defer C.free_string(ptrn)
	ptre := C.CString(ExternalID)
	defer C.free_string(ptre)
	ptrs := C.CString(SystemID)
	defer C.free_string(ptrs)
	cdtd := C.xmlNewDtd(doc.Ptr, C.to_xmlcharptr(ptrn), C.to_xmlcharptr(ptre), C.to_xmlcharptr(ptrs))
	return makeDtd(cdtd)
}
Exemplo n.º 21
0
// void webkit_web_frame_load_alternate_string(WebKitWebFrame *frame, const gchar *content, const gchar *base_url, const gchar *unreachable_url);
// void webkit_web_frame_load_request(WebKitWebFrame *frame, WebKitNetworkRequest *request);
func (v *WebKitWebFrame) LoadString(content, mime_type, encoding, base_uri string) {
	pcontent := C.CString(content)
	defer C.free_string(pcontent)
	pmime_type := C.CString(mime_type)
	defer C.free_string(pmime_type)
	pencoding := C.CString(encoding)
	defer C.free_string(pencoding)
	pbase_uri := C.CString(base_uri)
	defer C.free_string(pbase_uri)
	C.webkit_web_frame_load_string(v.getWebFrame(), C.to_gcharptr(pcontent), C.to_gcharptr(pmime_type), C.to_gcharptr(pencoding), C.to_gcharptr(pbase_uri))
}
Exemplo n.º 22
0
Arquivo: glib.go Projeto: leif/go-gtk
func FilenameToUri(filename string, hostname string) (uri string, err error) {
	pfilename := C.CString(filename)
	defer C.free_string(pfilename)
	phostname := C.CString(hostname)
	defer C.free_string(phostname)
	var gerror *C.GError
	uri = C.GoString(C.to_charptr(C.g_filename_to_uri(C.to_gcharptr(pfilename), C.to_gcharptr(phostname), &gerror)))
	if unsafe.Pointer(gerror) != nil {
		err = ErrorFromNative(unsafe.Pointer(gerror))
	} else {
		err = nil
	}
	return
}
Exemplo n.º 23
0
func (v *WebView) ExecuteScript(script string) {
	pscript := C.CString(script)
	defer C.free_string(pscript)
	C.webkit_web_view_execute_script(
		v.getWebView(),
		C.to_gcharptr(pscript))
}
Exemplo n.º 24
0
func (v *WebView) Open(uri string) {
	ptr := C.CString(uri)
	defer C.free_string(ptr)
	C.webkit_web_view_open(
		v.getWebView(),
		C.to_gcharptr(ptr))
}
Exemplo n.º 25
0
func (v *WebView) SetCustomEncoding(encoding string) {
	pencoding := C.CString(encoding)
	defer C.free_string(pencoding)
	C.webkit_web_view_set_custom_encoding(
		v.getWebView(),
		C.to_gcharptr(pencoding))
}
Exemplo n.º 26
0
func Color(name string) *GdkColor {
	var color C.GdkColor
	ptr := C.CString(name)
	defer C.free_string(ptr)
	C.gdk_color_parse(C.to_gcharptr(ptr), &color)
	return &GdkColor{color}
}
Exemplo n.º 27
0
func (v *WebFrame) LoadUri(uri string) {
	ptr := C.CString(uri)
	defer C.free_string(ptr)
	C.webkit_web_frame_load_uri(
		v.getWebFrame(),
		C.to_gcharptr(ptr))
}
Exemplo n.º 28
0
func (nr *WebKitNetworkRequest) SetURL(url string) {
	ptr := C.CString(url)
	defer C.free_string(ptr)
	C.webkit_network_request_set_uri(
		(*C.WebKitNetworkRequest)(nr.GObject.Object),
		C.to_gcharptr(ptr))
}
Exemplo n.º 29
0
func (v *WebView) LoadUri(uri string) {
	ptr := C.CString(uri)
	defer C.free_string(ptr)
	C.webkit_web_view_load_uri(
		v.getWebView(),
		C.to_gcharptr(ptr))
}
Exemplo n.º 30
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
}