1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT
use crate::Checker;
use glib::{prelude::*, translate::*};
use std::{fmt, ptr};
glib::wrapper! {
///
///
/// # Implements
///
/// [`NavigatorExt`][trait@crate::prelude::NavigatorExt]
#[doc(alias = "GspellNavigator")]
pub struct Navigator(Interface<ffi::GspellNavigator, ffi::GspellNavigatorInterface>);
match fn {
type_ => || ffi::gspell_navigator_get_type(),
}
}
impl Navigator {
pub const NONE: Option<&'static Navigator> = None;
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Navigator>> Sealed for T {}
}
/// Trait containing all [`struct@Navigator`] methods.
///
/// # Implementors
///
/// [`NavigatorTextView`][struct@crate::NavigatorTextView], [`Navigator`][struct@crate::Navigator]
pub trait NavigatorExt: IsA<Navigator> + sealed::Sealed + 'static {
/// Changes the current `word` by `change_to` in the text. `word` must be the same
/// as returned by the last call to [`goto_next()`][Self::goto_next()].
///
/// This function doesn't call [`CheckerExt::set_correction()`][crate::prelude::CheckerExt::set_correction()]. A widget using a
/// [`Navigator`][crate::Navigator] should call [`CheckerExt::set_correction()`][crate::prelude::CheckerExt::set_correction()] in addition to
/// this function.
/// ## `word`
/// the word to change.
/// ## `change_to`
/// the replacement.
#[doc(alias = "gspell_navigator_change")]
fn change(&self, word: &str, change_to: &str) {
unsafe {
ffi::gspell_navigator_change(
self.as_ref().to_glib_none().0,
word.to_glib_none().0,
change_to.to_glib_none().0,
);
}
}
/// Changes all occurrences of `word` by `change_to` in the text.
///
/// This function doesn't call [`CheckerExt::set_correction()`][crate::prelude::CheckerExt::set_correction()]. A widget using a
/// [`Navigator`][crate::Navigator] should call [`CheckerExt::set_correction()`][crate::prelude::CheckerExt::set_correction()] in addition to
/// this function.
/// ## `word`
/// the word to change.
/// ## `change_to`
/// the replacement.
#[doc(alias = "gspell_navigator_change_all")]
fn change_all(&self, word: &str, change_to: &str) {
unsafe {
ffi::gspell_navigator_change_all(
self.as_ref().to_glib_none().0,
word.to_glib_none().0,
change_to.to_glib_none().0,
);
}
}
/// Goes to the next misspelled word. When called the first time, goes to the
/// first misspelled word.
///
/// # Returns
///
/// [`true`] if a next misspelled word has been found, [`false`] if the spell
/// checking is finished or if an error occurred.
///
/// ## `word`
/// a location to store an allocated string, or [`None`].
/// Use `g_free()` to free the returned string.
///
/// ## `spell_checker`
/// a location to store the
/// [`Checker`][crate::Checker] used, or [`None`]. Use `g_object_unref()` when no longer
/// needed.
#[doc(alias = "gspell_navigator_goto_next")]
fn goto_next(&self) -> Result<(glib::GString, Checker), glib::Error> {
unsafe {
let mut word = ptr::null_mut();
let mut spell_checker = ptr::null_mut();
let mut error = ptr::null_mut();
let is_ok = ffi::gspell_navigator_goto_next(
self.as_ref().to_glib_none().0,
&mut word,
&mut spell_checker,
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok((from_glib_full(word), from_glib_full(spell_checker)))
} else {
Err(from_glib_full(error))
}
}
}
}
impl<O: IsA<Navigator>> NavigatorExt for O {}
impl fmt::Display for Navigator {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Navigator")
}
}