GspellChecker

GspellChecker — Spell checker

Functions

Properties

GspellLanguage * language Read / Write / Construct

Signals

Types and Values

Object Hierarchy

    GEnum
    ╰── GspellCheckerError
    GObject
    ╰── GspellChecker

Includes

#include <gspell/gspell.h>

Description

GspellChecker is a spell checker.

If the “language” property is NULL, it means that no dictonaries are available, in which case the GspellChecker is in a “disabled” (but allowed) state.

gspell uses the Enchant library. The use of Enchant is part of the gspell API, GspellChecker exposes the EnchantDict with the gspell_checker_get_enchant_dict() function.

Functions

gspell_checker_new ()

GspellChecker *
gspell_checker_new (const GspellLanguage *language);

Creates a new GspellChecker. If language is NULL, the default language is picked with gspell_language_get_default().

Parameters

language

the GspellLanguage to use, or NULL.

[nullable]

Returns

a new GspellChecker object.


gspell_checker_get_language ()

const GspellLanguage *
gspell_checker_get_language (GspellChecker *checker);

Parameters

checker

a GspellChecker.

 

Returns

the GspellLanguage currently used, or NULL if no dictionaries are available.

[nullable]


gspell_checker_set_language ()

void
gspell_checker_set_language (GspellChecker *checker,
                             const GspellLanguage *language);

Sets the language to use for the spell checking. If language is NULL, the default language is picked with gspell_language_get_default().

Parameters

checker

a GspellChecker.

 

language

the GspellLanguage to use, or NULL.

[nullable]

gspell_checker_check_word ()

gboolean
gspell_checker_check_word (GspellChecker *checker,
                           const gchar *word,
                           gssize word_length,
                           GError **error);

If the “language” is NULL, i.e. when no dictonaries are available, this function returns TRUE to limit the damage.

Parameters

checker

a GspellChecker.

 

word

the word to check.

 

word_length

the byte length of word , or -1 if word is nul-terminated.

 

error

a location to a NULL GError, or NULL.

[out][optional]

Returns

TRUE if word is correctly spelled, FALSE otherwise.


gspell_checker_get_suggestions ()

GSList *
gspell_checker_get_suggestions (GspellChecker *checker,
                                const gchar *word,
                                gssize word_length);

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

Parameters

checker

a GspellChecker.

 

word

a misspelled word.

 

word_length

the byte length of word , or -1 if word is nul-terminated.

 

Returns

the list of suggestions.

[transfer full][element-type utf8]


gspell_checker_add_word_to_personal ()

void
gspell_checker_add_word_to_personal (GspellChecker *checker,
                                     const gchar *word,
                                     gssize word_length);

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

Parameters

checker

a GspellChecker.

 

word

a word.

 

word_length

the byte length of word , or -1 if word is nul-terminated.

 

gspell_checker_add_word_to_session ()

void
gspell_checker_add_word_to_session (GspellChecker *checker,
                                    const gchar *word,
                                    gssize word_length);

Adds a word to the session dictionary. Each GspellChecker instance has a different session dictionary. The session dictionary is lost when the “language” property changes or when checker is destroyed or when gspell_checker_clear_session() is called.

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

Parameters

checker

a GspellChecker.

 

word

a word.

 

word_length

the byte length of word , or -1 if word is nul-terminated.

 

gspell_checker_clear_session ()

void
gspell_checker_clear_session (GspellChecker *checker);

Clears the session dictionary.

Parameters

checker

a GspellChecker.

 

gspell_checker_set_correction ()

void
gspell_checker_set_correction (GspellChecker *checker,
                               const gchar *word,
                               gssize word_length,
                               const gchar *replacement,
                               gssize replacement_length);

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

Parameters

checker

a GspellChecker.

 

word

a word.

 

word_length

the byte length of word , or -1 if word is nul-terminated.

 

replacement

the replacement word.

 

replacement_length

the byte length of replacement , or -1 if replacement is nul-terminated.

 

gspell_checker_get_enchant_dict ()

EnchantDict *
gspell_checker_get_enchant_dict (GspellChecker *checker);

Gets the EnchantDict currently used by checker . It permits to extend GspellChecker with more features. Note that by doing so, the other classes in gspell may no longer work well.

GspellChecker re-creates a new EnchantDict when the “language” is changed and when the session is cleared.

[skip]

Parameters

checker

a GspellChecker.

 

Returns

the EnchantDict currently used by checker .

[transfer none][nullable]

Since: 1.6

Types and Values

GspellChecker

typedef struct _GspellChecker GspellChecker;

enum GspellCheckerError

An error code used with GSPELL_CHECKER_ERROR in a GError returned from a spell-checker-related function.

Members

GSPELL_CHECKER_ERROR_DICTIONARY

dictionary error.

 

GSPELL_CHECKER_ERROR_NO_LANGUAGE_SET

no language set.

 

GSPELL_CHECKER_ERROR

#define GSPELL_CHECKER_ERROR (gspell_checker_error_quark ())

Error domain for the spell checker. Errors in this domain will be from the GspellCheckerError enumeration. See GError for more information on error domains.

Property Details

The “language” property

  “language”                 GspellLanguage *

The GspellLanguage used.

Owner: GspellChecker

Flags: Read / Write / Construct

Signal Details

The “session-cleared” signal

void
user_function (GspellChecker *spell_checker,
               gpointer       user_data)

Emitted when the session dictionary is cleared.

Parameters

spell_checker

the GspellChecker.

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “word-added-to-personal” signal

void
user_function (GspellChecker *spell_checker,
               char          *word,
               gpointer       user_data)

Emitted when a word is added to the personal dictionary.

Parameters

spell_checker

the GspellChecker.

 

word

the added word.

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “word-added-to-session” signal

void
user_function (GspellChecker *spell_checker,
               char          *word,
               gpointer       user_data)

Emitted when a word is added to the session dictionary. See gspell_checker_add_word_to_session().

Parameters

spell_checker

the GspellChecker.

 

word

the added word.

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last

See Also

GspellLanguage