tomboy r2280 - in trunk: . Tomboy Tomboy/Addins/Backlinks Tomboy/Addins/Bugzilla Tomboy/Addins/Evolution Tomboy/Addins/ExportToHtml Tomboy/Addins/GalagoPresence Tomboy/Addins/NoteOfTheDay Tomboy/Addins/Tasque Tomboy/Synchronization



Author: sharm
Date: Mon Jan 19 23:30:07 2009
New Revision: 2280
URL: http://svn.gnome.org/viewvc/tomboy?rev=2280&view=rev

Log:
* tomboy/Tomboy/Note.cs:
* tomboy/Tomboy/Undo.cs:
* tomboy/Tomboy/Tray.cs:
* tomboy/Tomboy/Trie.cs:
* tomboy/Tomboy/Utils.cs:
* tomboy/Tomboy/Search.cs:
* tomboy/Tomboy/NoteTag.cs:
* tomboy/Tomboy/TagEntry.cs:
* tomboy/Tomboy/Watchers.cs:
* tomboy/Tomboy/NoteBuffer.cs:
* tomboy/Tomboy/NoteWindow.cs:
* tomboy/Tomboy/XKeybinder.cs:
* tomboy/Tomboy/NoteManager.cs:
* tomboy/Tomboy/RecentChanges.cs:
* tomboy/Tomboy/RemoteControl.cs:
* tomboy/Tomboy/PrefsKeybinder.cs:
* tomboy/Tomboy/GnomeApplication.cs:
* tomboy/Tomboy/Synchronization/SyncDialog.cs:
* tomboy/Tomboy/Addins/Bugzilla/BugzillaLink.cs:
* tomboy/Tomboy/Addins/Tasque/TasqueNoteAddin.cs:
* tomboy/Tomboy/Addins/NoteOfTheDay/NoteOfTheDay.cs:
* tomboy/Tomboy/Addins/Evolution/EvolutionNoteAddin.cs:
* tomboy/Tomboy/Addins/Backlinks/BacklinksNoteAddin.cs:
* tomboy/Tomboy/Addins/ExportToHtml/ExportToHtmlNoteAddin.cs:
* tomboy/Tomboy/Addins/GalagoPresence/GalagoPresenceNoteAddin.cs:
* tomboy/Tomboy/Addins/NoteOfTheDay/NoteOfTheDayApplicationAddin.cs:
  Switch to using generic collection classes wherever possible.  Clean
  up some using statements.

Modified:
   trunk/ChangeLog
   trunk/Tomboy/Addins/Backlinks/BacklinksNoteAddin.cs
   trunk/Tomboy/Addins/Bugzilla/BugzillaLink.cs
   trunk/Tomboy/Addins/Evolution/EvolutionNoteAddin.cs
   trunk/Tomboy/Addins/ExportToHtml/ExportToHtmlNoteAddin.cs
   trunk/Tomboy/Addins/GalagoPresence/GalagoPresenceNoteAddin.cs
   trunk/Tomboy/Addins/NoteOfTheDay/NoteOfTheDay.cs
   trunk/Tomboy/Addins/NoteOfTheDay/NoteOfTheDayApplicationAddin.cs
   trunk/Tomboy/Addins/Tasque/TasqueNoteAddin.cs
   trunk/Tomboy/GnomeApplication.cs
   trunk/Tomboy/Note.cs
   trunk/Tomboy/NoteBuffer.cs
   trunk/Tomboy/NoteManager.cs
   trunk/Tomboy/NoteTag.cs
   trunk/Tomboy/NoteWindow.cs
   trunk/Tomboy/PrefsKeybinder.cs
   trunk/Tomboy/RecentChanges.cs
   trunk/Tomboy/RemoteControl.cs
   trunk/Tomboy/Search.cs
   trunk/Tomboy/Synchronization/SyncDialog.cs
   trunk/Tomboy/TagEntry.cs
   trunk/Tomboy/Tray.cs
   trunk/Tomboy/Trie.cs
   trunk/Tomboy/Undo.cs
   trunk/Tomboy/Utils.cs
   trunk/Tomboy/Watchers.cs
   trunk/Tomboy/XKeybinder.cs

Modified: trunk/Tomboy/Addins/Backlinks/BacklinksNoteAddin.cs
==============================================================================
--- trunk/Tomboy/Addins/Backlinks/BacklinksNoteAddin.cs	(original)
+++ trunk/Tomboy/Addins/Backlinks/BacklinksNoteAddin.cs	Mon Jan 19 23:30:07 2009
@@ -1,6 +1,6 @@
 
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Mono.Unix;
 
@@ -92,7 +92,7 @@
 
 		BacklinkMenuItem [] GetBacklinkMenuItems ()
 		{
-			ArrayList items = new ArrayList ();
+			List<BacklinkMenuItem> items = new List<BacklinkMenuItem> ();
 
 			string search_title = Note.Title;
 			string encoded_title = XmlEncoder.Encode (search_title.ToLower ());
@@ -111,7 +111,7 @@
 
 			items.Sort ();
 
-			return items.ToArray (typeof (BacklinkMenuItem)) as BacklinkMenuItem [];
+			return items.ToArray ();
 		}
 
 		bool CheckNoteHasMatch (Note note, string encoded_title)

Modified: trunk/Tomboy/Addins/Bugzilla/BugzillaLink.cs
==============================================================================
--- trunk/Tomboy/Addins/Bugzilla/BugzillaLink.cs	(original)
+++ trunk/Tomboy/Addins/Bugzilla/BugzillaLink.cs	Mon Jan 19 23:30:07 2009
@@ -36,7 +36,10 @@
 		public string BugUrl
 		{
 			get {
-				return (string) Attributes [UriAttributeName];
+				string url;
+				if (Attributes.TryGetValue (UriAttributeName, out url))
+					return url;
+				return null;
 			}
 			set {
 				Attributes [UriAttributeName] = value;

Modified: trunk/Tomboy/Addins/Evolution/EvolutionNoteAddin.cs
==============================================================================
--- trunk/Tomboy/Addins/Evolution/EvolutionNoteAddin.cs	(original)
+++ trunk/Tomboy/Addins/Evolution/EvolutionNoteAddin.cs	Mon Jan 19 23:30:07 2009
@@ -1,6 +1,7 @@
 
 using System;
 using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 using System.Xml;
 using System.Web;
@@ -20,7 +21,7 @@
 	class EvoUtils
 	{
 		// Cache of account URLs to account UIDs
-		static Hashtable source_url_to_uid;
+		static Dictionary<Uri, string> source_url_to_uid;
 
 		static GConf.Client gc;
 		static GConf.NotifyEventHandler changed_handler;
@@ -33,7 +34,7 @@
 				changed_handler = new GConf.NotifyEventHandler (OnAccountsSettingChanged);
 				gc.AddNotify ("/apps/evolution/mail/accounts", changed_handler);
 
-				source_url_to_uid = new Hashtable ();
+				source_url_to_uid = new Dictionary<Uri, string> ();
 				SetupAccountUrlToUidMap ();
 			}
 			catch (Exception e) {
@@ -137,7 +138,7 @@
 				}
 
 				if (match) {
-					account_uid = (string) source_url_to_uid [source_uri];
+					account_uid = source_url_to_uid [source_uri];
 					Logger.Log ("Evolution: Matching account '{0}'...",
 					            account_uid);
 					break;
@@ -283,8 +284,8 @@
 	public class EvolutionNoteAddin : NoteAddin
 	{
 		// Used in the two-phase evolution drop handling.
-		ArrayList xuid_list;
-		ArrayList subject_list;
+		List<string> xuid_list;
+		List<string> subject_list;
 
 		static EvolutionNoteAddin ()
 		{
@@ -374,7 +375,7 @@
 		{
 			string uri_string = Encoding.UTF8.GetString (args.SelectionData.Data);
 
-			subject_list = new ArrayList();
+			subject_list = new List<string>();
 
 			UriList uri_list = new UriList (uri_string);
 			foreach (Uri uri in uri_list) {
@@ -421,7 +422,7 @@
 			string source = Encoding.UTF8.GetString (args.SelectionData.Data);
 			string [] list = source.Split ('\0');
 
-			xuid_list = new ArrayList ();
+			xuid_list = new List<string> ();
 
 			Logger.Log ("Evolution: Dropped XUid: uri = '{0}'", list [0]);
 
@@ -441,7 +442,7 @@
 			}
 		}
 
-		void InsertMailLinks (int x, int y, ArrayList xuid_list, ArrayList subject_list)
+		void InsertMailLinks (int x, int y, List<string> xuid_list, List<string> subject_list)
 		{
 			int message_idx = 0;
 			bool more_than_one = false;
@@ -466,7 +467,7 @@
 						Buffer.Insert (ref cursor, ", ");
 				}
 
-				string launch_uri = (string) xuid_list [message_idx++];
+				string launch_uri = xuid_list [message_idx++];
 
 				EmailLink link_tag;
 				link_tag = (EmailLink) Note.TagTable.CreateDynamicTag ("link:evo-mail");

Modified: trunk/Tomboy/Addins/ExportToHtml/ExportToHtmlNoteAddin.cs
==============================================================================
--- trunk/Tomboy/Addins/ExportToHtml/ExportToHtmlNoteAddin.cs	(original)
+++ trunk/Tomboy/Addins/ExportToHtml/ExportToHtmlNoteAddin.cs	Mon Jan 19 23:30:07 2009
@@ -1,7 +1,6 @@
 
 using System;
 using System.IO;
-using System.Collections;
 using System.Reflection;
 using System.Xml;
 using System.Xml.XPath;

Modified: trunk/Tomboy/Addins/GalagoPresence/GalagoPresenceNoteAddin.cs
==============================================================================
--- trunk/Tomboy/Addins/GalagoPresence/GalagoPresenceNoteAddin.cs	(original)
+++ trunk/Tomboy/Addins/GalagoPresence/GalagoPresenceNoteAddin.cs	Mon Jan 19 23:30:07 2009
@@ -1,6 +1,6 @@
 
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.Runtime.InteropServices;
 using System.Diagnostics;
 using Mono.Unix;
@@ -74,7 +74,7 @@
 		void UpdateTrie (bool refresh_query)
 		{
 			trie = new TrieTree (false /* !case_sensitive */);
-			ArrayList people = new ArrayList ();
+			List<PersonLink> people = new List<PersonLink> ();
 
 			Logger.Log ("Loading up the person trie, Part 1...");
 

Modified: trunk/Tomboy/Addins/NoteOfTheDay/NoteOfTheDay.cs
==============================================================================
--- trunk/Tomboy/Addins/NoteOfTheDay/NoteOfTheDay.cs	(original)
+++ trunk/Tomboy/Addins/NoteOfTheDay/NoteOfTheDay.cs	Mon Jan 19 23:30:07 2009
@@ -1,5 +1,5 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using Tomboy;
 using Mono.Unix;
 
@@ -90,7 +90,7 @@
 
 		public static void CleanupOld (NoteManager manager)
 		{
-			ArrayList kill_list = new ArrayList();
+			List<Note> kill_list = new List<Note> ();
 			DateTime date_today = DateTime.Today; // time set to 00:00:00
 
 			foreach (Note note in manager.Notes) {

Modified: trunk/Tomboy/Addins/NoteOfTheDay/NoteOfTheDayApplicationAddin.cs
==============================================================================
--- trunk/Tomboy/Addins/NoteOfTheDay/NoteOfTheDayApplicationAddin.cs	(original)
+++ trunk/Tomboy/Addins/NoteOfTheDay/NoteOfTheDayApplicationAddin.cs	Mon Jan 19 23:30:07 2009
@@ -1,6 +1,5 @@
 
 using System;
-using System.Collections;
 using System.Runtime.InteropServices;
 
 using Gtk;

Modified: trunk/Tomboy/Addins/Tasque/TasqueNoteAddin.cs
==============================================================================
--- trunk/Tomboy/Addins/Tasque/TasqueNoteAddin.cs	(original)
+++ trunk/Tomboy/Addins/Tasque/TasqueNoteAddin.cs	Mon Jan 19 23:30:07 2009
@@ -1,6 +1,5 @@
 
 using System;
-using System.Collections;
 
 using Mono.Unix;
 

Modified: trunk/Tomboy/GnomeApplication.cs
==============================================================================
--- trunk/Tomboy/GnomeApplication.cs	(original)
+++ trunk/Tomboy/GnomeApplication.cs	Mon Jan 19 23:30:07 2009
@@ -1,5 +1,4 @@
 using System;
-using System.Collections;
 using System.Runtime.InteropServices;
 using System.Text;
 using System.IO;

Modified: trunk/Tomboy/Note.cs
==============================================================================
--- trunk/Tomboy/Note.cs	(original)
+++ trunk/Tomboy/Note.cs	Mon Jan 19 23:30:07 2009
@@ -1,5 +1,4 @@
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.IO;

Modified: trunk/Tomboy/NoteBuffer.cs
==============================================================================
--- trunk/Tomboy/NoteBuffer.cs	(original)
+++ trunk/Tomboy/NoteBuffer.cs	Mon Jan 19 23:30:07 2009
@@ -1,6 +1,5 @@
 
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.IO;
 using System.Xml;
@@ -35,7 +34,7 @@
 		// HATE.
 
 		// list of Gtk.TextTags to apply on insert
-		ArrayList active_tags;
+		List<Gtk.TextTag> active_tags;
 
 		// The note that owns this buffer
 		private Note note;
@@ -52,7 +51,7 @@
 		public NoteBuffer (Gtk.TextTagTable tags, Note note)
 : base (tags)
 		{
-			active_tags = new ArrayList ();
+			active_tags = new List<Gtk.TextTag> ();
 			undo_manager = new UndoManager (this);
 
 			InsertText += TextInsertedEvent;
@@ -1179,9 +1178,9 @@
 		                              Gtk.TextIter   end,
 		                              XmlTextWriter  xml)
 		{
-			Stack tag_stack = new Stack ();
-			Stack replay_stack = new Stack ();
-			Stack continue_stack = new Stack ();
+			Stack<Gtk.TextTag> tag_stack = new Stack<Gtk.TextTag> ();
+			Stack<Gtk.TextTag> replay_stack = new Stack<Gtk.TextTag> ();
+			Stack<Gtk.TextTag> continue_stack = new Stack<Gtk.TextTag> ();
 
 			Gtk.TextIter iter = start;
 			Gtk.TextIter next_iter = start;
@@ -1271,7 +1270,7 @@
 				while (continue_stack.Count > 0 &&
 				                ((depth_tag == null && iter.StartsLine ()) || iter.LineOffset == 1))
 				{
-					Gtk.TextTag continue_tag = (Gtk.TextTag) continue_stack.Pop();
+					Gtk.TextTag continue_tag = continue_stack.Pop();
 
 					if (!TagEndsHere (continue_tag, iter, next_iter)
 					                && iter.HasTag (continue_tag))
@@ -1313,7 +1312,7 @@
 				{
 					// Close all tags in the tag_stack
 					while (tag_stack.Count > 0) {
-						Gtk.TextTag existing_tag = tag_stack.Pop () as Gtk.TextTag;
+						Gtk.TextTag existing_tag = tag_stack.Pop ();
 
 						// Any tags which continue across the indented
 						// line are added to the continue_stack to be
@@ -1330,7 +1329,7 @@
 						                NoteTagTable.TagIsSerializable(tag) && !(tag is DepthNoteTag))
 						{
 							while (tag_stack.Count > 0) {
-								Gtk.TextTag existing_tag = tag_stack.Pop () as Gtk.TextTag;
+								Gtk.TextTag existing_tag = tag_stack.Pop ();
 
 								if (!TagEndsHere (existing_tag, iter, next_iter)) {
 									replay_stack.Push (existing_tag);
@@ -1344,7 +1343,7 @@
 							// overlapped with the ended
 							// tag...
 							while (replay_stack.Count > 0) {
-								Gtk.TextTag replay_tag = replay_stack.Pop () as Gtk.TextTag;
+								Gtk.TextTag replay_tag = replay_stack.Pop ();
 								tag_stack.Push (replay_tag);
 
 								WriteTag (replay_tag, xml, true);
@@ -1380,7 +1379,7 @@
 
 			// Empty any trailing tags left in tag_stack..
 			while (tag_stack.Count > 0) {
-				Gtk.TextTag tail_tag = (Gtk.TextTag) tag_stack.Pop ();
+				Gtk.TextTag tail_tag = tag_stack.Pop ();
 				WriteTag (tail_tag, xml, false);
 			}
 
@@ -1414,7 +1413,7 @@
 		                                XmlTextReader  xml)
 		{
 			int offset = start.Offset;
-			Stack stack = new Stack ();
+			Stack<TagStart> stack = new Stack<TagStart> ();
 			TagStart tag_start;
 
 			NoteTagTable note_table = buffer.TagTable as NoteTagTable;
@@ -1423,7 +1422,7 @@
 
 			// A stack of boolean values which mark if a
 			// list-item contains content other than another list
-			Stack list_stack = new Stack();
+			Stack<bool> list_stack = new Stack<bool> ();
 
 			while (xml.Read ()) {
 				switch (xml.NodeType) {
@@ -1489,7 +1488,7 @@
 						break;
 					}
 
-					tag_start = (TagStart) stack.Pop ();
+					tag_start = stack.Pop ();
 					if (tag_start.Tag == null)
 						break;
 
@@ -1506,7 +1505,7 @@
 					// had content.
 					DepthNoteTag depth_tag = tag_start.Tag as DepthNoteTag;
 
-					if (depth_tag != null && (bool) list_stack.Pop ()) {
+					if (depth_tag != null && list_stack.Pop ()) {
 						((NoteBuffer) buffer).InsertBullet (ref apply_start,
 						                                    depth_tag.Depth,
 						                                    depth_tag.Direction);

Modified: trunk/Tomboy/NoteManager.cs
==============================================================================
--- trunk/Tomboy/NoteManager.cs	(original)
+++ trunk/Tomboy/NoteManager.cs	Mon Jan 19 23:30:07 2009
@@ -1,7 +1,6 @@
 
 using System;
 using System.IO;
-using System.Collections;
 using System.Collections.Generic;
 using Mono.Unix;
 

Modified: trunk/Tomboy/NoteTag.cs
==============================================================================
--- trunk/Tomboy/NoteTag.cs	(original)
+++ trunk/Tomboy/NoteTag.cs	Mon Jan 19 23:30:07 2009
@@ -1,6 +1,6 @@
 
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 using System.Runtime.InteropServices;
 using System.Xml;
@@ -347,18 +347,18 @@
 
 	public class DynamicNoteTag : NoteTag
 	{
-		Hashtable attributes;
+		Dictionary<string, string> attributes;
 
 		public DynamicNoteTag ()
 : base()
 		{
 		}
 
-		public Hashtable Attributes
+		public IDictionary<string, string> Attributes
 		{
 			get {
 				if (attributes == null)
-					attributes = new Hashtable ();
+					attributes = new Dictionary<string, string> ();
 				return attributes;
 			}
 		}
@@ -370,7 +370,7 @@
 
 				if (start && attributes != null) {
 					foreach (string key in attributes.Keys) {
-						string val = (string) attributes [key];
+						string val = attributes [key];
 						xml.WriteAttributeString (null, key, null, val);
 					}
 				}
@@ -460,8 +460,8 @@
 	public class NoteTagTable : Gtk.TextTagTable
 	{
 		static NoteTagTable instance;
-		Hashtable tag_types;
-		ArrayList added_tags;
+		Dictionary<string, Type> tag_types;
+		List<Gtk.TextTag> added_tags;
 
 		public static NoteTagTable Instance
 		{
@@ -475,8 +475,8 @@
 		public NoteTagTable ()
 : base ()
 		{
-			tag_types = new Hashtable ();
-			added_tags = new ArrayList ();
+			tag_types = new Dictionary<string, Type> ();
+			added_tags = new List<Gtk.TextTag> ();
 
 			InitCommonTags ();
 		}
@@ -673,8 +673,8 @@
 
 		public DynamicNoteTag CreateDynamicTag (string tag_name)
 		{
-			Type tag_type = tag_types [tag_name] as Type;
-			if (tag_type == null)
+			Type tag_type;
+			if (!tag_types.TryGetValue (tag_name, out tag_type))
 				return null;
 
 			DynamicNoteTag tag = (DynamicNoteTag) Activator.CreateInstance(tag_type);
@@ -693,7 +693,11 @@
 
 		public bool IsDynamicTagRegistered (string tag_name)
 		{
-			return tag_types [tag_name] != null;
+			Type type;
+			if (tag_types.TryGetValue (tag_name, out type) &&
+			    type != null)
+				return true;
+			return false;
 		}
 
 		protected override void OnTagAdded (Gtk.TextTag tag)

Modified: trunk/Tomboy/NoteWindow.cs
==============================================================================
--- trunk/Tomboy/NoteWindow.cs	(original)
+++ trunk/Tomboy/NoteWindow.cs	Mon Jan 19 23:30:07 2009
@@ -1,6 +1,5 @@
 
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.Runtime.InteropServices;
 using System.Text;
@@ -723,7 +722,7 @@
 		Gtk.Button next_button;
 		Gtk.Button prev_button;
 
-		ArrayList current_matches;
+		List<Match> current_matches;
 		string prev_search_text;
 
 		InterruptableTimeout entry_changed_timeout;
@@ -1106,9 +1105,9 @@
 			UpdateSensitivity ();
 		}
 
-		ArrayList FindMatchesInBuffer (NoteBuffer buffer, string [] words)
+		List<Match> FindMatchesInBuffer (NoteBuffer buffer, string [] words)
 		{
-			ArrayList matches = new ArrayList ();
+			List<Match> matches = new List<Match> ();
 
 			string note_text = buffer.GetSlice (buffer.StartIter,
 			                                    buffer.EndIter,

Modified: trunk/Tomboy/PrefsKeybinder.cs
==============================================================================
--- trunk/Tomboy/PrefsKeybinder.cs	(original)
+++ trunk/Tomboy/PrefsKeybinder.cs	Mon Jan 19 23:30:07 2009
@@ -1,16 +1,16 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 namespace Tomboy
 {
 	public class PrefsKeybinder
 	{
-		ArrayList bindings;
+		List<Binding> bindings;
 		IKeybinder native_keybinder;
 
 		public PrefsKeybinder ()
 		{
-			bindings = new ArrayList ();
+			bindings = new List<Binding> ();
 			native_keybinder = Services.Keybinder;
 		}
 

Modified: trunk/Tomboy/RecentChanges.cs
==============================================================================
--- trunk/Tomboy/RecentChanges.cs	(original)
+++ trunk/Tomboy/RecentChanges.cs	Mon Jan 19 23:30:07 2009
@@ -1,6 +1,5 @@
 
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.Text;
 using Mono.Unix;
@@ -31,9 +30,9 @@
                 Gtk.TreeModelSort store_sort;
 
                 /// <summary>
-                /// Stores search results as ArrayLists hashed by note uri.
+                /// Stores search results as integers hashed by note uri.
                 /// </summary>
-                Hashtable current_matches;
+                Dictionary<string, int> current_matches;
 
                 InterruptableTimeout entry_changed_timeout;
                 
@@ -52,7 +51,7 @@
                 static Gdk.Pixbuf all_notes_icon;
                 static Gdk.Pixbuf unfiled_notes_icon;
                 static Gdk.Pixbuf notebook_icon;
-                static ArrayList previous_searches;
+                static List<string> previous_searches;
                 static NoteRecentChanges instance;
 
                 static NoteRecentChanges ()
@@ -80,7 +79,7 @@
                         this.IconName = "tomboy";
                         this.DefaultWidth = 450;
                         this.DefaultHeight = 400;
-                        this.current_matches = new Hashtable ();
+                        this.current_matches = new Dictionary<string, int> ();
                         this.Resizable = true;
 
                         selected_tags = new Dictionary<Tag, Tag> ();
@@ -515,9 +514,8 @@
 
                         Note note = (Note) model.GetValue (iter, 3 /* note */);
                         if (note != null) {
-                                object matches = current_matches [note.Uri];
-                                if (matches != null) {
-                                        int match_count = (int) matches;
+                                int match_count;
+                                if (current_matches.TryGetValue (note.Uri, out match_count)) {
                                         if (match_count > 0) {
                                                 match_str = string.Format (
                                                                     Catalog.GetPluralString ("{0} match",
@@ -629,7 +627,7 @@
                         if (current_matches.Count == 0)
                                 return false;
 
-                        return note != null && current_matches [note.Uri] != null;
+                        return note != null && current_matches.ContainsKey (note.Uri);
                 }
 
                 void OnCaseSensitiveToggled (object sender, EventArgs args)
@@ -1036,17 +1034,19 @@
                                 return -1;
                         }
 
-                        object matches_a = current_matches [note_a.Uri];
-                        object matches_b = current_matches [note_b.Uri];
+			int matches_a;
+			int matches_b;
+			bool has_matches_a = current_matches.TryGetValue (note_a.Uri, out matches_a);
+			bool has_matches_b = current_matches.TryGetValue (note_b.Uri, out matches_b);
 
-                        if (matches_a == null || matches_b == null) {
-                                if (matches_a != null)
+                        if (!has_matches_a || !has_matches_b) {
+                                if (has_matches_a)
                                         return 1;
 
                                 return -1;
                         }
 
-                        int result = (int) matches_a - (int) matches_b;
+                        int result = matches_a - matches_b;
                         if (result == 0) {
                                 // Do a secondary sort by note title in alphabetical order
                                 result = CompareTitles (model, a, b);
@@ -1130,7 +1130,7 @@
                         // list, or shuffling an existing term to the top...
 
                         if (previous_searches == null)
-                                previous_searches = new ArrayList ();
+                                previous_searches = new List<string> ();
 
                         bool repeat = false;
 

Modified: trunk/Tomboy/RemoteControl.cs
==============================================================================
--- trunk/Tomboy/RemoteControl.cs	(original)
+++ trunk/Tomboy/RemoteControl.cs	Mon Jan 19 23:30:07 2009
@@ -1,6 +1,5 @@
 
 using System;
-using System.Collections;
 using System.Collections.Generic;
 #if ENABLE_DBUS
 using NDesk.DBus;
@@ -157,11 +156,11 @@
 
 		public string[] ListAllNotes ()
 		{
-			ArrayList uris = new ArrayList ();
+			List<string> uris = new List<string> ();
 			foreach (Note note in note_manager.Notes) {
 				uris.Add (note.Uri);
 			}
-			return (string []) uris.ToArray (typeof (string)) ;
+			return uris.ToArray ();
 		}
 
 		public string GetNoteContents (string uri)

Modified: trunk/Tomboy/Search.cs
==============================================================================
--- trunk/Tomboy/Search.cs	(original)
+++ trunk/Tomboy/Search.cs	Mon Jan 19 23:30:07 2009
@@ -1,6 +1,5 @@
 
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.Text;
 

Modified: trunk/Tomboy/Synchronization/SyncDialog.cs
==============================================================================
--- trunk/Tomboy/Synchronization/SyncDialog.cs	(original)
+++ trunk/Tomboy/Synchronization/SyncDialog.cs	Mon Jan 19 23:30:07 2009
@@ -1,5 +1,4 @@
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using Mono.Unix;
 

Modified: trunk/Tomboy/TagEntry.cs
==============================================================================
--- trunk/Tomboy/TagEntry.cs	(original)
+++ trunk/Tomboy/TagEntry.cs	Mon Jan 19 23:30:07 2009
@@ -2,7 +2,6 @@
 // User: kkubasik (Kevin Kubasik) at 9:24 PMÂ12/13/2007
 
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.Text;
 
@@ -239,7 +238,7 @@
 				//TagsAttached (this, new_tags.ToArray ());
 
 			// Remove any removed tags from the selected photos
-			ArrayList remove_tags = new ArrayList ();
+			List<Tag> remove_tags = new List<Tag> ();
 			foreach (string tagname in selected_photos_tagnames) {
 				if (! IsTagInList (tagnames, tagname)) {
 					Tag tag = TagManager.GetTag(tagname);

Modified: trunk/Tomboy/Tray.cs
==============================================================================
--- trunk/Tomboy/Tray.cs	(original)
+++ trunk/Tomboy/Tray.cs	Mon Jan 19 23:30:07 2009
@@ -1,5 +1,4 @@
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using Mono.Unix;
 using System.Runtime.InteropServices;

Modified: trunk/Tomboy/Trie.cs
==============================================================================
--- trunk/Tomboy/Trie.cs	(original)
+++ trunk/Tomboy/Trie.cs	Mon Jan 19 23:30:07 2009
@@ -8,7 +8,7 @@
 //
 
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 namespace Tomboy
 {
@@ -47,7 +47,7 @@
 		}
 
 		TrieState root;
-		ArrayList fail_states;
+		List<TrieState> fail_states;
 		bool      case_sensitive;
 		int       max_length;
 
@@ -56,7 +56,7 @@
 			this.case_sensitive = case_sensitive;
 
 			root = new TrieState ();
-			fail_states = new ArrayList (8);
+			fail_states = new List<TrieState> (8);
 		}
 
 		TrieState InsertMatchAtState (int depth, TrieState q, char c)
@@ -67,7 +67,7 @@
 
 			// Insert/Replace into fail_states at %depth
 			if (depth < fail_states.Count) {
-				new_q.Next = (TrieState) fail_states [depth];
+				new_q.Next = fail_states [depth];
 				fail_states [depth] = new_q;
 			} else {
 				fail_states.Insert (depth, new_q);
@@ -137,7 +137,7 @@
 			// Step 2: compute failure graph...
 
 			for (int idx = 0; idx < fail_states.Count; idx++) {
-				q = (TrieState) fail_states [idx];
+				q = fail_states [idx];
 
 				while (q != null) {
 					TrieMatch m = q.FirstMatch;
@@ -198,9 +198,9 @@
 		 * ENDFOR
 		 * RETURN FALSE
 		 */
-		public ArrayList FindMatches (string haystack)
+		public IList<TrieHit> FindMatches (string haystack)
 		{
-			ArrayList matches = new ArrayList (0);
+			List<TrieHit> matches = new List<TrieHit> ();
 			TrieState q = root;
 			TrieMatch m = null;
 			int idx = 0, start_idx = 0, last_idx = 0;

Modified: trunk/Tomboy/Undo.cs
==============================================================================
--- trunk/Tomboy/Undo.cs	(original)
+++ trunk/Tomboy/Undo.cs	Mon Jan 19 23:30:07 2009
@@ -1,6 +1,6 @@
 
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 namespace Tomboy
 {
@@ -36,17 +36,17 @@
 
 	public abstract class SplitterAction : EditAction
 	{
-		struct TagData {
+		public struct TagData {
 			public int start;
 			public int end;
 			public Gtk.TextTag tag;
 		};
-		protected ArrayList splitTags;
+		protected List<TagData> splitTags;
 		protected TextRange chop;
 
 		protected SplitterAction ()
 		{
-			this.splitTags = new ArrayList();
+			this.splitTags = new List<TagData> ();
 		}
 
 		public TextRange Chop
@@ -56,7 +56,7 @@
 			}
 		}
 
-		public ArrayList SplitTags
+		public List<TagData> SplitTags
 		{
 			get {
 				return splitTags;
@@ -552,15 +552,15 @@
 		NoteBuffer buffer;
 		ChopBuffer chop_buffer;
 
-		Stack undo_stack;
-		Stack redo_stack;
+		Stack<EditAction> undo_stack;
+		Stack<EditAction> redo_stack;
 
 		public UndoManager (NoteBuffer buffer)
 		{
 			frozen_cnt = 0;
 			try_merge = false;
-			undo_stack = new Stack ();
-			redo_stack = new Stack ();
+			undo_stack = new Stack<EditAction> ();
+			redo_stack = new Stack<EditAction> ();
 
 			this.buffer = buffer;
 			chop_buffer = new ChopBuffer (buffer.TagTable);
@@ -609,7 +609,7 @@
 			--frozen_cnt;
 		}
 
-		void UndoRedo (Stack pop_from, Stack push_to, bool is_undo)
+		void UndoRedo (Stack<EditAction> pop_from, Stack<EditAction> push_to, bool is_undo)
 		{
 			if (pop_from.Count > 0) {
 				EditAction action = (EditAction) pop_from.Pop ();
@@ -632,7 +632,7 @@
 			}
 		}
 
-		void ClearActionStack (Stack stack)
+		void ClearActionStack (Stack<EditAction> stack)
 		{
 			foreach (EditAction action in stack) {
 				action.Destroy ();
@@ -652,7 +652,7 @@
 		public void AddUndoAction (EditAction action)
 		{
 			if (try_merge && undo_stack.Count > 0) {
-				EditAction top = (EditAction) undo_stack.Peek ();
+				EditAction top = undo_stack.Peek ();
 
 				if (top.CanMerge (action)) {
 					// Merging object should handle freeing

Modified: trunk/Tomboy/Utils.cs
==============================================================================
--- trunk/Tomboy/Utils.cs	(original)
+++ trunk/Tomboy/Utils.cs	Mon Jan 19 23:30:07 2009
@@ -1,6 +1,7 @@
 
 using System;
 using System.Collections;
+using System.Collections.Generic;
 using System.Runtime.InteropServices;
 using System.Text;
 using System.IO;
@@ -439,7 +440,7 @@
 		}
 	}
 
-	public class UriList : ArrayList
+	public class UriList : List<Uri>
 	{
 		public UriList (Note [] notes)
 		{

Modified: trunk/Tomboy/Watchers.cs
==============================================================================
--- trunk/Tomboy/Watchers.cs	(original)
+++ trunk/Tomboy/Watchers.cs	Mon Jan 19 23:30:07 2009
@@ -1,6 +1,6 @@
 
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 using System.Runtime.InteropServices;
 using System.Text.RegularExpressions;
@@ -783,7 +783,7 @@
 
 		void HighlightInBlock (Gtk.TextIter start, Gtk.TextIter end)
 		{
-			ArrayList hits = Manager.TitleTrie.FindMatches (start.GetSlice (end));
+			IList<TrieHit> hits = Manager.TitleTrie.FindMatches (start.GetSlice (end));
 			foreach (TrieHit hit in hits) {
 				DoHighlight (hit, start, end);
 			}

Modified: trunk/Tomboy/XKeybinder.cs
==============================================================================
--- trunk/Tomboy/XKeybinder.cs	(original)
+++ trunk/Tomboy/XKeybinder.cs	Mon Jan 19 23:30:07 2009
@@ -1,5 +1,5 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.Runtime.InteropServices;
 
 namespace Tomboy
@@ -20,7 +20,7 @@
 		public delegate void BindkeyHandler (string key, IntPtr user_data);
 
 		// TODO: Change to IList<T>
-		ArrayList      bindings;
+		List<Binding> bindings;
 		BindkeyHandler key_handler;
 
 		struct Binding {
@@ -30,7 +30,7 @@
 
 		public XKeybinder ()
 		{
-			bindings = new ArrayList ();
+			bindings = new List<Binding> ();
 			key_handler = new BindkeyHandler (KeybindingPressed);
 
 			tomboy_keybinder_init ();



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