[gnome-builder/editor-layout] save file position when saving a document
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/editor-layout] save file position when saving a document
- Date: Mon, 1 Dec 2014 10:23:03 +0000 (UTC)
commit 0d8f8476751106a46f4742597b4c4e6c0e7ed25f
Author: Christian Hergert <christian hergert me>
Date: Mon Dec 1 02:22:55 2014 -0800
save file position when saving a document
src/editor/gb-editor-document.c | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-editor-document.c b/src/editor/gb-editor-document.c
index a887c4c..1c2745f 100644
--- a/src/editor/gb-editor-document.c
+++ b/src/editor/gb-editor-document.c
@@ -22,6 +22,7 @@
#include <gtksourceview/gtksource.h>
#include "gb-editor-document.h"
+#include "gb-editor-file-marks.h"
#include "gb-log.h"
#include "gca-structs.h"
@@ -516,6 +517,9 @@ gb_editor_document_save_async (GbEditorDocument *document,
gpointer user_data)
{
GtkSourceFileSaver *saver;
+ GbEditorFileMarks *marks;
+ GbEditorFileMark *mark;
+ GFile *location;
GTask *task;
ENTRY;
@@ -531,6 +535,28 @@ gb_editor_document_save_async (GbEditorDocument *document,
saver = gtk_source_file_saver_new (GTK_SOURCE_BUFFER (document),
document->priv->file);
+ location = gtk_source_file_get_location (document->priv->file);
+
+ if (location)
+ {
+ GtkTextMark *insert;
+ GtkTextIter iter;
+ guint line;
+ guint column;
+
+ marks = gb_editor_file_marks_get_default ();
+ mark = gb_editor_file_marks_get_for_file (marks, location);
+
+ insert = gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (document));
+ gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (document), &iter,
+ insert);
+ line = gtk_text_iter_get_line (&iter);
+ column = gtk_text_iter_get_line_offset (&iter);
+
+ gb_editor_file_mark_set_line (mark, line);
+ gb_editor_file_mark_set_column (mark, column);
+ }
+
gtk_source_file_saver_save_async (saver,
G_PRIORITY_DEFAULT,
cancellable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]