[Monodevelop-patches-list] r1336 - trunk/MonoDevelop/src/Main/Base/Services/File
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Thu Apr 1 16:30:51 EST 2004
Author: jluke
Date: 2004-04-01 16:30:51 -0500 (Thu, 01 Apr 2004)
New Revision: 1336
Modified:
trunk/MonoDevelop/src/Main/Base/Services/File/FdoRecentFiles.cs
trunk/MonoDevelop/src/Main/Base/Services/File/RecentItem.cs
Log:
update
Modified: trunk/MonoDevelop/src/Main/Base/Services/File/FdoRecentFiles.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/File/FdoRecentFiles.cs 2004-04-01 21:30:30 UTC (rev 1335)
+++ trunk/MonoDevelop/src/Main/Base/Services/File/FdoRecentFiles.cs 2004-04-01 21:30:51 UTC (rev 1336)
@@ -17,32 +17,26 @@
{
public class FdoRecentFiles
{
- // The document should be stored in "~/.recently-used",
-
- // and it should contain no more than 500 items.
- int totalMaxLength = 500;
-
// MD only wants to save last 10 in its group
- int maxLength = 10;
- ArrayList lastfile = new ArrayList();
- ArrayList lastproject = new ArrayList();
+ ArrayList lastFiles = new ArrayList (10); // max 10
+ ArrayList lastProjects = new ArrayList (10); // max 10
+ ArrayList allRecents = new ArrayList (10); // max 500
- XmlDocument doc;
+ XPathDocument doc;
public event EventHandler RecentFileChanged;
public event EventHandler RecentProjectChanged;
public FdoRecentFiles ()
{
- string recentFile = Environment.GetEnvironmentVariable ("HOME");
- recentFile = Path.Combine (recentFile, ".recently_used");
- Console.WriteLine (recentFile);
+ // The document should be stored in "~/.recently-used",
+ string recentFile = Path.Combine (Environment.GetEnvironmentVariable ("HOME"), ".recently_used");
+ //Console.WriteLine (recentFile);
if (File.Exists (recentFile))
{
// use POSIX lockf ()
- doc = new XmlDocument ();
- doc.Load (recentFile);
+ doc = new XPathDocument (recentFile);
XPathNavigator nav = doc.CreateNavigator ();
XPathNodeIterator xni = nav.Select ("/RecentFiles/RecentItem");
@@ -55,8 +49,8 @@
// create it
}
- FileSystemWatcher watcher = new FileSystemWatcher (recentFile);
- watcher.Changed += new FileSystemEventHandler (OnWatcherChanged);
+ //FileSystemWatcher watcher = new FileSystemWatcher (recentFile);
+ //watcher.Changed += new FileSystemEventHandler (OnWatcherChanged);
}
void OnWatcherChanged (object o, FileSystemEventArgs args)
@@ -86,7 +80,7 @@
{
get
{
- return lastfile;
+ return lastFiles;
}
}
@@ -94,7 +88,7 @@
{
get
{
- return lastproject;
+ return lastProjects;
}
}
@@ -104,24 +98,54 @@
{
// uri must be unique
// or just update timestamp and group
+ foreach (RecentItem recentItem in allRecents)
+ {
+ if (recentItem.Uri == file_uri)
+ {
+ recentItem.Update (false);
+ lastFiles.Add (recentItem);
+ return;
+ }
+ }
+
RecentItem ri = new RecentItem (file_uri);
+ ri.Group = "MonoDevelop Files";
+ lastFiles.Add (ri);
}
public void AddProject (string file_uri)
{
// uri must be unique
// or just update timestamp and group
+ foreach (RecentItem recentItem in allRecents)
+ {
+ if (recentItem.Uri == file_uri)
+ {
+ recentItem.Update (true);
+ lastProjects.Add (recentItem);
+ return;
+ }
+ }
+
RecentItem ri = new RecentItem (file_uri);
+ ri.Group = "MonoDevelop Projects";
+ lastProjects.Add (ri);
}
// spec doesn't mention removal
public void ClearFiles ()
{
+ lastFiles.Clear ();
+ // remove from allRecents
+ // write the file
}
// spec doesn't mention removal
public void ClearProjects ()
{
+ lastProjects.Clear ();
+ // remove from allRecents
+ // write the file
}
}
}
Modified: trunk/MonoDevelop/src/Main/Base/Services/File/RecentItem.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/File/RecentItem.cs 2004-04-01 21:30:30 UTC (rev 1335)
+++ trunk/MonoDevelop/src/Main/Base/Services/File/RecentItem.cs 2004-04-01 21:30:51 UTC (rev 1336)
@@ -33,6 +33,17 @@
this.timestamp = ((int) (now - epoch).TotalSeconds).ToString ();
}
+ // update the group and timestamp
+ public void Update (bool project)
+ {
+ DateTime now = DateTime.UtcNow;
+ this.timestamp = ((int) (now - epoch).TotalSeconds).ToString ();
+ if (project)
+ this.group = "MonoDevelop Projects";
+ else
+ this.group = "MonoDevelop Files";
+ }
+
public string Mime
{
get { return mime; }
@@ -51,6 +62,7 @@
public string Group
{
get { return group; }
+ set { group = value; }
}
}
}
More information about the Monodevelop-patches-list
mailing list