[gtk/wip/chergert/spellcheck] textview: check spelling for visible region
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/spellcheck] textview: check spelling for visible region
- Date: Tue, 30 Mar 2021 04:37:03 +0000 (UTC)
commit bb7f114b2557b1723bd2f6af7ec2643473d13b10
Author: Christian Hergert <chergert redhat com>
Date: Mon Mar 29 21:36:18 2021 -0700
textview: check spelling for visible region
gtk/gtktextview.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
---
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 33c40d3555..3350031f1c 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -42,6 +42,7 @@
#include "gtktextiterprivate.h"
#include "gtkimmulticontext.h"
#include "gtkprivate.h"
+#include "gtktextbufferprivate.h"
#include "gtktextutil.h"
#include "gtkwidgetprivate.h"
#include "gtkwindow.h"
@@ -8068,6 +8069,26 @@ gtk_text_view_drag_drop (GtkDropTarget *dest,
return TRUE;
}
+static void
+gtk_text_view_check_spelling (GtkTextView *text_view)
+{
+ GtkTextIter begin, end;
+ GdkRectangle visible;
+
+ g_assert (GTK_IS_TEXT_VIEW (text_view));
+
+ if (!_gtk_text_buffer_can_check_spelling (text_view->priv->buffer))
+ return;
+
+ gtk_text_view_get_visible_rect (text_view, &visible);
+ gtk_text_view_get_iter_at_location (text_view, &begin, visible.x, visible.y);
+ gtk_text_view_get_iter_at_location (text_view, &end,
+ visible.x + visible.width,
+ visible.y + visible.height);
+
+ _gtk_text_buffer_check_spelling (text_view->priv->buffer, &begin, &end);
+}
+
static void
gtk_text_view_set_hadjustment (GtkTextView *text_view,
GtkAdjustment *adjustment)
@@ -8286,6 +8307,8 @@ gtk_text_view_value_changed (GtkAdjustment *adjustment,
gtk_text_view_update_handles (text_view);
+ gtk_text_view_check_spelling (text_view);
+
if (priv->anchored_children.length > 0)
gtk_widget_queue_allocate (GTK_WIDGET (text_view));
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]