tomboy r1992 - in trunk: . Tomboy/Notebooks



Author: btimothy
Date: Thu May  8 17:01:37 2008
New Revision: 1992
URL: http://svn.gnome.org/viewvc/tomboy?rev=1992&view=rev

Log:
* Tomboy/Notebooks/NotebookManager.cs: Added an additional
  PromptCreateNewNotebook () method to allow a new notebook to be
  created and move notes to it in a single operation.
* Tomboy/Notebooks/NotebookNoteAddin.cs: Add a "New notebook..." menu
  item into the Notebook toolbar item to allow users to create a new
  notebook directly from a note.  Fixes bug #532196.

Modified:
   trunk/ChangeLog
   trunk/Tomboy/Notebooks/NotebookManager.cs
   trunk/Tomboy/Notebooks/NotebookNoteAddin.cs

Modified: trunk/Tomboy/Notebooks/NotebookManager.cs
==============================================================================
--- trunk/Tomboy/Notebooks/NotebookManager.cs	(original)
+++ trunk/Tomboy/Notebooks/NotebookManager.cs	Thu May  8 17:01:37 2008
@@ -285,6 +285,26 @@
 		/// <returns>If successful, returns the newly created notebook.</returns>
 		public static Notebook PromptCreateNewNotebook (Gtk.Window parent)
 		{
+			return PromptCreateNewNotebook (parent, null);
+		}
+		
+		/// <summary>
+		/// Prompt the user to create a new notebook and if successful, move
+		/// the notes specified in the notesToAdd list into the new notebook.
+		/// </summary>
+		/// <param name="parent">
+		/// A <see cref="Gtk.Window"/>
+		/// </param>
+		/// <param name="notesToAdd">
+		/// A <see cref="List`1"/> of notes that should be added to the new
+		/// notebook.
+		/// </param>
+		/// <returns>
+		/// The newly created <see cref="Notebook"/> if successful or null
+		/// if there was a problem.
+		/// </returns>
+		public static Notebook PromptCreateNewNotebook (Gtk.Window parent, List<Note> notesToAdd)
+		{
 			// Prompt the user for the name of a new notebook
 			Notebooks.CreateNotebookDialog dialog =
 				new Notebooks.CreateNotebookDialog (parent,
@@ -304,6 +324,11 @@
 				Logger.Warn ("Could not create notebook: {0}", notebookName);
 			} else {
 				Logger.Debug ("Created the notebook: {0} ({1})", notebook.Name, notebook.NormalizedName);
+				
+				// Move all the specified notesToAdd into the new notebook
+				foreach (Note note in notesToAdd) {
+					NotebookManager.MoveNoteToNotebook (note, notebook);
+				}
 			}
 			
 			return notebook;

Modified: trunk/Tomboy/Notebooks/NotebookNoteAddin.cs
==============================================================================
--- trunk/Tomboy/Notebooks/NotebookNoteAddin.cs	(original)
+++ trunk/Tomboy/Notebooks/NotebookNoteAddin.cs	Thu May  8 17:01:37 2008
@@ -11,10 +11,12 @@
 		Gtk.ImageMenuItem menuItem;
 		Gtk.Menu menu;
 		static Gdk.Pixbuf notebookIcon;
+		static Gdk.Pixbuf newNotebookIcon;
 		
 		static NotebookNoteAddin ()
 		{
 			notebookIcon = GuiUtils.GetIcon ("notebook", 22);
+			newNotebookIcon = GuiUtils.GetIcon ("notebook-new", 16);
 		}
 
 		public override void Initialize ()
@@ -90,6 +92,13 @@
 				UpdateNotebookButtonLabel (null);
 		}
 		
+		void OnNewNotebookMenuItem (object sender, EventArgs args)
+		{
+			List<Note> noteList = new List<Note> ();
+			noteList.Add (Note);
+			NotebookManager.PromptCreateNewNotebook (Note.Window, noteList);
+		}
+		
 		void UpdateNotebookButtonLabel ()
 		{
 			Notebook currentNotebook = NotebookManager.GetNotebookFromNote (Note);
@@ -127,6 +136,14 @@
 			// Build a new menu
 			//
 			
+			// Add the "New Notebook..."
+			Gtk.ImageMenuItem newNotebookMenuItem =
+				new Gtk.ImageMenuItem (Catalog.GetString ("_New notebook..."));
+			newNotebookMenuItem.Image = new Gtk.Image (newNotebookIcon);
+			newNotebookMenuItem.Activated += OnNewNotebookMenuItem;
+			newNotebookMenuItem.Show ();
+			menu.Append (newNotebookMenuItem);
+			
 			// Add the "(no notebook)" item at the top of the list
 			NotebookMenuItem noNotebookMenuItem = new NotebookMenuItem (Note, null);
 			noNotebookMenuItem.ShowAll ();



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