[gnome-builder/wip/slaf/spellcheck-sidebar: 28/33] spellchecker: replicate the misspelled word in dict entry



commit b54e5db84334d6b882da848753a93713d23cf1aa
Author: Sébastien Lafargue <slafargue gnome org>
Date:   Tue Jan 10 22:37:04 2017 +0100

    spellchecker: replicate the misspelled word in dict entry
    
    This way it's easier to add a new word to the
    personal dictionary
    
    If you check a word, it's copied too the dict entry
    
    If you edit the change_to entry, then it's copied
    to the dict entry

 libide/editor/ide-editor-spell-widget.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/libide/editor/ide-editor-spell-widget.c b/libide/editor/ide-editor-spell-widget.c
index 4225f67..9f6e26e 100644
--- a/libide/editor/ide-editor-spell-widget.c
+++ b/libide/editor/ide-editor-spell-widget.c
@@ -354,11 +354,22 @@ static void
 ide_editor_spell_widget__word_entry_changed_cb (IdeEditorSpellWidget *self,
                                                 GtkEntry             *entry)
 {
+  const gchar *word;
+
   g_assert (IDE_IS_EDITOR_SPELL_WIDGET (self));
   g_assert (GTK_IS_ENTRY (entry));
 
   update_change_ignore_sensibility (self);
 
+  word = gtk_entry_get_text (self->word_entry);
+  if (ide_str_empty0 (word))
+    {
+      word = gtk_label_get_text (self->word_label);
+      gtk_entry_set_text (GTK_ENTRY (self->dict_word_entry), word);
+    }
+  else
+    gtk_entry_set_text (GTK_ENTRY (self->dict_word_entry), word);
+
   if (self->check_word_state == CHECK_WORD_CHECKING)
     {
       self->is_check_word_invalid = TRUE;
@@ -456,8 +467,14 @@ ide_editor_spell_widget__row_selected_cb (IdeEditorSpellWidget *self,
     {
       label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (row)));
       word = gtk_label_get_text (label);
+
+      g_signal_handlers_block_by_func (self->word_entry, ide_editor_spell_widget__word_entry_changed_cb, 
self);
+
       gtk_entry_set_text (self->word_entry, word);
       gtk_editable_set_position (GTK_EDITABLE (self->word_entry), -1);
+      update_change_ignore_sensibility (self);
+
+      g_signal_handlers_unblock_by_func (self->word_entry, ide_editor_spell_widget__word_entry_changed_cb, 
self);
     }
 }
 
@@ -914,8 +931,14 @@ ide_editor_spell_widget__word_entry_suggestion_activate (IdeEditorSpellWidget *s
   g_assert (GTK_IS_MENU_ITEM (item));
 
   word = g_object_get_data (G_OBJECT (item), "word");
+
+  g_signal_handlers_block_by_func (self->word_entry, ide_editor_spell_widget__word_entry_changed_cb, self);
+
   gtk_entry_set_text (self->word_entry, word);
   gtk_editable_set_position (GTK_EDITABLE (self->word_entry), -1);
+  update_change_ignore_sensibility (self);
+
+  g_signal_handlers_unblock_by_func (self->word_entry, ide_editor_spell_widget__word_entry_changed_cb, self);
 }
 
 static void
@@ -1068,6 +1091,10 @@ ide_editor_spell_widget_constructed (GObject *object)
                            G_CALLBACK (ide_editor_spell__widget_mapped_cb),
                            NULL,
                            G_CONNECT_AFTER);
+
+  g_object_bind_property (self->word_label, "label",
+                          self->dict_word_entry, "text",
+                          G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
 }
 
 static void


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