[gedit] gedit spell plugin: select first mispelled word
- From: Sebastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] gedit spell plugin: select first mispelled word
- Date: Fri, 19 Dec 2014 13:58:01 +0000 (UTC)
commit ffbaed1d46b103dcd8922b2941fa9c48766af5cc
Author: Stalin Pereira <letter2stalin gmail com>
Date: Fri Dec 19 14:52:36 2014 +0100
gedit spell plugin: select first mispelled word
First mispelled word was not selected because the focus was stolen by the "Check spelling" dialog.
Change get_next_misspelled_word signature to get the word start and end
Refactor the selection of the word
Select the word after showing the dialog and
after each next words.
https://bugzilla.gnome.org/show_bug.cgi?id=650829
plugins/spell/gedit-spell-plugin.c | 43 ++++++++++++++++++++++++++----------
1 files changed, 31 insertions(+), 12 deletions(-)
---
diff --git a/plugins/spell/gedit-spell-plugin.c b/plugins/spell/gedit-spell-plugin.c
index 125fbf7..feea69a 100644
--- a/plugins/spell/gedit-spell-plugin.c
+++ b/plugins/spell/gedit-spell-plugin.c
@@ -467,7 +467,7 @@ goto_next_word (GeditDocument *doc)
}
static gchar *
-get_next_misspelled_word (GeditView *view)
+get_next_misspelled_word (GeditView *view, gint *word_start_offset, gint *word_end_offset)
{
GeditDocument *doc;
CheckRange *range;
@@ -512,42 +512,56 @@ get_next_misspelled_word (GeditView *view)
if (word != NULL)
{
- GtkTextIter s, e;
-
range->mw_start = start;
range->mw_end = end;
+ *word_start_offset = start;
+ *word_end_offset = end;
gedit_debug_message (DEBUG_PLUGINS, "Select [%d, %d]", start, end);
-
- gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &s, start);
- gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &e, end);
-
- gtk_text_buffer_select_range (GTK_TEXT_BUFFER (doc), &s, &e);
-
- gedit_view_scroll_to_cursor (view);
}
else
{
range->mw_start = -1;
range->mw_end = -1;
+ *word_start_offset = -1;
+ *word_end_offset = -1;
}
return word;
}
static void
+select_misspelled_word (GeditView *view,
+ gint word_start_offset,
+ gint word_end_offset)
+{
+ GeditDocument *doc;
+ GtkTextIter word_start_iter, word_end_iter;
+
+ doc = GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+
+ gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &word_start_iter, word_start_offset);
+ gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &word_end_iter, word_end_offset);
+
+ gtk_text_buffer_select_range (GTK_TEXT_BUFFER (doc), &word_start_iter, &word_end_iter);
+
+ gedit_view_scroll_to_cursor (view);
+}
+
+static void
ignore_cb (GeditSpellCheckerDialog *dlg,
const gchar *w,
GeditView *view)
{
gchar *word = NULL;
+ gint word_start_offset, word_end_offset;
gedit_debug (DEBUG_PLUGINS);
g_return_if_fail (w != NULL);
g_return_if_fail (view != NULL);
- word = get_next_misspelled_word (view);
+ word = get_next_misspelled_word (view, &word_start_offset, &word_end_offset);
if (word == NULL)
{
gedit_spell_checker_dialog_set_completed (dlg);
@@ -555,6 +569,8 @@ ignore_cb (GeditSpellCheckerDialog *dlg,
return;
}
+ select_misspelled_word (view, word_start_offset, word_end_offset);
+
gedit_spell_checker_dialog_set_misspelled_word (GEDIT_SPELL_CHECKER_DIALOG (dlg),
word,
-1);
@@ -765,6 +781,7 @@ spell_cb (GSimpleAction *action,
GeditSpellChecker *spell;
GtkWidget *dlg;
GtkTextIter start, end;
+ gint word_start_offset, word_end_offset;
gchar *word;
gchar *data_dir;
@@ -805,7 +822,7 @@ spell_cb (GSimpleAction *action,
set_check_range (doc, &start, &end);
- word = get_next_misspelled_word (view);
+ word = get_next_misspelled_word (view, &word_start_offset, &word_end_offset);
if (word == NULL)
{
GtkWidget *statusbar;
@@ -840,6 +857,8 @@ spell_cb (GSimpleAction *action,
g_free (word);
gtk_widget_show (dlg);
+ select_misspelled_word (view, word_start_offset, word_end_offset);
+
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]