[gnome-builder] editor: handle IdeSourceView::focus-location action



commit 57c44665212285aa50a56b612c79bb15f4171a08
Author: Christian Hergert <christian hergert me>
Date:   Fri Mar 27 17:20:32 2015 -0700

    editor: handle IdeSourceView::focus-location action
    
    This will open the sourcelocation specified and jump to the given
    line/line-offset.
    
    (However, scrolling madness in gtktextview is still making this not
    show up at the target location sometimes).
    
    And yes, ctrl+] should now work (in vim mode).

 src/editor/gb-editor-frame.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-editor-frame.c b/src/editor/gb-editor-frame.c
index e6a9d21..461e33f 100644
--- a/src/editor/gb-editor-frame.c
+++ b/src/editor/gb-editor-frame.c
@@ -25,6 +25,7 @@
 #include "gb-editor-frame-actions.h"
 #include "gb-editor-frame-private.h"
 #include "gb-string.h"
+#include "gb-view-stack.h"
 #include "gb-widget.h"
 
 G_DEFINE_TYPE (GbEditorFrame, gb_editor_frame, GTK_TYPE_BIN)
@@ -399,6 +400,22 @@ gb_editor_frame__source_view_focus_in_event (GbEditorFrame *self,
 }
 
 static void
+gb_editor_frame__source_view_focus_location (GbEditorFrame     *self,
+                                             IdeSourceLocation *location,
+                                             IdeSourceView     *source_view)
+{
+  GtkWidget *widget = (GtkWidget *)self;
+
+  g_assert (GB_IS_EDITOR_FRAME (self));
+  g_assert (location != NULL);
+  g_assert (IDE_IS_SOURCE_VIEW (source_view));
+
+  for (; widget && !GB_IS_VIEW_STACK (widget); widget = gtk_widget_get_parent (widget)) { }
+  if (widget && GB_IS_VIEW_STACK (widget))
+    gb_view_stack_focus_location (GB_VIEW_STACK (widget), location);
+}
+
+static void
 gb_editor_frame__source_view_request_documentation (GbEditorFrame *self,
                                                     IdeSourceView *source_view)
 {
@@ -439,6 +456,12 @@ gb_editor_frame_constructed (GObject *object)
                            G_CONNECT_SWAPPED);
 
   g_signal_connect_object (self->source_view,
+                           "focus-location",
+                           G_CALLBACK (gb_editor_frame__source_view_focus_location),
+                           self,
+                           G_CONNECT_SWAPPED);
+
+  g_signal_connect_object (self->source_view,
                            "request-documentation",
                            G_CALLBACK (gb_editor_frame__source_view_request_documentation),
                            self,


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