[gtksourceview] buffer: add internal API to block cursor-moved signal emission
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] buffer: add internal API to block cursor-moved signal emission
- Date: Mon, 1 Aug 2022 20:33:23 +0000 (UTC)
commit 542789cc5fcb5ccfe9a54e1eb8c181904d0565b0
Author: Christian Hergert <chergert redhat com>
Date: Mon Aug 1 13:23:26 2022 -0700
buffer: add internal API to block cursor-moved signal emission
This can be useful in coordinating objects so that we can disable
extraneous emission during buffer intensive operations.
gtksourceview/gtksourcebuffer-private.h | 4 ++++
gtksourceview/gtksourcebuffer.c | 35 +++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+)
---
diff --git a/gtksourceview/gtksourcebuffer-private.h b/gtksourceview/gtksourcebuffer-private.h
index 96558894..644f4721 100644
--- a/gtksourceview/gtksourcebuffer-private.h
+++ b/gtksourceview/gtksourcebuffer-private.h
@@ -75,5 +75,9 @@ GTK_SOURCE_INTERNAL
GtkTextTag *_gtk_source_buffer_get_snippet_focus_tag (GtkSourceBuffer *buffer);
GTK_SOURCE_INTERNAL
gint64 _gtk_source_buffer_get_insertion_count (GtkSourceBuffer *buffer);
+GTK_SOURCE_INTERNAL
+void _gtk_source_buffer_block_cursor_moved (GtkSourceBuffer *buffer);
+GTK_SOURCE_INTERNAL
+void _gtk_source_buffer_unblock_cursor_moved (GtkSourceBuffer *buffer);
G_END_DECLS
diff --git a/gtksourceview/gtksourcebuffer.c b/gtksourceview/gtksourcebuffer.c
index de4fba49..cbb1ed76 100644
--- a/gtksourceview/gtksourcebuffer.c
+++ b/gtksourceview/gtksourcebuffer.c
@@ -163,6 +163,8 @@ typedef struct
gint64 insertion_count;
+ guint cursor_moved_block_count;
+
guint has_draw_spaces_tag : 1;
guint highlight_syntax : 1;
guint highlight_brackets : 1;
@@ -1030,6 +1032,13 @@ queue_bracket_highlighting_update (GtkSourceBuffer *buffer)
static void
cursor_moved (GtkSourceBuffer *buffer)
{
+ GtkSourceBufferPrivate *priv = gtk_source_buffer_get_instance_private (buffer);
+
+ if (priv->cursor_moved_block_count > 0)
+ {
+ return;
+ }
+
queue_bracket_highlighting_update (buffer);
GTK_SOURCE_PROFILER_BEGIN_MARK;
@@ -3071,3 +3080,29 @@ _gtk_source_buffer_get_insertion_count (GtkSourceBuffer *buffer)
return priv->insertion_count;
}
+
+void
+_gtk_source_buffer_block_cursor_moved (GtkSourceBuffer *buffer)
+{
+ GtkSourceBufferPrivate *priv = gtk_source_buffer_get_instance_private (buffer);
+
+ g_return_if_fail (GTK_SOURCE_IS_BUFFER (buffer));
+
+ priv->cursor_moved_block_count++;
+}
+
+void
+_gtk_source_buffer_unblock_cursor_moved (GtkSourceBuffer *buffer)
+{
+ GtkSourceBufferPrivate *priv = gtk_source_buffer_get_instance_private (buffer);
+
+ g_return_if_fail (GTK_SOURCE_IS_BUFFER (buffer));
+ g_return_if_fail (priv->cursor_moved_block_count > 0);
+
+ priv->cursor_moved_block_count--;
+
+ if (priv->cursor_moved_block_count == 0)
+ {
+ cursor_moved (buffer);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]