use crate::ffi;
use glib::translate::*;
glib::wrapper! {
#[doc(alias = "SpellingDictionary")]
pub struct Dictionary(Object<ffi::SpellingDictionary, ffi::SpellingDictionaryClass>);
match fn {
type_ => || ffi::spelling_dictionary_get_type(),
}
}
impl Dictionary {
#[doc(alias = "spelling_dictionary_add_word")]
pub fn add_word(&self, word: &str) {
unsafe {
ffi::spelling_dictionary_add_word(self.to_glib_none().0, word.to_glib_none().0);
}
}
#[doc(alias = "spelling_dictionary_contains_word")]
pub fn contains_word(&self, word: &str) -> bool {
let word_len = word.len() as _;
unsafe {
from_glib(ffi::spelling_dictionary_contains_word(
self.to_glib_none().0,
word.to_glib_none().0,
word_len,
))
}
}
#[doc(alias = "spelling_dictionary_get_code")]
#[doc(alias = "get_code")]
pub fn code(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::spelling_dictionary_get_code(self.to_glib_none().0)) }
}
#[doc(alias = "spelling_dictionary_get_extra_word_chars")]
#[doc(alias = "get_extra_word_chars")]
pub fn extra_word_chars(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::spelling_dictionary_get_extra_word_chars(
self.to_glib_none().0,
))
}
}
#[doc(alias = "spelling_dictionary_ignore_word")]
pub fn ignore_word(&self, word: &str) {
unsafe {
ffi::spelling_dictionary_ignore_word(self.to_glib_none().0, word.to_glib_none().0);
}
}
#[doc(alias = "spelling_dictionary_list_corrections")]
pub fn list_corrections(&self, word: &str) -> Vec<glib::GString> {
let word_len = word.len() as _;
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::spelling_dictionary_list_corrections(
self.to_glib_none().0,
word.to_glib_none().0,
word_len,
))
}
}
}