Index: Tomboy/Plugins/NoteOfTheDay.cs
===================================================================
--- Tomboy/Plugins/NoteOfTheDay.cs	(revision 864)
+++ Tomboy/Plugins/NoteOfTheDay.cs	(working copy)
@@ -2,6 +2,7 @@
 using System;
 using System.Collections;
 using System.Runtime.InteropServices;
+using System.Text;
 using Mono.Unix;
 
 using Gtk;
@@ -123,6 +124,48 @@
 		
 		return found_note;
 	}
+	
+	public static Note CreateReport (NoteManager manager, DateTime start, DateTime end)
+	{
+		StringBuilder report_str = new StringBuilder ();
+		
+		foreach (Note note in manager.Notes) {
+			if (note.Title.StartsWith (title_prefix) &&
+					note.Title != template_title) {
+				DateTime note_date = note.CreateDate.Date;
+				if (note_date >= start && note_date <= end) {
+					if (report_str.Length > 0)
+						report_str.Append ("\n\n");
+					
+					report_str.Append (note.XmlContent);
+				}
+			}
+		}
+		
+		if (report_str.Length == 0)
+			return null;
+		
+		// Friday, July 01 2005
+		string date_format = Catalog.GetString ("dddd, MMMM d yyyy");
+
+		string title =
+			string.Format ("{0}: {1} - {2}",
+					Catalog.GetString ("Note of the Day Report"),
+					start.ToString (date_format),
+					end.ToString (date_format));
+		
+		string xml_content = 
+			string.Format ("<note-content>" +
+				title +
+				"\n\n" +
+				report_str.ToString () +
+				"</note-content>");
+					
+		Note report_note = manager.Create (title, xml_content);
+		report_note.Save ();
+		
+		return report_note;
+	}
 }
 
 public class NoteOfTheDayPlugin : NotePlugin
@@ -127,9 +170,10 @@
 
 public class NoteOfTheDayPlugin : NotePlugin
 {
-	Gtk.CheckMenuItem item;
 	bool timeout_owner;
 	static InterruptableTimeout timeout;
+	
+	ImageMenuItem item;
 
 	// Called only by instance with timeout_owner set.
 	void CheckNewDay (object sender, EventArgs args)
@@ -154,6 +198,12 @@
 			timeout.Reset (0);
 			timeout_owner = true;
 		}
+		
+		item = new ImageMenuItem (Catalog.GetString ("Create Note of the Day Report"));
+		item.Image = new Gtk.Image (Gtk.Stock.Index, Gtk.IconSize.Menu);
+		item.Activated += CreateReportClicked;
+		item.Show ();
+		AddPluginMenuItem (item);
 	}
 
 	protected override void Shutdown ()
@@ -164,6 +214,8 @@
 			timeout.Cancel();
 			timeout = null;
 		}
+		
+		item.Activated -= CreateReportClicked;
 	}
 
 	protected override void OnNoteOpened () 
@@ -170,4 +222,73 @@
 	{
 		// Do nothing.
 	}
+	
+	void CreateReportClicked (object sender, EventArgs args)
+	{
+		CreateNotDReportDialog dialog = new CreateNotDReportDialog (Manager);
+		int response = dialog.Run ();
+		
+		if (response != (int) ResponseType.Ok) {
+			dialog.Destroy ();
+			return;
+		}
+		
+		Logger.Log ("Creating NotD Report: {0} to {1} ...", dialog.StartDate, dialog.EndDate);
+		
+		Note note = NoteOfTheDay.CreateReport (Manager, dialog.StartDate, dialog.EndDate);
+		
+		dialog.Destroy ();
+		
+		if (note != null)
+			note.Window.Show ();
+	}
+}
+
+///
+/// Eventually, make this dialog show a list of NotD notes (sorted by date)
+/// that the user can select (with checkboxes) of the notes that should be
+/// used to generate a report note.
+///
+class CreateNotDReportDialog : Dialog
+{
+	NoteManager manager;
+	
+	Gnome.DateEdit start_date;
+	Gnome.DateEdit end_date;
+
+	public CreateNotDReportDialog (NoteManager manager)
+	{
+		this.manager = manager;
+		
+		HasSeparator = false;
+		AddButton (Stock.Cancel, ResponseType.Cancel);
+		AddButton (Stock.Ok, ResponseType.Ok);
+		
+		DefaultResponse = ResponseType.Ok;
+		
+		CreateWidgets ();
+		
+		ShowAll ();
+	}
+	
+	void CreateWidgets ()
+	{
+		end_date = new Gnome.DateEdit (DateTime.Today, false);
+		start_date = new Gnome.DateEdit (end_date.Time - new TimeSpan (365, 0, 0, 0), false);
+		
+		VBox.PackStart (start_date);
+		VBox.PackStart (end_date);
+	}
+	
+	public DateTime StartDate
+	{
+		get { return start_date.Time; }
+		set { start_date.Time = value; }
+	}
+	
+	public DateTime EndDate
+	{
+		get { return end_date.Time; }
+		set { end_date.Time = value; }
+	}
 }
