[gspell/wip/current-word-policy] Entry: connect to ::move-cursor



commit 51e9a341fa4dc5ad424dc9a700ab77e1edf72ded
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed Dec 21 15:01:52 2016 +0100

    Entry: connect to ::move-cursor

 gspell/gspell-entry.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/gspell/gspell-entry.c b/gspell/gspell-entry.c
index 32296ad..d08336d 100644
--- a/gspell/gspell-entry.c
+++ b/gspell/gspell-entry.c
@@ -669,12 +669,11 @@ populate_popup_cb (GtkEntry    *gtk_entry,
 }
 
 static void
-cursor_position_notify_cb (GtkEntry    *gtk_entry,
-                          GParamSpec  *pspec,
-                          GspellEntry *gspell_entry)
+move_cursor_cb (GspellEntry *gspell_entry)
 {
        g_message ("%s", G_STRFUNC);
        _gspell_current_word_policy_cursor_moved (gspell_entry->current_word_policy);
+       emit_changed_signal (gspell_entry);
 }
 
 static gboolean
@@ -778,10 +777,16 @@ set_entry (GspellEntry *gspell_entry,
                                G_CALLBACK (populate_popup_cb),
                                gspell_entry);
 
-       g_signal_connect (gtk_entry,
-                         "notify::cursor-position",
-                         G_CALLBACK (cursor_position_notify_cb),
-                         gspell_entry);
+       /* Connecting to notify::cursor-position is not suitable because we have
+        * notifications also when text is inserted/deleted. And we get the
+        * notification *after* the GtkEditable::insert-text signal (not
+        * *during* its emission). So it's simpler to connect to ::move-cursor,
+        * even if it is not recommended.
+        */
+       g_signal_connect_swapped (gtk_entry,
+                                 "move-cursor",
+                                 G_CALLBACK (move_cursor_cb),
+                                 gspell_entry);
 
        g_signal_connect_after (GTK_EDITABLE (gtk_entry),
                                "insert-text",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]