use glib::translate::*;
use std::cmp;
glib::wrapper! {
#[derive(Debug, Hash)]
pub struct Language(Boxed<ffi::GspellLanguage>);
match fn {
copy => |ptr| ffi::gspell_language_copy(ptr),
free => |ptr| ffi::gspell_language_free(ptr),
type_ => || ffi::gspell_language_get_type(),
}
}
impl Language {
#[doc(alias = "gspell_language_compare")]
fn compare(&self, language_b: &Language) -> i32 {
unsafe { ffi::gspell_language_compare(self.to_glib_none().0, language_b.to_glib_none().0) }
}
#[doc(alias = "gspell_language_get_code")]
#[doc(alias = "get_code")]
pub fn code(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::gspell_language_get_code(self.to_glib_none().0)) }
}
#[doc(alias = "gspell_language_get_name")]
#[doc(alias = "get_name")]
pub fn name(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::gspell_language_get_name(self.to_glib_none().0)) }
}
#[doc(alias = "gspell_language_get_available")]
#[doc(alias = "get_available")]
pub fn available() -> Vec<Language> {
assert_initialized_main_thread!();
unsafe { FromGlibPtrContainer::from_glib_none(ffi::gspell_language_get_available()) }
}
#[doc(alias = "gspell_language_get_default")]
#[doc(alias = "get_default")]
#[allow(clippy::should_implement_trait)]
pub fn default() -> Option<Language> {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::gspell_language_get_default()) }
}
#[doc(alias = "gspell_language_lookup")]
pub fn lookup(language_code: &str) -> Option<Language> {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::gspell_language_lookup(language_code.to_glib_none().0)) }
}
}
impl PartialEq for Language {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.compare(other) == 0
}
}
impl Eq for Language {}
impl PartialOrd for Language {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
Some(self.cmp(other))
}
}
impl Ord for Language {
#[inline]
fn cmp(&self, other: &Self) -> cmp::Ordering {
self.compare(other).cmp(&0)
}
}