Example #1
0
// GetBuffer is a wrapper around gtk_text_view_get_buffer().
func (v *TextView) GetBuffer() (*TextBuffer, error) {
	c := C.gtk_text_view_get_buffer(v.native())
	if c == nil {
		return nil, nilPtrErr
	}
	return wrapTextBuffer(wrapObject(unsafe.Pointer(c))), nil
}
Example #2
0
func (t *textbox) Text() string {
	var start, end C.GtkTextIter

	buf := C.gtk_text_view_get_buffer(t.textview)
	C.gtk_text_buffer_get_bounds(buf, &start, &end)
	// include hidden chars even though there can't be one since Textbox is explicitly unformatted just to be safe
	// don't worry about embedded pixbufs or widgets; those aren't allowed either
	ctext := C.gtk_text_buffer_get_text(buf, &start, &end, C.TRUE)
	// not explicitly documented: have to manually free this (thanks ste in irc.gimp.net/#gtk+)
	defer C.g_free(C.gpointer(unsafe.Pointer(ctext)))
	return fromgstr(ctext)
}
Example #3
0
func (t *textbox) SetText(text string) {
	ctext := togstr(text)
	defer freegstr(ctext)
	buf := C.gtk_text_view_get_buffer(t.textview)
	C.gtk_text_buffer_set_text(buf, ctext, -1) // null-terminated
}