[gspell/wip/inline-checker-gtv] inline-checker-gtv: listen to no-spell-check tag added/removed



commit a2c55ca86365fe31a8b60b1cd01caf9ef7545f94
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Dec 13 14:56:49 2015 +0100

    inline-checker-gtv: listen to no-spell-check tag added/removed

 gspell/gspell-inline-checker-gtv.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/gspell/gspell-inline-checker-gtv.c b/gspell/gspell-inline-checker-gtv.c
index 780560b..8518fb6 100644
--- a/gspell/gspell-inline-checker-gtv.c
+++ b/gspell/gspell-inline-checker-gtv.c
@@ -58,6 +58,7 @@ struct _GspellInlineCheckerGtv
        GSList *views;
 
        GtkTextTag *highlight_tag;
+       GtkTextTag *no_spell_check_tag;
 
        GtkTextMark *mark_click;
 
@@ -820,7 +821,22 @@ tag_added_cb (GtkTextTagTable        *table,
              GtkTextTag             *tag,
              GspellInlineCheckerGtv *spell)
 {
+       gchar *name;
+
        update_highlight_tag_priority (spell, table);
+
+       g_object_get (tag, "name", &name, NULL);
+
+       if (g_strcmp0 (name, "gtksourceview:context-classes:no-spell-check") == 0)
+       {
+               g_return_if_fail (spell->no_spell_check_tag == NULL);
+
+               spell->no_spell_check_tag = g_object_ref (tag);
+
+               recheck_all (spell);
+       }
+
+       g_free (name);
 }
 
 static void
@@ -832,6 +848,14 @@ tag_removed_cb (GtkTextTagTable        *table,
        {
                update_highlight_tag_priority (spell, table);
        }
+
+       if (spell->no_spell_check_tag != NULL &&
+           spell->no_spell_check_tag == tag)
+       {
+               g_clear_object (&spell->no_spell_check_tag);
+
+               recheck_all (spell);
+       }
 }
 
 static void
@@ -853,6 +877,7 @@ set_buffer (GspellInlineCheckerGtv *spell,
        g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
        g_return_if_fail (spell->buffer == NULL);
        g_return_if_fail (spell->highlight_tag == NULL);
+       g_return_if_fail (spell->no_spell_check_tag == NULL);
        g_return_if_fail (spell->mark_click == NULL);
 
        spell->buffer = g_object_ref (buffer);
@@ -878,6 +903,12 @@ set_buffer (GspellInlineCheckerGtv *spell,
                                                           NULL);
        g_object_ref (spell->highlight_tag);
 
+       spell->no_spell_check_tag = _gspell_utils_get_no_spell_check_tag (spell->buffer);
+       if (spell->no_spell_check_tag != NULL)
+       {
+               g_object_ref (spell->no_spell_check_tag);
+       }
+
        tag_table = gtk_text_buffer_get_tag_table (spell->buffer);
 
        g_signal_connect_object (tag_table,
@@ -1024,6 +1055,7 @@ gspell_inline_checker_gtv_dispose (GObject *object)
        }
 
        g_clear_object (&spell->highlight_tag);
+       g_clear_object (&spell->no_spell_check_tag);
        g_clear_object (&spell->spell_checker);
 
        g_slist_free_full (spell->views, g_object_unref);


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