[tomboy] Add beginnings of template bar, including button to untemplate



commit ffe7e2631d8c6fc2e66b0989a03ea6a45476171b
Author: Sandy Armstrong <sanfordarmstrong gmail com>
Date:   Sun Jul 25 09:39:23 2010 -0700

    Add beginnings of template bar, including button to untemplate
    
    Signed-off-by: Aaron Borden <adborden live com>

 Tomboy/NoteWindow.cs |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/Tomboy/NoteWindow.cs b/Tomboy/NoteWindow.cs
index 9efb78a..a9d41ad 100644
--- a/Tomboy/NoteWindow.cs
+++ b/Tomboy/NoteWindow.cs
@@ -22,6 +22,7 @@ namespace Tomboy
 		Gtk.ScrolledWindow editor_window;
 		NoteFindBar find_bar;
 		Gtk.ToolButton delete;
+		Gtk.Box template_widget;
 
 		GlobalKeybinder global_keys;
 		InterruptableTimeout mark_set_timeout;
@@ -71,6 +72,9 @@ namespace Tomboy
 			toolbar = MakeToolbar ();
 			toolbar.Show ();
 
+
+			template_widget = MakeTemplateBar ();
+
 			// The main editor widget
 			editor = new NoteEditor (note.Buffer);
 			editor.PopulatePopup += OnPopulatePopup;
@@ -99,6 +103,7 @@ namespace Tomboy
 
 			Gtk.VBox box = new Gtk.VBox (false, 2);
 			box.PackStart (toolbar, false, false, 0);
+			box.PackStart (template_widget, false, false, 0);
 			box.PackStart (editor_window, true, true, 0);
 			box.PackStart (find_bar, false, false, 0);
 
@@ -547,6 +552,37 @@ namespace Tomboy
 			return menu;
 		}
 
+		private Gtk.Box MakeTemplateBar ()
+		{
+			var bar = new Gtk.VBox ();
+			Tag template_tag = TagManager.GetOrCreateSystemTag (TagManager.TemplateNoteSystemTag);
+			var infoLabel  = new Gtk.Label (Catalog.GetString ("This note is a template note. It determines " +
+			                                                   "the default content of regular notes, and will " +
+			                                                   "not show up in the note menu or search window."));
+			infoLabel.Wrap = true;
+			var untemplateButton = new Gtk.Button ();
+			untemplateButton.Label = "Con_vert to regular note";
+			untemplateButton.Clicked += (o, e) => {
+				note.RemoveTag (template_tag);
+			};
+			bar.PackStart (infoLabel);
+			bar.PackStart (untemplateButton);
+			if (note.ContainsTag (template_tag))
+				bar.ShowAll ();
+
+			note.TagAdded += delegate (Note taggedNote, Tag tag) {
+				if (taggedNote == note && tag == template_tag)
+					bar.ShowAll ();
+			};
+
+			note.TagRemoved += delegate (Note taggedNote, string tag) {
+				if (taggedNote == note && tag == template_tag.NormalizedName)
+					bar.HideAll ();
+			};
+
+			return bar;
+		}
+
 		//
 		// Find context menu
 		//



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