tomboy r1783 - in trunk: . Tomboy Tomboy/Notebooks data/images



Author: btimothy
Date: Mon Jan 14 19:50:53 2008
New Revision: 1783
URL: http://svn.gnome.org/viewvc/tomboy?rev=1783&view=rev

Log:
2008-01-14  Boyd Timothy <btimothy gmail com> 

        * Tomboy/RecentChanges: Added an "Unfiled Notes" item to the
          Notebooks list.

        * Tomboy/Notebooks/NotebookManager.cs: Add UnfiledNotesNotebook
          as the second item in the list.

        * Tomboy/Notebooks/NotebooksTreeView.cs: Special case drag/drop
          stuff with SpecialNotebook instead of AllNotesNotebook.

        * Tomboy/Notebooks/Notebook.cs: Added a SpecialNotebook abstract
          class that both AllNotesNotebook and UnfiledNotesNotebook (new)
          extend.

        * Tomboy/Makefile.am: Include tomboy-unfiled-notes.png as a
          resource.

        * data/images/tomboy-unfiles-notes-22.png: Stubbed out
          this icon.

        * data/images/Makefile.am: Install/uninstall
          tomboy-unfiled-notes.png properly.



Added:
   trunk/data/images/tomboy-unfiled-notes-22.png   (contents, props changed)
Modified:
   trunk/ChangeLog
   trunk/Tomboy/Makefile.am
   trunk/Tomboy/Notebooks/Notebook.cs
   trunk/Tomboy/Notebooks/NotebookManager.cs
   trunk/Tomboy/Notebooks/NotebooksTreeView.cs
   trunk/Tomboy/RecentChanges.cs
   trunk/data/images/Makefile.am

Modified: trunk/Tomboy/Makefile.am
==============================================================================
--- trunk/Tomboy/Makefile.am	(original)
+++ trunk/Tomboy/Makefile.am	Mon Jan 14 19:50:53 2008
@@ -90,6 +90,7 @@
 	-resource:$(top_srcdir)/data/images/tomboy.png,tomboy.png			\
 	-resource:$(top_srcdir)/data/images/tomboy-note-16.png,tomboy-note.png		\
 	-resource:$(top_srcdir)/data/images/tomboy-all-notes-22.png,tomboy-all-notes.png		\
+	-resource:$(top_srcdir)/data/images/tomboy-unfiled-notes-22.png,tomboy-unfiled-notes.png		\
 	-resource:$(top_srcdir)/data/images/tomboy-notebook-22.png,tomboy-notebook.png		\
 	-resource:$(top_srcdir)/data/images/tomboy-new-notebook-22.png,tomboy-new-notebook.png		\
 	-resource:$(top_srcdir)/data/images/tomboy-new-notebook-48.png,tomboy-new-notebook-dialog.png		\

Modified: trunk/Tomboy/Notebooks/Notebook.cs
==============================================================================
--- trunk/Tomboy/Notebooks/Notebook.cs	(original)
+++ trunk/Tomboy/Notebooks/Notebook.cs	Mon Jan 14 19:50:53 2008
@@ -157,12 +157,22 @@
 	}
 
 	/// <summary>
+	/// A notebook of this type is special in the sense that it
+	/// will not normally be displayed to the user as a notebook
+	/// but it's used in the Search All Notes Window for special
+	/// filtering of the notes.
+	/// </summary>
+	public abstract class SpecialNotebook : Notebook
+	{
+	}
+	
+	/// <summary>
 	/// A special notebook that represents really "no notebook" as
 	/// being selected.  This notebook is used in the Search All
 	/// Notes Window to allow users to select it at the top of the
 	/// list so that all notes are shown.
 	/// </summary>
-	public class AllNotesNotebook : Notebook
+	public class AllNotesNotebook : SpecialNotebook
 	{
 		public AllNotesNotebook () : base ()
 		{
@@ -188,4 +198,36 @@
 			return Tomboy.DefaultNoteManager.GetOrCreateTemplateNote ();
 		}
 	}
+	
+	/// <summary>
+	/// A special notebook that represents a notebook with notes
+	/// that are not filed.  This is used in the Search All Notes
+	/// Window to filter notes that are not placed in any notebook.
+	/// </summary>
+	public class UnfiledNotesNotebook : SpecialNotebook
+	{
+		public UnfiledNotesNotebook () : base ()
+		{
+		}
+		
+		public override string Name
+		{
+			get { return Catalog.GetString ("Unfiled Notes"); }
+		}
+		
+		public override string NormalizedName
+		{
+			get { return "___NotebookManager___UnfiledNotes__Notebook___"; }
+		}
+		
+		public override Tag Tag
+		{
+			get { return null; }
+		}
+		
+		public override Note GetTemplateNote ()
+		{
+			return Tomboy.DefaultNoteManager.GetOrCreateTemplateNote ();
+		}
+	}
 }
\ No newline at end of file

Modified: trunk/Tomboy/Notebooks/NotebookManager.cs
==============================================================================
--- trunk/Tomboy/Notebooks/NotebookManager.cs	(original)
+++ trunk/Tomboy/Notebooks/NotebookManager.cs	Mon Jan 14 19:50:53 2008
@@ -40,6 +40,10 @@
 			AllNotesNotebook allNotesNotebook = new AllNotesNotebook ();
 			Gtk.TreeIter iter = notebooks.Append ();
 			notebooks.SetValue (iter, 0, allNotesNotebook);
+			
+			UnfiledNotesNotebook unfiledNotesNotebook = new UnfiledNotesNotebook ();
+			iter = notebooks.Append ();
+			notebooks.SetValue (iter, 0, unfiledNotesNotebook);
 
 			// <summary>
 			// The key for this dictionary is Notebook.Name.ToLower ().
@@ -60,8 +64,8 @@
 		
 		/// <summary>
 		/// A Gtk.TreeModel that contains all of the items in the
-		/// NotebookManager TreeStore including the "All Notes"
-		/// item which is used in the "Search All Notes" window.
+		/// NotebookManager TreeStore including SpecialNotebooks
+		/// which are used in the "Search All Notes" window.
 		/// </summary>
 		/// <param name="notebookName">
 		/// A <see cref="System.String"/>
@@ -69,7 +73,7 @@
 		/// <returns>
 		/// A <see cref="Notebook"/>
 		/// </returns>
-		public static Gtk.TreeModel NotebooksWithAllNotesItem
+		public static Gtk.TreeModel NotebooksWithSpecialItems
 		{
 			get {
 				return sortedNotebooks;
@@ -372,7 +376,7 @@
 			
 			// Only attempt to add the notebook tag when this
 			// menu item is not the "No notebook" menu item.
-			if (notebook != null && (notebook is AllNotesNotebook) == false) {
+			if (notebook != null && (notebook is SpecialNotebook) == false) {
 				note.AddTag (notebook.Tag);
 				if (NoteAddedToNotebook != null)
 					NoteAddedToNotebook (note, notebook);
@@ -393,9 +397,14 @@
 			if (notebook_a == null || notebook_b == null)
 				return 0;
 			
-			if (notebook_a is AllNotesNotebook)
+			if (notebook_a is SpecialNotebook && notebook_b is SpecialNotebook) {
+				if (notebook_a is AllNotesNotebook)
+					return -1;
+				else
+					return 1;
+			} else if (notebook_a is SpecialNotebook)
 				return -1;
-			else if (notebook_b is AllNotesNotebook)
+			else if (notebook_b is SpecialNotebook)
 				return 1;
 
 			return string.Compare (notebook_a.Name, notebook_b.Name);
@@ -421,12 +430,12 @@
 		}
 
         /// <summary>
-        /// Filter out the "All Notes" item from the model
+        /// Filter out SpecialNotebooks from the model
         /// </summary>
         static bool FilterNotebooks (Gtk.TreeModel model, Gtk.TreeIter iter)
         {
         	Notebook notebook = model.GetValue (iter, 0) as Notebook;
-        	if (notebook == null || notebook is AllNotesNotebook)
+        	if (notebook == null || notebook is SpecialNotebook)
         		return false;
         	
         	return true;

Modified: trunk/Tomboy/Notebooks/NotebooksTreeView.cs
==============================================================================
--- trunk/Tomboy/Notebooks/NotebooksTreeView.cs	(original)
+++ trunk/Tomboy/Notebooks/NotebooksTreeView.cs	Mon Jan 14 19:50:53 2008
@@ -52,7 +52,7 @@
 			}
 			
 			Notebook destNotebook = Model.GetValue (iter, 0) as Notebook;
-			if (destNotebook is AllNotesNotebook) {
+			if (destNotebook is SpecialNotebook) {
 				Gtk.Drag.Finish (context, false, false, time_);
 				return;
 			}
@@ -90,7 +90,7 @@
 			}
 			
 			Notebook destNotebook = Model.GetValue (iter, 0) as Notebook;
-			if (destNotebook is AllNotesNotebook) {
+			if (destNotebook is SpecialNotebook) {
 				SetDragDestRow (null, Gtk.TreeViewDropPosition.IntoOrAfter);
 				return true;
 			}

Modified: trunk/Tomboy/RecentChanges.cs
==============================================================================
--- trunk/Tomboy/RecentChanges.cs	(original)
+++ trunk/Tomboy/RecentChanges.cs	Mon Jan 14 19:50:53 2008
@@ -47,6 +47,7 @@
 
                 static Gdk.Pixbuf note_icon;
                 static Gdk.Pixbuf all_notes_icon;
+                static Gdk.Pixbuf unfiled_notes_icon;
                 static Gdk.Pixbuf notebook_icon;
                 static ArrayList previous_searches;
                 static NoteRecentChanges instance;
@@ -55,6 +56,7 @@
                 {
                         note_icon = GuiUtils.GetIcon ("tomboy-note", 22);
                         all_notes_icon = GuiUtils.GetIcon ("tomboy-all-notes", 22);
+                        unfiled_notes_icon = GuiUtils.GetIcon ("tomboy-unfiled-notes", 22);
                         notebook_icon = GuiUtils.GetIcon ("tomboy-notebook", 22);
                 }
 
@@ -231,7 +233,7 @@
 
 		Gtk.Widget MakeNotebooksPane ()
 		{
-			notebooksTree = new Notebooks.NotebooksTreeView (Notebooks.NotebookManager.NotebooksWithAllNotesItem);
+			notebooksTree = new Notebooks.NotebooksTreeView (Notebooks.NotebookManager.NotebooksWithSpecialItems);
 			notebooksTree.Selection.Mode = Gtk.SelectionMode.Single;
 			notebooksTree.HeadersVisible = true;
 			notebooksTree.RulesHint = false;
@@ -433,7 +435,7 @@
 			
 			// Search using the currently selected notebook
 			Notebooks.Notebook selected_notebook = GetSelectedNotebook ();
-			if (selected_notebook is Notebooks.AllNotesNotebook)
+			if (selected_notebook is Notebooks.SpecialNotebook)
 				selected_notebook = null;
 			
 			IDictionary<Note,int> results =
@@ -552,6 +554,15 @@
                         Tag template_tag = TagManager.GetOrCreateSystemTag (TagManager.TemplateNoteSystemTag);
                         if (note.ContainsTag (template_tag))
                         	return false;
+                        
+                        Notebooks.Notebook selected_notebook = GetSelectedNotebook ();
+                        if (selected_notebook is Notebooks.UnfiledNotesNotebook) {
+                        	// If the note belongs to a notebook, return false
+                        	// since the only notes that should be shown in this
+                        	// case are notes that are unfiled (not in a notebook).
+                        	if (Notebooks.NotebookManager.GetNotebookFromNote (note) != null)
+                        		return false;
+                        }
 
                         bool passes_search_filter = FilterBySearch (note);
                         if (passes_search_filter == false)
@@ -1044,6 +1055,8 @@
 			Gtk.CellRendererPixbuf crp = renderer as Gtk.CellRendererPixbuf;
 			if (notebook is Notebooks.AllNotesNotebook) {
 				crp.Pixbuf = all_notes_icon;
+			} else if (notebook is Notebooks.UnfiledNotesNotebook) {
+				crp.Pixbuf = unfiled_notes_icon;
 			} else {
 				crp.Pixbuf = notebook_icon;
 			}
@@ -1063,8 +1076,8 @@
 			
 			crt.Text = notebook.Name;
 
-			if (notebook is Notebooks.AllNotesNotebook) {
-				// Bold the All Notes item
+			if (notebook is Notebooks.SpecialNotebook) {
+				// Bold the "Special" Notebooks
 				crt.Markup = string.Format ("<span weight=\"bold\">{0}</span>", notebook.Name);
 			} else {
 				crt.Text = notebook.Name;
@@ -1089,10 +1102,10 @@
 				selected_tags.Clear ();
 				if (notebook.Tag != null)
 					selected_tags.Add (notebook.Tag, notebook.Tag);
-				if (notebook is Notebooks.AllNotesNotebook) {
-	                Tomboy.ActionManager ["OpenNotebookTemplateNoteAction"].Sensitive = true;
+				if (notebook is Notebooks.SpecialNotebook) {
+					Tomboy.ActionManager ["DeleteNotebookAction"].Sensitive = false;
 				} else {
-	                Tomboy.ActionManager ["OpenNotebookTemplateNoteAction"].Sensitive = true;
+					Tomboy.ActionManager ["DeleteNotebookAction"].Sensitive = true;
 				}
 			}
 			
@@ -1122,7 +1135,7 @@
 		private void OnNewNotebookNote (object sender, EventArgs args)
 		{
 			Notebooks.Notebook notebook = GetSelectedNotebook ();
-			if (notebook == null || notebook is Notebooks.AllNotesNotebook) {
+			if (notebook == null || notebook is Notebooks.SpecialNotebook) {
 				// Just create a standard note (not in a notebook)
 				Tomboy.ActionManager ["NewNoteAction"].Activate ();
 				return;
@@ -1223,7 +1236,7 @@
 				case Gdk.Key.Menu:
 					// Pop up the context menu if a notebook is selected
 					Notebooks.Notebook notebook = GetSelectedNotebook ();
-					if (notebook == null || notebook is Notebooks.AllNotesNotebook)
+					if (notebook == null || notebook is Notebooks.SpecialNotebook)
 						return; // Don't pop open a submenu
 					
 					Gtk.Menu menu = Tomboy.ActionManager.GetWidget (

Modified: trunk/data/images/Makefile.am
==============================================================================
--- trunk/data/images/Makefile.am	(original)
+++ trunk/data/images/Makefile.am	Mon Jan 14 19:50:53 2008
@@ -14,6 +14,7 @@
 	tomboy-22.png			\
 	tomboy-note-22.png		\
 	tomboy-all-notes-22.png		\
+	tomboy-unfiled-notes-22.png		\
 	tomboy-notebook-22.png		\
 	tomboy-new-notebook-22.png	\
 	tomboy-new-notebook-48.png	\
@@ -34,6 +35,7 @@
 	$(INSTALL_DATA) $(srcdir)/tomboy-22.png $(DESTDIR)$(hicolordir)/22x22/apps/tomboy.png
 	$(INSTALL_DATA) $(srcdir)/tomboy-note-22.png $(DESTDIR)$(hicolordir)/22x22/apps/tomboy-note.png
 	$(INSTALL_DATA) $(srcdir)/tomboy-all-notes-22.png $(DESTDIR)$(hicolordir)/22x22/apps/tomboy-all-notes.png
+	$(INSTALL_DATA) $(srcdir)/tomboy-unfiled-notes-22.png $(DESTDIR)$(hicolordir)/22x22/apps/tomboy-unfiled-notes.png
 	$(INSTALL_DATA) $(srcdir)/tomboy-notebook-22.png $(DESTDIR)$(hicolordir)/22x22/apps/tomboy-notebook.png
 	$(INSTALL_DATA) $(srcdir)/tomboy-new-notebook-22.png $(DESTDIR)$(hicolordir)/22x22/apps/tomboy-new-notebook.png
 	@-$(mkinstalldirs) $(DESTDIR)$(hicolordir)/32x32/apps
@@ -65,6 +67,7 @@
 	rm -f $(DESTDIR)$(hicolordir)/22x22/apps/tomboy.png
 	rm -f $(DESTDIR)$(hicolordir)/22x22/apps/tomboy-note.png
 	rm -f $(DESTDIR)$(hicolordir)/22x22/apps/tomboy-all-notes.png
+	rm -f $(DESTDIR)$(hicolordir)/22x22/apps/tomboy-unfiled-notes.png
 	rm -f $(DESTDIR)$(hicolordir)/22x22/apps/tomboy-notebook.png
 	rm -f $(DESTDIR)$(hicolordir)/22x22/apps/tomboy-new-notebook.png
 	rm -f $(DESTDIR)$(hicolordir)/32x32/apps/tomboy.png

Added: trunk/data/images/tomboy-unfiled-notes-22.png
==============================================================================
Binary file. No diff available.



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