[tomboy] Save selection bound using template-bar
- From: Aaron Borden <adborden src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tomboy] Save selection bound using template-bar
- Date: Mon, 22 Aug 2011 21:49:08 +0000 (UTC)
commit 6dcc433d6261a6aeec20c352e33f84d6d96d74a1
Author: Aaron Borden <adborden live com>
Date: Fri Apr 15 08:01:19 2011 -0700
Save selection bound using template-bar
Choosing "Save Selection" will save the selection bound in addition to the
cursor's position.
Tomboy/NoteManager.cs | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/Tomboy/NoteManager.cs b/Tomboy/NoteManager.cs
index e1aab2b..6693605 100644
--- a/Tomboy/NoteManager.cs
+++ b/Tomboy/NoteManager.cs
@@ -722,15 +722,20 @@ Ciao!");
Tag template_save_selection = TagManager.GetOrCreateSystemTag (TagManager.TemplateNoteSaveSelectionSystemTag);
if (template_note.Data.CursorPosition > 0 && template_note.ContainsTag (template_save_selection)) {
+ Gtk.TextBuffer buffer = new_note.Buffer;
+ Gtk.TextIter iter;
+
// Because the titles will be different between template and
// new note, we can't just drop the cursor at template's
// CursorPosition. Whitespace after the title makes this more
// complicated so let's just start counting from the line after the title.
- int template_cursor_offset_normalized = template_note.Data.CursorPosition - template_note.Buffer.GetIterAtLine (1).Offset;
+ int title_offset_difference = buffer.GetIterAtLine (1).Offset - template_note.Buffer.GetIterAtLine (1).Offset;
- Gtk.TextBuffer buffer = new_note.Buffer;
- Gtk.TextIter cursor = buffer.GetIterAtOffset (buffer.GetIterAtLine (1).Offset + template_cursor_offset_normalized);
- buffer.PlaceCursor(cursor);
+ iter = buffer.GetIterAtOffset (template_note.Data.CursorPosition + title_offset_difference);
+ buffer.PlaceCursor(iter);
+
+ iter = buffer.GetIterAtOffset (template_note.Data.SelectionBoundPosition + title_offset_difference);
+ buffer.MoveMark (buffer.SelectionBound.Name, iter);
}
return new_note;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]