Gspell (spelling correction library) is currently being migrated to GTK4
I am looking for suggestion to update the API. Currently there are the following classes:
- GspellChecker is a spell checker
- GspellCheckerDialog is a GtkDialog to spell check a document one word at a time. It uses a GspellNavigator
- GspellEntry extends the GtkEntry class with inline spell checking
- GspellEntryBuffer extends the GtkEntryBuffer class with spell checking support.
- GspellLanguage represents a language that can be used for the spell checking
- GspellLanguageChooserDialog is a GtkDialog for choosing a #GspellLanguage
- GspellNavigatorTextView is a GtkDialog for navigate through misspelled words, and correct the mistakes
- GspellTextBuffer spell checking support for GtkTextBuffer
- GspellTextView spell checking support for GtkTextView
Basically Gspell*Buffer takes care of highlighting wrong words with a red underline and Gspell*View takes care of adding an extra contextual menu to correct the words through suggestions.
currently to add the features to a GtkTextView (also works with a GtkSourceView) you have to use the following code:
gspell_view = gspell_text_view_get_from_gtk_text_view (gtk_text_view); gspell_text_view_basic_setup (gspell_view); /* gspell_text_view_get_checker (gspell_view) */
The above code doesn’t seem very intuitive to me. My proposal would be something like:
gspell_checker = gspell_checker_new (...); gspell_text_view = gspell_text_view_new (); gspell_text_view_set_checker (gspell_checker) /* or gspell_text_view_new_from_checker (gspell_checker) */ gspell_text_view_attach_view (gtk_text_view) /* and gspell_text_view_dettach_view (gtk_text_view) */
GspellEntry and GspellEntryBuffer they would be eliminated due to the difficulty in highlighting and and getting the position of the cursor on the widget. Besides, I don’t see much use for spell checking in this type of widget that is used for simple things.
Instead of a GtkEntry you could use a GtkText with a GtkTextBuffer for highlighting (you could pass a GspellTextBuffer as a buffer) but there would also be the problem of getting the cursor position on the widget.
Also don’t think it is necessary to include the GspellLanguageChooserDialog and GspellCheckerDialog widgets in the library and they would become examples to use the library.
I appreciate any new idea or correction to my proposal.
I also created a room in matrix.to in case they want to talk there: #gspell:matrix.org