[tomboy] Save title option for template bar



commit e0bf39a123a64b75e860e5955d619bc54a8128db
Author: Aaron Borden <adborden live com>
Date:   Wed Apr 27 17:10:25 2011 -0700

    Save title option for template bar
    
    Adds a setting to the template bar to allow new notes based on the template to
    use the template note's title as the base title for the new note. e.g. a note
    based on a template named "Tomboy Bug Note" would have the name "Tomboy Bug
    Note 101"

 Tomboy/NoteManager.cs |    4 ++++
 Tomboy/NoteWindow.cs  |   11 +++++++++++
 Tomboy/TagManager.cs  |    1 +
 3 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/Tomboy/NoteManager.cs b/Tomboy/NoteManager.cs
index 6693605..8e70f9a 100644
--- a/Tomboy/NoteManager.cs
+++ b/Tomboy/NoteManager.cs
@@ -705,6 +705,10 @@ Ciao!");
 		// the template note.
 		private Note CreateNoteFromTemplate (string title, Note template_note, string guid)
 		{
+			Tag template_save_title = TagManager.GetOrCreateSystemTag (TagManager.TemplateNoteSaveTitleSystemTag);
+			if (template_note.ContainsTag (template_save_title))
+				title = GetUniqueName (template_note.Title, notes.Count);
+			
 			// Use the body from the template note
 			string xml_content =
 				template_note.XmlContent.Replace (XmlEncoder.Encode (template_note.Title),
diff --git a/Tomboy/NoteWindow.cs b/Tomboy/NoteWindow.cs
index b0fc217..cc8be4f 100644
--- a/Tomboy/NoteWindow.cs
+++ b/Tomboy/NoteWindow.cs
@@ -558,6 +558,7 @@ namespace Tomboy
 			Tag template_tag = TagManager.GetOrCreateSystemTag (TagManager.TemplateNoteSystemTag);
 			Tag template_save_size_tag = TagManager.GetOrCreateSystemTag (TagManager.TemplateNoteSaveSizeSystemTag);
 			Tag template_save_selection_tag = TagManager.GetOrCreateSystemTag (TagManager.TemplateNoteSaveSelectionSystemTag);
+			Tag template_save_title_tag = TagManager.GetOrCreateSystemTag (TagManager.TemplateNoteSaveTitleSystemTag);
 
 			var bar = new Gtk.VBox ();
 
@@ -589,11 +590,21 @@ namespace Tomboy
 				else
 					note.RemoveTag (template_save_selection_tag);
 			};
+			
+			var saveTitleCheckbutton = new Gtk.CheckButton (Catalog.GetString ("Save _Title"));
+			saveTitleCheckbutton.Active = note.ContainsTag (template_save_title_tag);
+			saveTitleCheckbutton.Toggled += (o, e) => {
+				if (saveTitleCheckbutton.Active)
+					note.AddTag (template_save_title_tag);
+				else
+					note.RemoveTag (template_save_title_tag);
+			};
 
 			bar.PackStart (infoLabel);
 			bar.PackStart (untemplateButton);
 			bar.PackStart (saveSizeCheckbutton);
 			bar.PackStart (saveSelectionCheckbutton);
+			bar.PackStart (saveTitleCheckbutton);
 
 			if (note.ContainsTag (template_tag))
 				bar.ShowAll ();
diff --git a/Tomboy/TagManager.cs b/Tomboy/TagManager.cs
index 43ddf3a..6b5d45d 100644
--- a/Tomboy/TagManager.cs
+++ b/Tomboy/TagManager.cs
@@ -27,6 +27,7 @@ namespace Tomboy
 		public static string TemplateNoteSystemTag = "template";
 		public static string TemplateNoteSaveSizeSystemTag = TemplateNoteSystemTag + ":save-size";
 		public static string TemplateNoteSaveSelectionSystemTag = TemplateNoteSystemTag + ":save-selection";
+		public static string TemplateNoteSaveTitleSystemTag = TemplateNoteSystemTag + ":save-title";
 		
 		#region Constructors
 		static TagManager ()



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