[gnome-builder/wip/slaf/spellcheck-sidebar: 30/33] spellchecker: be able to re-check a word
- From: Sébastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/slaf/spellcheck-sidebar: 30/33] spellchecker: be able to re-check a word
- Date: Wed, 11 Jan 2017 20:49:21 +0000 (UTC)
commit fe0a936c6405c62015ece64a3f175878f027fe26
Author: Sébastien Lafargue <slafargue gnome org>
Date: Wed Jan 11 17:30:58 2017 +0100
spellchecker: be able to re-check a word
When changing language, we need to re-check the current word.
This patch add a new IdeEditorSpellNavigator method:
ide_editor_spell_navigator_goto_word_start
libide/editor/ide-editor-spell-navigator.c | 21 +++++++++++++++++++++
libide/editor/ide-editor-spell-navigator.h | 1 +
libide/editor/ide-editor-spell-widget.c | 3 +++
3 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/libide/editor/ide-editor-spell-navigator.c b/libide/editor/ide-editor-spell-navigator.c
index 8282dfd..e3474f3 100644
--- a/libide/editor/ide-editor-spell-navigator.c
+++ b/libide/editor/ide-editor-spell-navigator.c
@@ -409,6 +409,27 @@ select_misspelled_word (IdeEditorSpellNavigator *self)
0.0);
}
+/* Go to the start of the current checked word so that
+ * we can re-check it again, change of language for example
+ */
+gboolean
+ide_editor_spell_navigator_goto_word_start (IdeEditorSpellNavigator *self)
+{
+ GtkTextIter start;
+
+ g_assert (IDE_IS_EDITOR_SPELL_NAVIGATOR (self));
+
+ if (self->word_start != NULL)
+ {
+ gtk_text_buffer_get_iter_at_mark (self->buffer, &start, self->word_start);
+ gtk_text_buffer_move_mark (self->buffer, self->word_end, &start);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static gboolean
ide_editor_spell_navigator_goto_next (GspellNavigator *navigator,
gchar **word_p,
diff --git a/libide/editor/ide-editor-spell-navigator.h b/libide/editor/ide-editor-spell-navigator.h
index 4081832..0a85797 100644
--- a/libide/editor/ide-editor-spell-navigator.h
+++ b/libide/editor/ide-editor-spell-navigator.h
@@ -32,6 +32,7 @@ GspellNavigator *ide_editor_spell_navigator_new (GtkTextView
guint ide_editor_spell_navigator_get_count (IdeEditorSpellNavigator *self,
const gchar *word);
gboolean ide_editor_spell_navigator_get_is_words_counted (IdeEditorSpellNavigator *self);
+gboolean ide_editor_spell_navigator_goto_word_start (IdeEditorSpellNavigator *self);
G_END_DECLS
diff --git a/libide/editor/ide-editor-spell-widget.c b/libide/editor/ide-editor-spell-widget.c
index 95c9237..5518c33 100644
--- a/libide/editor/ide-editor-spell-widget.c
+++ b/libide/editor/ide-editor-spell-widget.c
@@ -884,6 +884,9 @@ ide_editor_spell_widget__language_notify_cb (IdeEditorSpellWidget *self,
ide_editor_spell_widget__dict_word_entry_changed_cb (self, GTK_ENTRY (self->dict_word_entry));
gtk_widget_set_sensitive (GTK_WIDGET (self->dict_words_list), TRUE);
+
+ ide_editor_spell_navigator_goto_word_start (IDE_EDITOR_SPELL_NAVIGATOR (self->navigator));
+ jump_to_next_misspelled_word (self);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]