Gspell.Checker

g GObject.Object GObject.Object Gspell.Checker Gspell.Checker GObject.Object->Gspell.Checker

Subclasses:None

Methods

Inherited:GObject.Object (37)
Structs:GObject.ObjectClass (5)
class new (language)
  add_word_to_personal (word, word_length)
  add_word_to_session (word, word_length)
  check_word (word, word_length)
  clear_session ()
  get_language ()
  get_suggestions (word, word_length)
  set_correction (word, word_length, replacement, replacement_length)
  set_language (language)

Properties

Name Type Flags Short Description
language Gspell.Language r/w/c  

Signals

Inherited:GObject.Object (1)
Name Short Description
session-cleared Emitted when the session dictionary is cleared.
word-added-to-personal Emitted when a word is added to the personal dictionary.
word-added-to-session Emitted when a word is added to the session dictionary.

Fields

Inherited:GObject.Object (1)
Name Type Access Description
parent_instance GObject.Object r  

Class Details

class Gspell.Checker(**kwargs)
Bases:GObject.Object
Abstract:No
Structure:Gspell.CheckerClass
classmethod new(language)
Parameters:language (Gspell.Language or None) – the Gspell.Language to use, or None.
Returns:a new Gspell.Checker object.
Return type:Gspell.Checker

Creates a new Gspell.Checker. If language is None, the default language is picked with Gspell.Language.get_default().

add_word_to_personal(word, word_length)
Parameters:
  • word (str) – a word.
  • word_length (int) – the byte length of word, or -1 if word is nul-terminated.

Adds a word to the personal dictionary. It is typically saved in the user’s home directory.

add_word_to_session(word, word_length)
Parameters:
  • word (str) – a word.
  • word_length (int) – the byte length of word, or -1 if word is nul-terminated.

Adds a word to the session dictionary. Each Gspell.Checker instance has a different session dictionary. The session dictionary is lost when the Gspell.Checker :language property changes or when self is destroyed or when Gspell.Checker.clear_session() is called.

This function is typically called for an “Ignore All” action.

check_word(word, word_length)
Parameters:
  • word (str) – the word to check.
  • word_length (int) – the byte length of word, or -1 if word is nul-terminated.
Raises:

GLib.Error

Returns:

True if word is correctly spelled, False otherwise.

Return type:

bool

If the Gspell.Checker :language is None, i.e. when no dictonaries are available, this function returns True to limit the damage.

clear_session()

Clears the session dictionary.

get_language()
Returns:the Gspell.Language currently used, or None if no dictionaries are available.
Return type:Gspell.Language or None
get_suggestions(word, word_length)
Parameters:
  • word (str) – a misspelled word.
  • word_length (int) – the byte length of word, or -1 if word is nul-terminated.
Returns:

the list of suggestions.

Return type:

[str]

Gets the suggestions for word. Free the return value with g_slist_free_full(suggestions, GLib.free).

set_correction(word, word_length, replacement, replacement_length)
Parameters:
  • word (str) – a word.
  • word_length (int) – the byte length of word, or -1 if word is nul-terminated.
  • replacement (str) – the replacement word.
  • replacement_length (int) – the byte length of replacement, or -1 if replacement is nul-terminated.

Informs the spell checker that word is replaced/corrected by replacement.

set_language(language)
Parameters:language (Gspell.Language or None) – the Gspell.Language to use, or None.

Sets the language to use for the spell checking. If language is None, the default language is picked with Gspell.Language.get_default().

do_session_cleared() virtual
do_word_added_to_personal(word) virtual
Parameters:word (str) –
do_word_added_to_session(word) virtual
Parameters:word (str) –

Signal Details

Gspell.Checker.signals.session_cleared(checker)
Signal Name:session-cleared
Flags:RUN_LAST
Parameters:checker (Gspell.Checker) – The object which received the signal

Emitted when the session dictionary is cleared.

Gspell.Checker.signals.word_added_to_personal(checker, word)
Signal Name:

word-added-to-personal

Flags:

RUN_LAST

Parameters:
  • checker (Gspell.Checker) – The object which received the signal
  • word (str) – the added word.

Emitted when a word is added to the personal dictionary.

Gspell.Checker.signals.word_added_to_session(checker, word)
Signal Name:

word-added-to-session

Flags:

RUN_LAST

Parameters:
  • checker (Gspell.Checker) – The object which received the signal
  • word (str) – the added word.

Emitted when a word is added to the session dictionary. See Gspell.Checker.add_word_to_session().

Property Details

Gspell.Checker.props.language
Name:language
Type:Gspell.Language
Default Value:None
Flags:READABLE, WRITABLE, CONSTRUCT

The Gspell.Language used.