[gnome-builder/wip/file-marks] editor: add function to restore file mark in an editor tab.



commit e7a75b49b2c79a1ae67e626a01c83d345342a5a9
Author: Christian Hergert <christian hergert me>
Date:   Wed Oct 8 16:06:22 2014 -0700

    editor: add function to restore file mark in an editor tab.

 src/editor/gb-editor-tab.c |   33 ++++++++++++++++++++++++++++++++-
 src/editor/gb-editor-tab.h |    1 +
 2 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/src/editor/gb-editor-tab.c b/src/editor/gb-editor-tab.c
index 68b3b12..ef1c5af 100644
--- a/src/editor/gb-editor-tab.c
+++ b/src/editor/gb-editor-tab.c
@@ -20,9 +20,12 @@
 
 #include <glib/gi18n.h>
 
-#include "gb-editor-workspace.h"
+#include "gb-editor-file-mark.h"
+#include "gb-editor-file-marks.h"
 #include "gb-editor-tab.h"
 #include "gb-editor-tab-private.h"
+#include "gb-editor-workspace.h"
+#include "gb-gtk.h"
 #include "gb-log.h"
 #include "gb-rgba.h"
 #include "gb-source-change-gutter-renderer.h"
@@ -1332,6 +1335,34 @@ gb_editor_tab_constructed (GObject *object)
   EXIT;
 }
 
+void
+gb_editor_tab_load_file_mark (GbEditorTab *tab)
+{
+  GbEditorFileMarks *marks;
+  GbEditorFileMark *mark;
+  GtkTextBuffer *buffer;
+  GtkTextIter iter;
+  GFile *file;
+  guint line;
+  guint column;
+
+  g_return_if_fail (GB_IS_EDITOR_TAB (tab));
+
+  buffer = GTK_TEXT_BUFFER (tab->priv->document);
+
+  file = gtk_source_file_get_location (tab->priv->file);
+  marks = gb_editor_file_marks_get_default ();
+  mark = gb_editor_file_marks_get_for_file (marks, file);
+
+  line = gb_editor_file_mark_get_line (mark);
+  column = gb_editor_file_mark_get_column (mark);
+
+  gb_gtk_text_buffer_get_iter_at_line_and_offset (buffer, &iter, line, column);
+  gtk_text_buffer_select_range (buffer, &iter, &iter);
+  gb_gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (tab->priv->source_view),
+                                   &iter, 0.0, TRUE, 0.5, 0.5);
+}
+
 static void
 gb_editor_tab_save_file_mark (GbEditorTab *tab)
 {
diff --git a/src/editor/gb-editor-tab.h b/src/editor/gb-editor-tab.h
index 61961f8..ed86a01 100644
--- a/src/editor/gb-editor-tab.h
+++ b/src/editor/gb-editor-tab.h
@@ -60,6 +60,7 @@ void              gb_editor_tab_set_settings   (GbEditorTab                *tab,
 void              gb_editor_tab_set_font_desc  (GbEditorTab                *tab,
                                                 const PangoFontDescription *font_desc);
 gboolean          gb_editor_tab_get_is_default (GbEditorTab                *tab);
+void              gb_editor_tab_load_file_mark (GbEditorTab                *tab);
 void              gb_editor_tab_scroll_to_line (GbEditorTab                *tab,
                                                 guint                       line,
                                                 guint                       line_offset);


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