[gtksourceview/wip/chergert/gsv-gtk4: 84/84] buffer: add GtkSourceBuffer::cursor-moved signal



commit 0953a117d62d6aceb9ecd99bb054b2fd0f5d84cd
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 15 15:44:55 2020 -0800

    buffer: add GtkSourceBuffer::cursor-moved signal
    
    This is commonly implemented in subclasses, so it seems reasonable to add
    it upstream within GtkSourceBuffer directly now that it will not collide
    with subclasses.

 gtksourceview/gtksourcebuffer.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
---
diff --git a/gtksourceview/gtksourcebuffer.c b/gtksourceview/gtksourcebuffer.c
index d98d34fe..f95ef646 100644
--- a/gtksourceview/gtksourcebuffer.c
+++ b/gtksourceview/gtksourcebuffer.c
@@ -136,6 +136,7 @@
 
 enum
 {
+       CURSOR_MOVED,
        HIGHLIGHT_UPDATED,
        SOURCE_MARK_UPDATED,
        UNDO,
@@ -370,6 +371,21 @@ gtk_source_buffer_class_init (GtkSourceBufferClass *klass)
 
        g_object_class_install_properties (object_class, N_PROPERTIES, buffer_properties);
 
+       /**
+        * GtkSourceBuffer::cursor-moved:
+        * @buffer: a #GtkSourceBuffer
+        *
+        * The "cursor-moved" signal is emitted when then insertion mark has moved.
+        *
+        * Since: 5.0
+        */
+       buffer_signals[CURSOR_MOVED] =
+               g_signal_new_class_handler ("cursor-moved",
+                                           G_OBJECT_CLASS_TYPE (object_class),
+                                           G_SIGNAL_RUN_LAST,
+                                           NULL, NULL, NULL, NULL,
+                                           G_TYPE_NONE, 0);
+
        /**
         * GtkSourceBuffer::highlight-updated:
         * @buffer: the buffer that received the signal
@@ -971,6 +987,8 @@ static void
 cursor_moved (GtkSourceBuffer *buffer)
 {
        queue_bracket_highlighting_update (buffer);
+
+       g_signal_emit (buffer, buffer_signals[CURSOR_MOVED], 0);
 }
 
 static void


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