GspellChecker

## GspellChecker GspellChecker — Spell checker |

## Functions

#define | GSPELL_CHECKER_ERROR
GspellChecker * | gspell_checker_new ()
gboolean | gspell_checker_set_language ()
const GspellLanguage * | gspell_checker_get_language ()
gboolean | gspell_checker_check_word ()
GSList * | gspell_checker_get_suggestions ()
void | gspell_checker_add_word_to_personal ()
void | gspell_checker_add_word_to_session ()
void | gspell_checker_clear_session ()
void | gspell_checker_set_correction ()

## Properties

GspellLanguage * | language | Read / Write / Construct

## Signals

void | add-word-to-personal | Run Last
void | add-word-to-session | Run Last
void | clear-session | Run Last

## Types and Values

| GspellChecker
enum | GspellCheckerError

## Object Hierarchy

        GObject
        ╰── GspellChecker

## Includes

    #include <gspell/gspell.h>

## Description

GspellChecker is a spell checker. It is a wrapper around the Enchant library, to have an API based on GObject.

If the “language” is not set correctly, the spell checker should not be used. It can happen when no dictionaries are available, in which case `gspell_checker_get_language()` returns `NULL`.

## Functions

### 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.

### gspell_checker_new ()

    GspellChecker *
    gspell_checker_new (const GspellLanguage *language);

Creates a new GspellChecker. If `language` is `NULL`, finds the best available language based on the current locale.

#### Parameters

language | the GspellLanguage to use, or `NULL`. | [nullable]

#### Returns

a new GspellChecker object.

### gspell_checker_set_language ()

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

Sets the language to use for the spell checking. If `language` is `NULL`, finds the best available language based on the current locale.

#### Parameters

checker | a GspellChecker. |
language | the GspellLanguage to use, or `NULL`. | [nullable]

#### Returns

whether the operation was successful.

### 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_check_word ()

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

#### Parameters

checker | a GspellChecker. |
word | the word to check. |
error | a location to a `NULL` GError, or `NULL`. | [out][optional]

#### Returns

whether `word` is correctly spelled.

### gspell_checker_get_suggestions ()

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

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. |

#### 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);

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

#### Parameters

checker | a GspellChecker. |
word | a word. |

### gspell_checker_add_word_to_session ()

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

Adds a word to the session dictionary. The session dictionary is lost when the application exits. This function is typically called when an “Ignore All” action is activated.

#### Parameters

checker | a GspellChecker. |
word | a word. |

### 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,
                                   const gchar *replacement);

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

#### Parameters

checker | a GspellChecker. |
word | a word. |
replacement | the replacement word. |

## 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. |

## Property Details

### The `“language”` property

      “language”                 GspellLanguage *

The GspellLanguage used.

Flags: Read / Write / Construct

## Signal Details

### The `“add-word-to-personal”` signal

    void
    user_function (GspellChecker *spell_checker,
                   gchar         *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 `“add-word-to-session”` signal

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

Emitted when a word is added to the session dictionary. The session dictionary is lost when the application exits.

#### Parameters

spell_checker | the GspellChecker. |
word | the added word. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“clear-session”` 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

## See Also

GspellLanguage