示例#1
0
func (spell *GtkSpellChecker) SetLanguage(language string) *glib.Error {
	lang := C.CString(language)
	defer C.free(unsafe.Pointer(lang))

	var gerror *C.GError
	if C.gtk_spell_checker_set_language(spell.Spell, C.to_gcharptr(lang), &gerror) == 0 {
		return glib.ErrorFromNative(unsafe.Pointer(gerror))
	}
	return nil
}
示例#2
0
func New(textview *gtk.GtkTextView, language string) (*GtkSpellChecker, *glib.Error) {
	var lang *C.char
	if len(language) > 0 {
		lang = C.CString(language)
		defer C.free(unsafe.Pointer(lang))
	}

	var gerror *C.GError
	v := C.gtk_spell_checker_new()
	if C.gtk_spell_checker_set_language(v, (*C.gchar)(unsafe.Pointer(lang)), &gerror) == 0 {
		return nil, glib.ErrorFromNative(unsafe.Pointer(gerror))
	}
	C.gtk_spell_checker_attach(v, C.to_GtkTextView(unsafe.Pointer(textview.Widget)))
	return &GtkSpellChecker{v}, nil
}