[gspell/wip/entry-context-menu] Entry: save click position on popup-menu
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell/wip/entry-context-menu] Entry: save click position on popup-menu
- Date: Fri, 25 Nov 2016 13:40:31 +0000 (UTC)
commit ef27080c4566fc25497d808d385bd65455563e4f
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Nov 25 14:37:46 2016 +0100
Entry: save click position on popup-menu
gspell/gspell-entry.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/gspell/gspell-entry.c b/gspell/gspell-entry.c
index 13d1a43..2034c1d 100644
--- a/gspell/gspell-entry.c
+++ b/gspell/gspell-entry.c
@@ -48,6 +48,9 @@ struct _GspellEntry
*/
GSList *misspelled_words;
+ /* The position is in characters, not in bytes. */
+ gint click_char_position;
+
gulong notify_attributes_handler_id;
guint notify_attributes_idle_id;
@@ -416,6 +419,18 @@ notify_buffer_cb (GtkEntry *gtk_entry,
emit_changed_signal (gspell_entry);
}
+static gboolean
+popup_menu_cb (GtkEntry *gtk_entry,
+ GspellEntry *gspell_entry)
+{
+ /* Save the click position before popping up the menu, otherwise it will
+ * contain the wrong set of suggestions.
+ */
+ gspell_entry->click_char_position = gtk_editable_get_position (GTK_EDITABLE (gtk_entry));
+
+ return FALSE;
+}
+
static void
set_entry (GspellEntry *gspell_entry,
GtkEntry *gtk_entry)
@@ -447,6 +462,11 @@ set_entry (GspellEntry *gspell_entry,
G_CALLBACK (notify_attributes_cb),
gspell_entry);
+ g_signal_connect (gtk_entry,
+ "popup-menu",
+ G_CALLBACK (popup_menu_cb),
+ gspell_entry);
+
update_buffer (gspell_entry);
g_object_notify (G_OBJECT (gspell_entry), "entry");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]