[gnome-builder] sourceview: add IdeSourceView::focus-location gsignal



commit c3098935cbb47219a018e05e039be155077a9ec1
Author: Christian Hergert <christian hergert me>
Date:   Fri Mar 27 17:19:04 2015 -0700

    sourceview: add IdeSourceView::focus-location gsignal
    
    This signal is emitted when the sourceview has determined that it needs
    to jump to a new source location. This could happen after resolving
    a type that we'd like to jump to, or a multitude of things we haven't
    thought about yet.
    
    This is also subject to change, but makes forward progress.

 libide/ide-source-view.c |   31 ++++++++++++++++++++++++++++++-
 libide/ide-source-view.h |    1 +
 2 files changed, 31 insertions(+), 1 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 3969583..ecdfc46 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -207,6 +207,7 @@ enum {
   DELETE_SELECTION,
   END_MACRO,
   END_USER_ACTION,
+  FOCUS_LOCATION,
   GOTO_DEFINITION,
   HIDE_COMPLETION,
   INDENT_SELECTION,
@@ -4409,6 +4410,7 @@ ide_source_view_goto_definition_symbol_cb (GObject      *object,
   g_autoptr(IdeSourceView) self = user_data;
   g_autoptr(IdeSymbol) symbol = NULL;
   g_autoptr(GError) error = NULL;
+  IdeSourceLocation *srcloc;
 
   g_assert (IDE_IS_BUFFER (buffer));
   g_assert (IDE_IS_SOURCE_VIEW (self));
@@ -4421,7 +4423,23 @@ ide_source_view_goto_definition_symbol_cb (GObject      *object,
       return;
     }
 
-  g_print ("Symbol: %s\n", ide_symbol_get_name (symbol));
+  srcloc = ide_symbol_get_definition_location (symbol);
+
+  if (srcloc != NULL)
+    {
+#ifndef IDE_DISABLE_TRACE
+      guint line = ide_source_location_get_line (srcloc);
+      guint line_offset = ide_source_location_get_line_offset (srcloc);
+      IdeFile *file = ide_source_location_get_file (srcloc);
+      const gchar *filename = ide_file_get_path (file);
+
+      IDE_TRACE_MSG ("%s => %s +%u:%u",
+                     ide_symbol_get_name (symbol),
+                     filename, line+1, line_offset+1);
+#endif
+
+      g_signal_emit (self, gSignals [FOCUS_LOCATION], 0, srcloc);
+    }
 }
 
 static void
@@ -5390,6 +5408,17 @@ ide_source_view_class_init (IdeSourceViewClass *klass)
                                 G_TYPE_NONE,
                                 0);
 
+  gSignals [FOCUS_LOCATION] =
+    g_signal_new ("focus-location",
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (IdeSourceViewClass, focus_location),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__BOXED,
+                  G_TYPE_NONE,
+                  1,
+                  IDE_TYPE_SOURCE_LOCATION);
+
   gSignals [GOTO_DEFINITION] =
     g_signal_new ("goto-definition",
                   G_TYPE_FROM_CLASS (klass),
diff --git a/libide/ide-source-view.h b/libide/ide-source-view.h
index f9aeb69..2db6cf4 100644
--- a/libide/ide-source-view.h
+++ b/libide/ide-source-view.h
@@ -219,6 +219,7 @@ struct _IdeSourceViewClass
                                        GtkDirectionType         direction);
   void (*delete_selection)            (IdeSourceView           *self);
   void (*end_macro)                   (IdeSourceView           *self);
+  void (*focus_location)              (IdeSourceView           *self);
   void (*goto_definition)             (IdeSourceView           *self);
   void (*hide_completion)             (IdeSourceView           *self);
   void (*indent_selection)            (IdeSourceView           *self,


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