[gspell/wip/entry: 3/7] Entry: recheck all when buffer changes
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell/wip/entry: 3/7] Entry: recheck all when buffer changes
- Date: Sun, 30 Oct 2016 17:43:48 +0000 (UTC)
commit 8350c2b2dff56610c896130f38038c449e68a7cd
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Oct 30 15:31:33 2016 +0100
Entry: recheck all when buffer changes
With unit test.
gspell/gspell-entry.c | 13 +++++++++++++
testsuite/test-entry.c | 29 +++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/gspell/gspell-entry.c b/gspell/gspell-entry.c
index 3c21f94..4cacba3 100644
--- a/gspell/gspell-entry.c
+++ b/gspell/gspell-entry.c
@@ -281,6 +281,14 @@ emit_changed_signal (GspellEntry *gspell_entry)
g_signal_emit_by_name (gspell_entry->entry, "changed");
}
+static void
+notify_buffer_cb (GtkEntry *gtk_entry,
+ GParamSpec *pspec,
+ GspellEntry *gspell_entry)
+{
+ emit_changed_signal (gspell_entry);
+}
+
static gboolean
notify_attributes_idle_cb (gpointer user_data)
{
@@ -330,6 +338,11 @@ set_entry (GspellEntry *gspell_entry,
G_CALLBACK (changed_after_cb),
gspell_entry);
+ g_signal_connect (gtk_entry,
+ "notify::buffer",
+ G_CALLBACK (notify_buffer_cb),
+ gspell_entry);
+
g_assert (gspell_entry->notify_attributes_handler_id == 0);
gspell_entry->notify_attributes_handler_id =
g_signal_connect (gtk_entry,
diff --git a/testsuite/test-entry.c b/testsuite/test-entry.c
index aea8514..55baad2 100644
--- a/testsuite/test-entry.c
+++ b/testsuite/test-entry.c
@@ -204,6 +204,34 @@ test_inline_spell_checking_property (void)
g_object_unref (gtk_entry);
}
+static void
+test_buffer_change (void)
+{
+ GtkEntry *gtk_entry;
+ GtkEntryBuffer *other_buffer;
+ GspellEntry *gspell_entry;
+ GSList *expected_list;
+ const GSList *received_list;
+
+ gtk_entry = create_entry ();
+ gspell_entry = gspell_entry_get_from_gtk_entry (gtk_entry);
+
+ gtk_entry_set_text (gtk_entry, "auienrst");
+ expected_list = add_word (NULL, "auienrst", 0, 8);
+ received_list = _gspell_entry_get_misspelled_words (gspell_entry);
+ check_entry_word_list_equal (expected_list, received_list);
+ free_word_list (expected_list);
+
+ other_buffer = gtk_entry_buffer_new (NULL, -1);
+ gtk_entry_set_buffer (gtk_entry, other_buffer);
+ g_object_unref (other_buffer);
+ expected_list = NULL;
+ received_list = _gspell_entry_get_misspelled_words (gspell_entry);
+ check_entry_word_list_equal (expected_list, received_list);
+
+ g_object_unref (gtk_entry);
+}
+
gint
main (gint argc,
gchar **argv)
@@ -212,6 +240,7 @@ main (gint argc,
g_test_add_func ("/entry-utils/get-words", test_get_words);
g_test_add_func ("/entry/inline-spell-checking-property", test_inline_spell_checking_property);
+ g_test_add_func ("/entry/buffer-change", test_buffer_change);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]