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



commit 63b73ba798581e3d57f41bfa05ce2550c896b29f
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]