[gnome-builder/wip/chergert/layout] spellcheck: add begin/end pairs to view



commit a3350457cf3314b205d2d72f382cee71dca280a8
Author: Christian Hergert <chergert redhat com>
Date:   Sun Jul 16 13:47:58 2017 -0700

    spellcheck: add begin/end pairs to view
    
    This API is meant to be called by the spell widget to enable or
    disable checking on the textview and buffer. The goal here is to
    dynamically enable buffer features when necessary.

 plugins/spellcheck/gbp-spell-editor-view-addin.c |   54 ++++++++++++++++++++++
 plugins/spellcheck/gbp-spell-editor-view-addin.h |    3 +
 2 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/plugins/spellcheck/gbp-spell-editor-view-addin.c 
b/plugins/spellcheck/gbp-spell-editor-view-addin.c
index 7fd7085..a1adc53 100644
--- a/plugins/spellcheck/gbp-spell-editor-view-addin.c
+++ b/plugins/spellcheck/gbp-spell-editor-view-addin.c
@@ -105,3 +105,57 @@ static void
 gbp_spell_editor_view_addin_init (GbpSpellEditorViewAddin *self)
 {
 }
+
+/**
+ * gbp_spell_editor_view_addin_begin_checking:
+ * @self: a #GbpSpellEditorViewAddin
+ *
+ * This function should be called by the #GbpSpellWidget to enable
+ * spellchecking on the textview and underlying buffer. Doing so allows the
+ * inline-spellchecking and language-menu to be dynamically enabled even if
+ * spellchecking is typically disabled in the buffer.
+ *
+ * The caller should call gbp_spell_editor_view_addin_end_checking() when they
+ * have completed the spellchecking process.
+ *
+ * Since: 3.26
+ */
+void
+gbp_spell_editor_view_addin_begin_checking (GbpSpellEditorViewAddin *self)
+{
+  GObject *buffer_addin;
+
+  g_return_if_fail (GBP_IS_SPELL_EDITOR_VIEW_ADDIN (self));
+
+  buffer_addin = dzl_binding_group_get_source (self->buffer_addin_bindings);
+
+  if (buffer_addin == NULL)
+    {
+      g_warning ("Attempt to start spellchecking after disposal");
+      return;
+    }
+
+  gbp_spell_buffer_addin_begin_checking (GBP_SPELL_BUFFER_ADDIN (buffer_addin));
+}
+
+/**
+ * gbp_spell_editor_view_addin_end_checking:
+ * @self: a #GbpSpellEditorViewAddin
+ *
+ * Completes a spellcheck operation and potentially restores the buffer to
+ * the visual state before spellchecking started.
+ *
+ * Since: 3.26
+ */
+void
+gbp_spell_editor_view_addin_end_checking (GbpSpellEditorViewAddin *self)
+{
+  GObject *buffer_addin;
+
+  g_return_if_fail (GBP_IS_SPELL_EDITOR_VIEW_ADDIN (self));
+
+  buffer_addin = dzl_binding_group_get_source (self->buffer_addin_bindings);
+
+  if (GBP_IS_SPELL_BUFFER_ADDIN (buffer_addin))
+    gbp_spell_buffer_addin_end_checking (GBP_SPELL_BUFFER_ADDIN (buffer_addin));
+}
diff --git a/plugins/spellcheck/gbp-spell-editor-view-addin.h 
b/plugins/spellcheck/gbp-spell-editor-view-addin.h
index 4b2aa14..f94a632 100644
--- a/plugins/spellcheck/gbp-spell-editor-view-addin.h
+++ b/plugins/spellcheck/gbp-spell-editor-view-addin.h
@@ -26,4 +26,7 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (GbpSpellEditorViewAddin, gbp_spell_editor_view_addin, GBP, SPELL_EDITOR_VIEW_ADDIN, 
GObject)
 
+void gbp_spell_editor_view_addin_begin_checking (GbpSpellEditorViewAddin *self);
+void gbp_spell_editor_view_addin_end_checking   (GbpSpellEditorViewAddin *self);
+
 G_END_DECLS


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