GspellTextView

GspellTextView — Spell checking support for GtkTextView

Functions

Properties

gboolean enable-language-menu Read / Write
gboolean inline-spell-checking Read / Write
GtkTextView * view Read / Write / Construct Only

Types and Values

Object Hierarchy

    GObject
    ╰── GspellTextView

Includes

#include <gspell/gspell.h>

Description

GspellTextView extends the GtkTextView class with inline spell checking. Misspelled words are highlighted with a red PANGO_UNDERLINE_SINGLE. Right-clicking a misspelled word pops up a context menu of suggested replacements. The context menu also contains an “Ignore All” item to add the misspelled word to the session dictionary. And an “Add” item to add the word to the personal dictionary.

For a basic use-case, there is the gspell_text_view_basic_setup() convenience function.

The spell is checked only on the visible region of the GtkTextView. Note that if a same GtkTextBuffer is used for several views, the misspelled words are visible in all views, because the highlighting is achieved with a GtkTextTag added to the buffer.

If you don't use the gspell_text_view_basic_setup() function, you need to call gspell_text_buffer_set_spell_checker() to associate a GspellChecker to the GtkTextBuffer.

Note that GspellTextView extends the GtkTextView class but without subclassing it, because the GtkSourceView library has already a GtkTextView subclass.

If you want a PANGO_UNDERLINE_ERROR instead (a wavy underline), please fix this bug first.

Functions

gspell_text_view_get_from_gtk_text_view ()

GspellTextView *
gspell_text_view_get_from_gtk_text_view
                               (GtkTextView *gtk_view);

Returns the GspellTextView of gtk_view . The returned object is guaranteed to be the same for the lifetime of gtk_view .

Parameters

gtk_view

a GtkTextView.

 

Returns

the GspellTextView of gtk_view .

[transfer none]


gspell_text_view_basic_setup ()

void
gspell_text_view_basic_setup (GspellTextView *gspell_view);

This function is a convenience function that does the following:

Example:

1
2
3
4
5
GtkTextView *gtk_view;
GspellTextView *gspell_view;

gspell_view = gspell_text_view_get_from_gtk_text_view (gtk_view);
gspell_text_view_basic_setup (gspell_view);

This is equivalent to:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
GtkTextView *gtk_view;
GspellTextView *gspell_view;
GspellChecker *checker;
GtkTextBuffer *gtk_buffer;
GspellTextBuffer *gspell_buffer;

checker = gspell_checker_new (NULL);
gtk_buffer = gtk_text_view_get_buffer (gtk_view);
gspell_buffer = gspell_text_buffer_get_from_gtk_text_buffer (gtk_buffer);
gspell_text_buffer_set_spell_checker (gspell_buffer, checker);
g_object_unref (checker);

gspell_view = gspell_text_view_get_from_gtk_text_view (gtk_view);
gspell_text_view_set_inline_spell_checking (gspell_view, TRUE);
gspell_text_view_set_enable_language_menu (gspell_view, TRUE);

Parameters

gspell_view

a GspellTextView.

 

Since: 1.2


gspell_text_view_get_view ()

GtkTextView *
gspell_text_view_get_view (GspellTextView *gspell_view);

Parameters

gspell_view

a GspellTextView.

 

Returns

the GtkTextView of gspell_view .

[transfer none]


gspell_text_view_get_inline_spell_checking ()

gboolean
gspell_text_view_get_inline_spell_checking
                               (GspellTextView *gspell_view);

Parameters

gspell_view

a GspellTextView.

 

Returns

whether the inline spell checking is enabled.


gspell_text_view_set_inline_spell_checking ()

void
gspell_text_view_set_inline_spell_checking
                               (GspellTextView *gspell_view,
                                gboolean enable);

Enables or disables the inline spell checking.

Parameters

gspell_view

a GspellTextView.

 

enable

the new state.

 

gspell_text_view_get_enable_language_menu ()

gboolean
gspell_text_view_get_enable_language_menu
                               (GspellTextView *gspell_view);

Parameters

gspell_view

a GspellTextView.

 

Returns

whether the language context menu is enabled.

Since: 1.2


gspell_text_view_set_enable_language_menu ()

void
gspell_text_view_set_enable_language_menu
                               (GspellTextView *gspell_view,
                                gboolean enable_language_menu);

Sets whether to enable the language context menu. If enabled, doing a right click on the GtkTextView will show a sub-menu to choose the language for the spell checking. If another language is chosen, it changes the “language” property of the “spell-checker” of the “buffer” of the “view”.

Parameters

gspell_view

a GspellTextView.

 

enable_language_menu

whether to enable the language context menu.

 

Since: 1.2

Types and Values

GspellTextView

typedef struct _GspellTextView GspellTextView;

Property Details

The “enable-language-menu” property

  “enable-language-menu”     gboolean

When the context menu is shown, whether to add a sub-menu to select the language for the spell checking.

Owner: GspellTextView

Flags: Read / Write

Default value: FALSE

Since: 1.2


The “inline-spell-checking” property

  “inline-spell-checking”    gboolean

Whether the inline spell checking is enabled.

Owner: GspellTextView

Flags: Read / Write

Default value: FALSE


The “view” property

  “view”                     GtkTextView *

The GtkTextView.

Owner: GspellTextView

Flags: Read / Write / Construct Only