[Monodevelop-patches-list] r1986 - in trunk/MonoDevelop/Core/src/Main/Base: . Commands Services/File Services/Project
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Wed Oct 20 21:27:58 EDT 2004
Author: jluke
Date: 2004-10-20 21:27:57 -0400 (Wed, 20 Oct 2004)
New Revision: 1986
Modified:
trunk/MonoDevelop/Core/src/Main/Base/ChangeLog
trunk/MonoDevelop/Core/src/Main/Base/Commands/AutostartCommands.cs
trunk/MonoDevelop/Core/src/Main/Base/Commands/FileCommands.cs
trunk/MonoDevelop/Core/src/Main/Base/Commands/MenuItemBuilders.cs
trunk/MonoDevelop/Core/src/Main/Base/Services/File/DefaultFileService.cs
trunk/MonoDevelop/Core/src/Main/Base/Services/File/RecentOpen.cs
trunk/MonoDevelop/Core/src/Main/Base/Services/Project/DefaultProjectService.cs
Log:
2004-10-20 John Luke <john.luke at gmail.com>
* Commands/MenuItemBuilders.cs:
* Commands/FileCommands.cs:
* Commands/AutostartCommands.cs:
* Services/File/RecentOpen.cs:
* Services/File/DefaultFileService.cs:
* Services/Project/DefaultProjectService.cs: enable new Recent Files stuff,
and small adjustments for it.
Modified: trunk/MonoDevelop/Core/src/Main/Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/Main/Base/ChangeLog 2004-10-20 18:45:32 UTC (rev 1985)
+++ trunk/MonoDevelop/Core/src/Main/Base/ChangeLog 2004-10-21 01:27:57 UTC (rev 1986)
@@ -1,5 +1,15 @@
2004-10-20 John Luke <john.luke at gmail.com>
+ * Commands/MenuItemBuilders.cs:
+ * Commands/FileCommands.cs:
+ * Commands/AutostartCommands.cs:
+ * Services/File/RecentOpen.cs:
+ * Services/File/DefaultFileService.cs:
+ * Services/Project/DefaultProjectService.cs: enable new Recent Files stuff,
+ and small adjustments for it.
+
+2004-10-20 John Luke <john.luke at gmail.com>
+
* Services/File/RecentFiles.cs: fix a bunch of bugs
2004-10-20 John Luke <john.luke at gmail.com>
Modified: trunk/MonoDevelop/Core/src/Main/Base/Commands/AutostartCommands.cs
===================================================================
--- trunk/MonoDevelop/Core/src/Main/Base/Commands/AutostartCommands.cs 2004-10-20 18:45:32 UTC (rev 1985)
+++ trunk/MonoDevelop/Core/src/Main/Base/Commands/AutostartCommands.cs 2004-10-21 01:27:57 UTC (rev 1986)
@@ -62,7 +62,7 @@
object recentOpenObj = propertyService.GetProperty("MonoDevelop.Gui.MainWindow.RecentOpen");
if (recentOpenObj is MonoDevelop.Services.RecentOpen) {
MonoDevelop.Services.RecentOpen recOpen = (MonoDevelop.Services.RecentOpen)recentOpenObj;
- if (recOpen.RecentProject.Count > 0) {
+ if (recOpen.RecentProject != null && recOpen.RecentProject.Length > 0) {
projectService.OpenCombine(recOpen.RecentProject[0].ToString());
}
}
Modified: trunk/MonoDevelop/Core/src/Main/Base/Commands/FileCommands.cs
===================================================================
--- trunk/MonoDevelop/Core/src/Main/Base/Commands/FileCommands.cs 2004-10-20 18:45:32 UTC (rev 1985)
+++ trunk/MonoDevelop/Core/src/Main/Base/Commands/FileCommands.cs 2004-10-21 01:27:57 UTC (rev 1986)
@@ -395,7 +395,7 @@
IFileService fileService = (IFileService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(IFileService));
IMessageService messageService = (IMessageService) MonoDevelop.Core.Services.ServiceManager.GetService(typeof(IMessageService));
- if (fileService.RecentOpen.RecentFile != null && fileService.RecentOpen.RecentFile.Count > 0 && messageService.AskQuestion(GettextCatalog.GetString ("Are you sure you want to clear recent files list?"), GettextCatalog.GetString ("Clear recent files")))
+ if (fileService.RecentOpen.RecentFile != null && fileService.RecentOpen.RecentFile.Length > 0 && messageService.AskQuestion(GettextCatalog.GetString ("Are you sure you want to clear recent files list?"), GettextCatalog.GetString ("Clear recent files")))
{
fileService.RecentOpen.ClearRecentFiles();
}
@@ -411,7 +411,7 @@
IFileService fileService = (IFileService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(IFileService));
IMessageService messageService = (IMessageService) MonoDevelop.Core.Services.ServiceManager.GetService(typeof(IMessageService));
- if (fileService.RecentOpen.RecentProject != null && fileService.RecentOpen.RecentProject.Count > 0 && messageService.AskQuestion(GettextCatalog.GetString ("Are you sure you want to clear recent projects list?"), GettextCatalog.GetString ("Clear recent projects")))
+ if (fileService.RecentOpen.RecentProject != null && fileService.RecentOpen.RecentProject.Length > 0 && messageService.AskQuestion(GettextCatalog.GetString ("Are you sure you want to clear recent projects list?"), GettextCatalog.GetString ("Clear recent projects")))
{
fileService.RecentOpen.ClearRecentProjects();
}
Modified: trunk/MonoDevelop/Core/src/Main/Base/Commands/MenuItemBuilders.cs
===================================================================
--- trunk/MonoDevelop/Core/src/Main/Base/Commands/MenuItemBuilders.cs 2004-10-20 18:45:32 UTC (rev 1985)
+++ trunk/MonoDevelop/Core/src/Main/Base/Commands/MenuItemBuilders.cs 2004-10-21 01:27:57 UTC (rev 1986)
@@ -52,10 +52,10 @@
RecentOpen recentOpen = fileService.RecentOpen;
- if (recentOpen.RecentFile.Count > 0) {
- RFMItem[] items = new RFMItem[recentOpen.RecentFile.Count];
+ if (recentOpen.RecentFile != null && recentOpen.RecentFile.Length > 0) {
+ RFMItem[] items = new RFMItem[recentOpen.RecentFile.Length];
- for (int i = 0; i < recentOpen.RecentFile.Count; ++i) {
+ for (int i = 0; i < recentOpen.RecentFile.Length; ++i) {
string accelaratorKeyPrefix = i < 10 ? "&" + ((i + 1) % 10).ToString() + " " : "";
items[i] = new RFMItem(null, null, accelaratorKeyPrefix + recentOpen.RecentFile[i].ToString().Replace ("_", "__"), new EventHandler(LoadRecentFile));
items[i].Tag = recentOpen.RecentFile[i].ToString();
@@ -93,9 +93,9 @@
RecentOpen recentOpen = fileService.RecentOpen;
- if (recentOpen.RecentProject.Count > 0) {
- RPMItem[] items = new RPMItem[recentOpen.RecentProject.Count];
- for (int i = 0; i < recentOpen.RecentProject.Count; ++i) {
+ if (recentOpen.RecentProject != null && recentOpen.RecentProject.Length > 0) {
+ RPMItem[] items = new RPMItem[recentOpen.RecentProject.Length];
+ for (int i = 0; i < recentOpen.RecentProject.Length; ++i) {
string accelaratorKeyPrefix = i < 10 ? "&" + ((i + 1) % 10).ToString() + " " : "";
items[i] = new RPMItem(null, null, accelaratorKeyPrefix + recentOpen.RecentProject[i].ToString().Replace ("_", "__"), new EventHandler(LoadRecentProject));
items[i].Tag = recentOpen.RecentProject[i].ToString();
Modified: trunk/MonoDevelop/Core/src/Main/Base/Services/File/DefaultFileService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/Main/Base/Services/File/DefaultFileService.cs 2004-10-20 18:45:32 UTC (rev 1985)
+++ trunk/MonoDevelop/Core/src/Main/Base/Services/File/DefaultFileService.cs 2004-10-21 01:27:57 UTC (rev 1986)
@@ -12,13 +12,10 @@
using System.Xml;
using MonoDevelop.Core.AddIns;
-
using MonoDevelop.Core.Services;
-
using MonoDevelop.Internal.Project;
using MonoDevelop.Gui;
using MonoDevelop.Core.AddIns.Codons;
-
using MonoDevelop.Gui.Utils;
namespace MonoDevelop.Services
@@ -37,10 +34,8 @@
public RecentOpen RecentOpen {
get {
- if (recentOpen == null) {
- PropertyService propertyService = (PropertyService)ServiceManager.GetService(typeof(PropertyService));
- recentOpen = (RecentOpen)propertyService.GetProperty("MonoDevelop.Gui.MainWindow.RecentOpen", new RecentOpen());
- }
+ if (recentOpen == null)
+ recentOpen = new RecentOpen ();
return recentOpen;
}
}
@@ -116,6 +111,10 @@
return;
string origName = fileName;
+
+ if (fileName.StartsWith ("file://"))
+ fileName = fileName.Substring (7);
+
if (!fileName.StartsWith ("http://"))
fileName = System.IO.Path.GetFullPath (fileName);
Modified: trunk/MonoDevelop/Core/src/Main/Base/Services/File/RecentOpen.cs
===================================================================
--- trunk/MonoDevelop/Core/src/Main/Base/Services/File/RecentOpen.cs 2004-10-20 18:45:32 UTC (rev 1985)
+++ trunk/MonoDevelop/Core/src/Main/Base/Services/File/RecentOpen.cs 2004-10-21 01:27:57 UTC (rev 1986)
@@ -12,38 +12,38 @@
using System.IO;
using MonoDevelop.Core.Properties;
-
+using MonoDevelop.Gui.Utils;
using MonoDevelop.Services;
+using Freedesktop.RecentFiles;
namespace MonoDevelop.Services
{
/// <summary>
- /// This class handles the recent open files and the recent open project files of SharpDevelop
- /// it checks, if the files exists at every creation, and if not it doesn't list them in the
- /// recent files, and they'll not be saved during the next option save.
+ /// This class handles the recent open files and the recent open project files of MonoDevelop
/// </summary>
- public class RecentOpen : IXmlConvertable
+ public class RecentOpen
{
/// <summary>
/// This variable is the maximal length of lastfile/lastopen entries
/// must be > 0
/// </summary>
- int MAX_LENGTH = 10;
+ const int MAX_LENGTH = 10;
- ArrayList lastfile = new ArrayList();
- ArrayList lastproject = new ArrayList();
+ RecentItem[] lastfile;
+ RecentItem[] lastproject;
+ RecentFiles recentFiles;
public event EventHandler RecentFileChanged;
public event EventHandler RecentProjectChanged;
- public ArrayList RecentFile {
+ public RecentItem[] RecentFile {
get {
Debug.Assert(lastfile != null, "RecentOpen : set string[] LastFile (value == null)");
return lastfile;
}
}
- public ArrayList RecentProject {
+ public RecentItem[] RecentProject {
get {
Debug.Assert(lastproject != null, "RecentOpen : set string[] LastProject (value == null)");
return lastproject;
@@ -66,134 +66,84 @@
public RecentOpen()
{
+ recentFiles = RecentFiles.GetInstance ();
+ UpdateLastFile ();
+ UpdateLastProject ();
}
- public RecentOpen(XmlElement element)
+ public void AddLastFile (string name)
{
- XmlNodeList nodes = element["FILES"].ChildNodes;
-
- for (int i = 0; i < nodes.Count; ++i) {
- if (File.Exists(nodes[i].InnerText)) {
- lastfile.Add(nodes[i].InnerText);
+ if (lastfile != null && lastfile.Length >= MAX_LENGTH)
+ {
+ RecentItem oldestItem = lastfile[0];
+ for (int i = 1; i < lastfile.Length - 1; i ++)
+ {
+ // the lowest number is the oldest
+ if (lastfile[i].Timestamp < oldestItem.Timestamp)
+ oldestItem = lastfile[i];
}
+ recentFiles.RemoveItem (oldestItem);
}
-
- nodes = element["PROJECTS"].ChildNodes;
-
- for (int i = 0; i < nodes.Count; ++i) {
- if (File.Exists(nodes[i].InnerText)) {
- lastproject.Add(nodes[i].InnerText);
- }
- }
+
+ recentFiles.AddItem (new RecentItem (new Uri (name), Vfs.GetMimeType (name), "MonoDevelop Files"));
+ UpdateLastFile ();
}
- public void AddLastFile(string name) // TODO : improve
- {
- for (int i = 0; i < lastfile.Count; ++i) {
- if (lastfile[i].ToString() == name) {
- lastfile.RemoveAt(i);
- }
- }
-
- while (lastfile.Count >= MAX_LENGTH) {
- lastfile.RemoveAt(lastfile.Count - 1);
- }
-
- if (lastfile.Count > 0) {
- lastfile.Insert(0, name);
- } else {
- lastfile.Add(name);
- }
-
- OnRecentFileChange();
- }
-
public void ClearRecentFiles()
{
- lastfile.Clear();
-
+ lastfile = null;
+ recentFiles.ClearGroup ("MonoDevelop Files");
OnRecentFileChange();
}
public void ClearRecentProjects()
{
- lastproject.Clear();
-
+ lastproject = null;
+ recentFiles.ClearGroup ("MonoDevelop Projects");
OnRecentProjectChange();
}
- public void AddLastProject(string name) // TODO : improve
+ public void AddLastProject (string name)
{
- for (int i = 0; i < lastproject.Count; ++i) {
- if (lastproject[i].ToString() == name) {
- lastproject.RemoveAt(i);
+ if (lastproject != null && lastproject.Length >= MAX_LENGTH)
+ {
+ RecentItem oldestItem = lastproject[0];
+ for (int i = 1; i < lastproject.Length; i ++)
+ {
+ // the lowest number is the oldest
+ if (lastproject[i].Timestamp < oldestItem.Timestamp)
+ oldestItem = lastproject[i];
}
+ recentFiles.RemoveItem (oldestItem);
}
-
- while (lastproject.Count >= MAX_LENGTH) {
- lastproject.RemoveAt(lastproject.Count - 1);
- }
-
- if (lastproject.Count > 0) {
- lastproject.Insert(0, name);
- } else {
- lastproject.Add(name);
- }
- OnRecentProjectChange();
+
+ recentFiles.AddItem (new RecentItem (new Uri (name), Vfs.GetMimeType (name), "MonoDevelop Projects"));
+ UpdateLastProject ();
}
- public object FromXmlElement(XmlElement element)
+ public void FileRemoved(object sender, FileEventArgs e)
{
- return new RecentOpen(element);
+ recentFiles.RemoveItem (new Uri (e.FileName));
+ UpdateLastFile ();
}
- public XmlElement ToXmlElement(XmlDocument doc)
+ public void FileRenamed(object sender, FileEventArgs e)
{
- XmlElement recent = doc.CreateElement("RECENT");
-
- XmlElement lastfiles = doc.CreateElement("FILES");
- foreach (string file in lastfile) {
- XmlElement element = doc.CreateElement("FILE");
- element.InnerText = file;
- lastfiles.AppendChild(element);
- }
-
- XmlElement lastprojects = doc.CreateElement("PROJECTS");
- foreach (string project in lastproject) {
- XmlElement element = doc.CreateElement("PROJECT");
- element.InnerText = project;
- lastprojects.AppendChild(element);
- }
-
- recent.AppendChild(lastfiles);
- recent.AppendChild(lastprojects);
-
- return recent;
+ recentFiles.RenameItem (new Uri (e.FileName), new Uri (e.TargetFile));
+ UpdateLastFile ();
}
-
- public void FileRemoved(object sender, FileEventArgs e)
+
+ void UpdateLastFile ()
{
- for (int i = 0; i < lastfile.Count; ++i) {
- string file = lastfile[i].ToString();
- if (e.FileName == file) {
- lastfile.RemoveAt(i);
- OnRecentFileChange();
- break;
- }
- }
+ lastfile = recentFiles.GetItemsInGroup ("MonoDevelop Files");
+ OnRecentFileChange();
}
-
- public void FileRenamed(object sender, FileEventArgs e)
+
+ void UpdateLastProject ()
{
- for (int i = 0; i < lastfile.Count; ++i) {
- string file = lastfile[i].ToString();
- if (e.SourceFile == file) {
- lastfile.RemoveAt(i);
- lastfile.Insert(i, e.TargetFile);
- OnRecentFileChange();
- break;
- }
- }
+ lastproject = recentFiles.GetItemsInGroup ("MonoDevelop Projects");
+ OnRecentFileChange();
}
}
}
+
Modified: trunk/MonoDevelop/Core/src/Main/Base/Services/Project/DefaultProjectService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/Main/Base/Services/Project/DefaultProjectService.cs 2004-10-20 18:45:32 UTC (rev 1985)
+++ trunk/MonoDevelop/Core/src/Main/Base/Services/Project/DefaultProjectService.cs 2004-10-21 01:27:57 UTC (rev 1986)
@@ -128,6 +128,9 @@
SaveCombine();
CloseCombine();
}
+
+ if (filename.StartsWith ("file://"))
+ filename = filename.Substring (7);
if (!fileUtilityService.TestFileExists(filename)) {
return;
More information about the Monodevelop-patches-list
mailing list