[gspell/wip/fix-constant-redrawing: 2/2] inline-checker-text-buffer: fix constant redraw
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell/wip/fix-constant-redrawing: 2/2] inline-checker-text-buffer: fix constant redraw
- Date: Sat, 9 Jul 2016 11:58:19 +0000 (UTC)
commit 3cb4f0317766220c0237ae86b7858b804742a1f5
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Jul 9 13:56:19 2016 +0200
inline-checker-text-buffer: fix constant redraw
gspell/gspell-inline-checker-text-buffer.c | 76 +++++++++++++++++++++-------
1 files changed, 57 insertions(+), 19 deletions(-)
---
diff --git a/gspell/gspell-inline-checker-text-buffer.c b/gspell/gspell-inline-checker-text-buffer.c
index 2da0e00..fab18de 100644
--- a/gspell/gspell-inline-checker-text-buffer.c
+++ b/gspell/gspell-inline-checker-text-buffer.c
@@ -287,6 +287,49 @@ get_current_word_boundaries (GtkTextBuffer *buffer,
!gtk_text_iter_equal (current_word_end, &insert_iter));
}
+/* FIXME properly. Workaround for bug in GtkTextView:
+ * https://bugzilla.gnome.org/show_bug.cgi?id=763741
+ */
+static void
+hack_queue_draw (GtkTextView *view)
+{
+ if (view != NULL)
+ {
+ gtk_widget_queue_draw (GTK_WIDGET (view));
+ }
+}
+
+static void
+remove_tag_if_present (GtkTextView *view,
+ GtkTextBuffer *buffer,
+ GtkTextTag *tag,
+ const GtkTextIter *start,
+ const GtkTextIter *end)
+{
+ gboolean remove = FALSE;
+
+ if (gtk_text_iter_has_tag (start, tag))
+ {
+ remove = TRUE;
+ }
+ else
+ {
+ GtkTextIter iter = *start;
+
+ if (gtk_text_iter_forward_to_tag_toggle (&iter, tag) &&
+ gtk_text_iter_compare (&iter, end) < 0)
+ {
+ remove = TRUE;
+ }
+ }
+
+ if (remove)
+ {
+ gtk_text_buffer_remove_tag (buffer, tag, start, end);
+ hack_queue_draw (view);
+ }
+}
+
static void
check_visible_region_in_view (GspellInlineCheckerTextBuffer *spell,
GtkTextView *view)
@@ -315,8 +358,9 @@ check_visible_region_in_view (GspellInlineCheckerTextBuffer *spell,
&visible_start,
&visible_end);
- if (intersect == NULL)
+ if (_gspell_region_is_empty (intersect))
{
+ g_clear_object (&intersect);
return;
}
@@ -329,10 +373,11 @@ check_visible_region_in_view (GspellInlineCheckerTextBuffer *spell,
¤t_word_start,
¤t_word_end))
{
- gtk_text_buffer_remove_tag (spell->buffer,
- spell->highlight_tag,
- ¤t_word_start,
- ¤t_word_end);
+ remove_tag_if_present (view,
+ spell->buffer,
+ spell->highlight_tag,
+ ¤t_word_start,
+ ¤t_word_end);
_gspell_region_subtract (intersect,
¤t_word_start,
@@ -344,13 +389,13 @@ check_visible_region_in_view (GspellInlineCheckerTextBuffer *spell,
_gspell_region_add (spell->scan_region,
¤t_word_start,
¤t_word_end);
- }
- }
- if (_gspell_region_is_empty (intersect))
- {
- g_clear_object (&intersect);
- goto out;
+ if (_gspell_region_is_empty (intersect))
+ {
+ g_clear_object (&intersect);
+ return;
+ }
+ }
}
_gspell_region_get_start_region_iter (intersect, &intersect_iter);
@@ -391,14 +436,7 @@ check_visible_region_in_view (GspellInlineCheckerTextBuffer *spell,
g_clear_object (&spell->scan_region);
}
-out:
- if (view != NULL)
- {
- /* FIXME properly. Workaround for bug in GtkTextView:
- * https://bugzilla.gnome.org/show_bug.cgi?id=763741
- */
- gtk_widget_queue_draw (GTK_WIDGET (view));
- }
+ hack_queue_draw (view);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]