[gnome-builder/wip/chergert/layout: 87/118] editor: update cursor position when document changes



commit 53d9727505bdae6419547ddb37bdbcc588ea3e04
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jul 3 04:03:16 2017 -0700

    editor: update cursor position when document changes

 libide/editor/ide-editor-layout-stack-controls.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/libide/editor/ide-editor-layout-stack-controls.c 
b/libide/editor/ide-editor-layout-stack-controls.c
index b553226..0ad0d8a 100644
--- a/libide/editor/ide-editor-layout-stack-controls.c
+++ b/libide/editor/ide-editor-layout-stack-controls.c
@@ -198,6 +198,21 @@ warning_button_clicked (IdeEditorLayoutStackControls *self,
 }
 
 static void
+ide_editor_layout_stack_controls_bind (IdeEditorLayoutStackControls *self,
+                                       GtkTextBuffer                *buffer,
+                                       DzlSignalGroup               *buffer_signals)
+{
+  GtkTextIter iter;
+
+  g_assert (IDE_IS_EDITOR_LAYOUT_STACK_CONTROLS (self));
+  g_assert (IDE_IS_BUFFER (buffer));
+  g_assert (DZL_IS_SIGNAL_GROUP (buffer_signals));
+
+  gtk_text_buffer_get_iter_at_mark (buffer, &iter, gtk_text_buffer_get_insert (buffer));
+  document_cursor_moved (self, &iter, buffer);
+}
+
+static void
 ide_editor_layout_stack_controls_finalize (GObject *object)
 {
   IdeEditorLayoutStackControls *self = (IdeEditorLayoutStackControls *)object;
@@ -264,6 +279,11 @@ ide_editor_layout_stack_controls_init (IdeEditorLayoutStackControls *self)
 
   self->buffer_signals = dzl_signal_group_new (IDE_TYPE_BUFFER);
 
+  g_signal_connect_swapped (self->buffer_signals,
+                            "bind",
+                            G_CALLBACK (ide_editor_layout_stack_controls_bind),
+                            self);
+
   dzl_signal_group_connect_object (self->buffer_signals,
                                    "cursor-moved",
                                    G_CALLBACK (document_cursor_moved),


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