GtkSpell.Checker

g GObject.InitiallyUnowned GObject.InitiallyUnowned GtkSpell.Checker GtkSpell.Checker GObject.InitiallyUnowned->GtkSpell.Checker GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

decode_language_code (lang)

class

get_from_text_view (view)

class

get_language_list ()

class

new ()

add_to_dictionary (word)

attach (view)

check_word (word)

detach ()

get_language ()

get_suggestions (word)

get_suggestions_menu (iter)

ignore_word (word)

recheck_all ()

set_language (lang)

Virtual Methods

Inherited:

GObject.Object (7)

do_language_changed (new_lang)

Properties

Name

Type

Flags

Short Description

decode-language-codes

bool

r/w

Whether to show decoded language codes in the context menu (requires the iso-codes package).

Signals

Inherited:

GObject.Object (1)

Name

Short Description

language-changed

The ::language-changed signal is emitted when the user selects a new spelling language from the context menu.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.InitiallyUnowned

r

Class Details

class GtkSpell.Checker(**kwargs)
Bases:

GObject.InitiallyUnowned

Abstract:

No

Structure:

GtkSpell.CheckerClass

The GtkSpell.Checker struct contains only private fields.

classmethod decode_language_code(lang)
Parameters:

lang (str) – The language locale specifier (i.e. “en_US”).

Returns:

The translated language specifier. Use GLib.free to free the returned string after use.

Return type:

str

Translates the language code to a human readable format (i.e. “en_US” -> “English (United States)”). Note: If the iso-codes package is not available, the unchanged code is returned.

New in version 3.0.3.

classmethod get_from_text_view(view)
Parameters:

view (Gtk.TextView) – A Gtk.TextView.

Returns:

the GtkSpell.Checker object, or None if there is no GtkSpell.Checker attached to view.

Return type:

GtkSpell.Checker

Retrieves the GtkSpell.Checker object attached to a text view.

classmethod get_language_list()
Returns:

a GLib.List of the available languages. Use g_list_free_full with GLib.free to free the list after use.

Return type:

[str]

Requests the list of available languages from the enchant broker.

New in version 3.0.3.

classmethod new()
Returns:

a new GtkSpell.Checker object.

Return type:

GtkSpell.Checker

Create a new GtkSpell.Checker object.

add_to_dictionary(word)
Parameters:

word (str) – The word to add to the user dictionary.

Add the specified word to the user dictionary.

New in version 3.0.9.

attach(view)
Parameters:

view (Gtk.TextView) – The Gtk.TextView to attach to.

Returns:

True on success, False on failure.

Return type:

bool

Attach GtkSpell.Checker object to view.

Note: Please read the tutorial section of the documentation to make sure you don’t leak references!

check_word(word)
Parameters:

word (str) – The word to check.

Returns:

True if the word is correctly spelled, False otherwise.

Return type:

bool

Check the specified word.

New in version 3.0.8.

detach()

Detaches this GtkSpell.Checker from its Gtk.TextView. Use GtkSpell.Checker.get_from_text_view () to retrieve a GtkSpell.Checker from a Gtk.TextView. If the GtkSpell.Checker is not attached to any Gtk.TextView, the function silently exits.

Note: if the GtkSpell.Checker is owned by the Gtk.TextView, you must take a reference to it to prevent it from being automatically destroyed. Please read the tutorial section of the documentation!

get_language()
Returns:

the current language. This string is owned by the spell object and must not be modified or freed.

Return type:

str

Fetches the current language.

get_suggestions(word)
Parameters:

word (str) – The word for which to fetch suggestions

Returns:

the list of spelling suggestions for the specified word, or None if there are no suggestions.

Return type:

[str]

Retreives a list of spelling suggestions for the specified word.

New in version 3.0.8.

get_suggestions_menu(iter)
Parameters:

iter (Gtk.TextIter) – Textiter of position in buffer to be corrected if necessary.

Returns:

the Gtk.Menu widget, or None if there is no need for a menu

Return type:

Gtk.Widget

Retrieves a submenu of replacement spellings, or None if the word at iter is not misspelt.

ignore_word(word)
Parameters:

word (str) – The word to add to the user ignore list.

Add the specified word to the user ignore list.

New in version 3.0.9.

recheck_all()

Recheck the spelling in the entire buffer.

set_language(lang)
Parameters:

lang (str or None) – The language to use, as a locale specifier (i.e. “en_US”). If None, attempt to use the default system locale (LANG).

Raises:

GLib.Error

Returns:

False if there was an error.

Return type:

bool

Set the language on self to lang, possibily returning an error in error.

do_language_changed(new_lang) virtual
Parameters:

new_lang (str) –

Signal Details

GtkSpell.Checker.signals.language_changed(checker, lang)
Signal Name:

language-changed

Flags:

RUN_LAST

Parameters:
  • checker (GtkSpell.Checker) – The object which received the signal

  • lang (str) – the new language which was selected.

The ::language-changed signal is emitted when the user selects a new spelling language from the context menu.

Property Details

GtkSpell.Checker.props.decode_language_codes
Name:

decode-language-codes

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether to show decoded language codes in the context menu (requires the iso-codes package).