[gnome-builder/wip/gtk4-port: 526/736] plugins/spellcheck: add action to ignore word




commit fa881d715c84242e465ee0e79f53d949d3471197
Author: Christian Hergert <chergert redhat com>
Date:   Thu Apr 7 17:18:18 2022 -0700

    plugins/spellcheck: add action to ignore word

 src/plugins/spellcheck/gbp-spell-buffer-addin.c     | 17 +++++++++++++++++
 src/plugins/spellcheck/gbp-spell-buffer-addin.h     |  6 ++++--
 .../spellcheck/gbp-spell-editor-page-addin.c        | 21 +++++++++++++++++++++
 3 files changed, 42 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/spellcheck/gbp-spell-buffer-addin.c b/src/plugins/spellcheck/gbp-spell-buffer-addin.c
index c601555de..3f44d1f0f 100644
--- a/src/plugins/spellcheck/gbp-spell-buffer-addin.c
+++ b/src/plugins/spellcheck/gbp-spell-buffer-addin.c
@@ -163,3 +163,20 @@ gbp_spell_buffer_addin_add_word (GbpSpellBufferAddin *self,
 
   IDE_EXIT;
 }
+
+void
+gbp_spell_buffer_addin_ignore_word (GbpSpellBufferAddin *self,
+                                    const char          *word)
+{
+  IDE_ENTRY;
+
+  g_return_if_fail (GBP_IS_SPELL_BUFFER_ADDIN (self));
+
+  if (word == NULL || word[0] == 0)
+    IDE_EXIT;
+
+  editor_spell_checker_ignore_word (self->checker, word);
+  editor_text_buffer_spell_adapter_invalidate_all (self->adapter);
+
+  IDE_EXIT;
+}
diff --git a/src/plugins/spellcheck/gbp-spell-buffer-addin.h b/src/plugins/spellcheck/gbp-spell-buffer-addin.h
index dafcbc838..0a8dd86cc 100644
--- a/src/plugins/spellcheck/gbp-spell-buffer-addin.h
+++ b/src/plugins/spellcheck/gbp-spell-buffer-addin.h
@@ -28,7 +28,9 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (GbpSpellBufferAddin, gbp_spell_buffer_addin, GBP, SPELL_BUFFER_ADDIN, GObject)
 
-void gbp_spell_buffer_addin_add_word (GbpSpellBufferAddin *self,
-                                      const char          *word);
+void gbp_spell_buffer_addin_add_word    (GbpSpellBufferAddin *self,
+                                         const char          *word);
+void gbp_spell_buffer_addin_ignore_word (GbpSpellBufferAddin *self,
+                                         const char          *word);
 
 G_END_DECLS
diff --git a/src/plugins/spellcheck/gbp-spell-editor-page-addin.c 
b/src/plugins/spellcheck/gbp-spell-editor-page-addin.c
index 1c0a0b79a..2388216b0 100644
--- a/src/plugins/spellcheck/gbp-spell-editor-page-addin.c
+++ b/src/plugins/spellcheck/gbp-spell-editor-page-addin.c
@@ -57,8 +57,29 @@ gbp_spell_editor_page_addin_add (GSimpleAction *action,
   IDE_EXIT;
 }
 
+static void
+gbp_spell_editor_page_addin_ignore (GSimpleAction *action,
+                                    GVariant      *param,
+                                    gpointer       user_data)
+{
+  GbpSpellEditorPageAddin *self = user_data;
+  const char *word;
+
+  IDE_ENTRY;
+
+  g_assert (G_IS_SIMPLE_ACTION (action));
+  g_assert (param != NULL);
+  g_assert (g_variant_is_of_type (param, G_VARIANT_TYPE_STRING));
+
+  word = g_variant_get_string (param, NULL);
+  gbp_spell_buffer_addin_ignore_word (self->buffer_addin, word);
+
+  IDE_EXIT;
+}
+
 static const GActionEntry actions[] = {
   { "add", gbp_spell_editor_page_addin_add, "s" },
+  { "ignore", gbp_spell_editor_page_addin_ignore, "s" },
 };
 
 static void


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