[MonoDevelop] PATCH: Enable filering in open dialog

Lluis Sanchez lluis at ximian.com
Thu Mar 16 06:06:29 EST 2006


El jue, 16-03-2006 a las 10:15 +0100, "David Makovský (Yakeen)"
escribió:
> Hi all,
> 
> can someone look at it? Any suggestions?
> Does someone have idea how to add other types like HTML which has not
> Language Binding?
> Or should be code files be grouped?

There is an extension element for specifying filters
(/SharpDevelop/Workbench/FileFilter) which is not being used right now.
Maybe we should implement support for it.

> 
> Regards,
> David
> 
> documento de texto sencillo adjunto (fileselector-filters.patch)
> Index: Core/src/MonoDevelop.Projects/MonoDevelop.Projects/ILanguageBinding.cs
> ===================================================================
> --- Core/src/MonoDevelop.Projects/MonoDevelop.Projects/ILanguageBinding.cs	(revision 57975)
> +++ Core/src/MonoDevelop.Projects/MonoDevelop.Projects/ILanguageBinding.cs	(working copy)
> @@ -23,6 +23,11 @@
>  		/// The language for this language binding.
>  		/// </returns>
>  		string Language { get; }
> +
> +		/// <returns>
> +		/// Supported MIME Types by this language binding.
> +		/// </returns>
> +		string[] MimeTypes { get; }
>  		
>  		/// <summary>
>  		/// Used by Comment and Uncomment operations and by Centaurus Addin.
> Index: Core/src/MonoDevelop.Projects/ChangeLog
> ===================================================================
> --- Core/src/MonoDevelop.Projects/ChangeLog	(revision 57975)
> +++ Core/src/MonoDevelop.Projects/ChangeLog	(working copy)
> @@ -1,3 +1,7 @@
> +2006-03-16 David Makovský (Yakeen) <yakeen at sannyas-on.net>
> +
> +	* MonoDevelop.Projects/ILanguageBinding.cs: Added MimeTypes property to interface
> +
>  2006-03-08 Lluis Sanchez Gual  <lluis at novell.com>
>  
>  	* MonoDevelop.Projects.Text/TextFile.cs: Some small improvements.
> Index: Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs
> ===================================================================
> --- Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs	(revision 57975)
> +++ Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs	(working copy)
> @@ -84,37 +84,35 @@
>  	{
>  		protected override void Run()
>  		{
> -			//string[] fileFilters  = (string[])(AddInTreeSingleton.AddInTree.GetTreeNode("/SharpDevelop/Workbench/FileFilter").BuildChildItems(this)).ToArray(typeof(string));
> -			//bool foundFilter      = false;
> -			// search filter like in the current selected project
> -			/*
> -			IProjectService projectService = (IProjectService)MonoDevelop.Core.ServiceManager.GetService(typeof(IProjectService));
> -			
> -			if (projectService.CurrentSelectedProject != null) {
> -				LanguageBindingService languageBindingService = (LanguageBindingService)MonoDevelop.Core.ServiceManager.GetService(typeof(LanguageBindingService));
> +			using (FileSelector fs = new FileSelector (GettextCatalog.GetString ("File to Open"))) {
>  				
> -				LanguageBindingCodon languageCodon = languageBindingService.GetCodonPerLanguageName(projectService.CurrentSelectedProject.ProjectType);
> -				for (int i = 0; !foundFilter && i < fileFilters.Length; ++i) {
> -					for (int j = 0; !foundFilter && j < languageCodon.Supportedextensions.Length; ++j) {
> -						if (fileFilters[i].IndexOf(languageCodon.Supportedextensions[j]) >= 0) {
> -							break;
> -						}
> -					}
> +				// Soluton/Project Files Filter
> +				Gtk.FileFilter projectsFilter = new Gtk.FileFilter ();
> +				projectsFilter.Name = GettextCatalog.GetString ("Solution/Project Files");
> +				projectsFilter.AddPattern ("*.mds");
> +				projectsFilter.AddPattern ("*.mdp");
> +				fs.AddFilter (projectsFilter);
> +				
> +				// Supported Language Files
> +				LanguageBindingService languageBindingService = (LanguageBindingService)MonoDevelop.Core.ServiceManager.GetService (typeof (LanguageBindingService));
> +				ILanguageBinding[] languageBindings = languageBindingService.GetLanguageBindings ();
> +				foreach (ILanguageBinding lb in languageBindings)
> +				{
> +					Gtk.FileFilter filter = new Gtk.FileFilter ();
> +					filter.Name = String.Format (GettextCatalog.GetString ("{0} Files"), lb.Language);
> +					filter.AddPattern (lb.GetFileName ("*"));
> +					foreach (string mimeType in lb.MimeTypes)
> +						filter.AddMimeType (mimeType);
> +					fs.AddFilter (filter);
>  				}
> -			}
> -			
> -			// search filter like in the current open file
> -			if (!foundFilter) {
> -				IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
> -				if (window != null) {
> -					for (int i = 0; i < fileFilters.Length; ++i) {
> -						if (fileFilters[i].IndexOf(Path.GetExtension(window.ViewContent.ContentName == null ? window.ViewContent.UntitledName : window.ViewContent.ContentName)) >= 0) {
> -							break;
> -						}
> -					}
> -				}
> -			}*/
> -			using (FileSelector fs = new FileSelector (GettextCatalog.GetString ("File to Open"))) {
> +
> +				// Show All Files
> +				Gtk.FileFilter allFilter = new Gtk.FileFilter ();
> +				allFilter.Name = GettextCatalog.GetString ("All Files");
> +				allFilter.AddPattern ("*");
> +				fs.AddFilter (allFilter);
> +
> +
>  				int response = fs.Run ();
>  				string name = fs.Filename;
>  				fs.Hide ();
> Index: Core/src/MonoDevelop.Ide/ChangeLog
> ===================================================================
> --- Core/src/MonoDevelop.Ide/ChangeLog	(revision 57975)
> +++ Core/src/MonoDevelop.Ide/ChangeLog	(working copy)
> @@ -1,3 +1,7 @@
> +2006-03-16 David Makovský (Yakeen) <yakeen at sannyas-on.net>
> +
> +	* MonoDevelop.Ide.Commands/FileCommands.cs: Added filtering to Open dialog.
> +
>  2006-03-14 Michael Hutchinson  <m.j.hutchinson at gmail.com>
>  
>  	* MonoDevelop.Ide.Gui.Dialogs/IncludeFilesDialog.cs:
> Index: Extras/ILAsmBinding/ChangeLog
> ===================================================================
> --- Extras/ILAsmBinding/ChangeLog	(revision 57975)
> +++ Extras/ILAsmBinding/ChangeLog	(working copy)
> @@ -1,3 +1,7 @@
> +2006-03-16 David Makovský (Yakeen) <yakeen at sannyas-on.net>
> +
> +	* ILAsmLanguageBinding.cs: Track changes in ILanguageBinding.
> +
>  2005-12-13  Lluis Sanchez Gual  <lluis at novell.com> 
>  
>  	* ILAsmLanguageBinding.cs: Implemented the new methods in
> Index: Extras/ILAsmBinding/ILAsmLanguageBinding.cs
> ===================================================================
> --- Extras/ILAsmBinding/ILAsmLanguageBinding.cs	(revision 57975)
> +++ Extras/ILAsmBinding/ILAsmLanguageBinding.cs	(working copy)
> @@ -26,6 +26,7 @@
>  	public class ILAsmLanguageBinding : IDotNetLanguageBinding
>  	{
>  		public const string LanguageName = "ILAsm";
> +		private static readonly string[] mimeTypes = { "text/x-msil" };
>  		
>  		ILAsmCompilerManager  compilerManager  = new ILAsmCompilerManager();
>  		
> @@ -34,6 +35,12 @@
>  				return LanguageName;
>  			}
>  		}
> +
> +		public string[] MimeTypes {
> +				get {
> +					return mimeTypes;
> +				}
> +		}
>  		
>  		public bool IsSourceCodeFile (string fileName)
>  		{
> Index: Extras/VBNetBinding/ChangeLog
> ===================================================================
> --- Extras/VBNetBinding/ChangeLog	(revision 57975)
> +++ Extras/VBNetBinding/ChangeLog	(working copy)
> @@ -1,3 +1,7 @@
> +2006-03-16 David Makovský (Yakeen) <yakeen at sannyas-on.net>
> +
> +	* VBLanguageBinding.cs: Track changes in ILanguageBinding.
> +
>  2006-01-30 Lluis Sanchez Gual  <lluis at novell.com>   
>  
>  	* VBBindingCompilerServices.cs:
> Index: Extras/VBNetBinding/VBLanguageBinding.cs
> ===================================================================
> --- Extras/VBNetBinding/VBLanguageBinding.cs	(revision 57975)
> +++ Extras/VBNetBinding/VBLanguageBinding.cs	(working copy)
> @@ -23,7 +23,8 @@
>  {
>  	public class VBLanguageBinding : IDotNetLanguageBinding
>  	{
> -		public const string LanguageName = "VBNet";
> +		public const string LanguageName = "VBNet";
> +		private static readonly string[] mimeTypes = { "text/x-vb" };
>  		
>  		VBBindingCompilerServices   compilerServices  = new VBBindingCompilerServices();
>  		VBCodeProvider provider;
> @@ -33,6 +34,12 @@
>  			get {
>  				return LanguageName;
>  			}
> +		}
> +
> +		public string[] MimeTypes {
> +				get {
> +					return mimeTypes;
> +				}
>  		}
>  		
>  		public bool IsSourceCodeFile (string fileName)
> Index: Extras/CSharpBinding/CSharpLanguageBinding.cs
> ===================================================================
> --- Extras/CSharpBinding/CSharpLanguageBinding.cs	(revision 57975)
> +++ Extras/CSharpBinding/CSharpLanguageBinding.cs	(working copy)
> @@ -28,6 +28,7 @@
>  	public class CSharpLanguageBinding : IDotNetLanguageBinding
>  	{
>  		public const string LanguageName = "C#";
> +		private static readonly string[] mimeTypes = { "text/x-csharp" };
>  		
>  		CSharpBindingCompilerManager   compilerManager  = new CSharpBindingCompilerManager();
>  		CSharpCodeProvider provider;
> @@ -38,6 +39,12 @@
>  			}
>  		}
>  		
> +		public string[] MimeTypes {
> +				get {
> +					return mimeTypes;
> +				}
> +		}
> +
>  		public bool IsSourceCodeFile (string fileName)
>  		{
>  			Debug.Assert(compilerManager != null);
> Index: Extras/CSharpBinding/ChangeLog
> ===================================================================
> --- Extras/CSharpBinding/ChangeLog	(revision 57975)
> +++ Extras/CSharpBinding/ChangeLog	(working copy)
> @@ -1,3 +1,7 @@
> +2006-03-16 David Makovský (Yakeen) <yakeen at sannyas-on.net>
> +
> +	* CSharpLanguageBinding.cs: Track changes in ILanguageBinding.
> +
>  2006-03-08 Lluis Sanchez Gual  <lluis at novell.com>   
>  
>  	* Parser/CodeGenerator.cs: Fixed issues when finding class
> Index: Extras/JavaBinding/JavaLanguageBinding.cs
> ===================================================================
> --- Extras/JavaBinding/JavaLanguageBinding.cs	(revision 57975)
> +++ Extras/JavaBinding/JavaLanguageBinding.cs	(working copy)
> @@ -29,6 +29,8 @@
>  	public class JavaLanguageBinding : IDotNetLanguageBinding
>  	{
>  		internal const string LanguageName = "Java";
> +		private static readonly string[] mimeTypes = { "text/x-java" };
> +
>  		JavaBindingCompilerServices compilerServices = new JavaBindingCompilerServices ();
>  		
>  		static GlobalProperties props = new GlobalProperties ();
> @@ -42,6 +44,12 @@
>  				return LanguageName;
>  			}
>  		}
> +
> +		public string[] MimeTypes {
> +				get {
> +					return mimeTypes;
> +				}
> +		}
>  		
>  		public bool IsSourceCodeFile (string fileName)
>  		{
> Index: Extras/JavaBinding/ChangeLog
> ===================================================================
> --- Extras/JavaBinding/ChangeLog	(revision 57975)
> +++ Extras/JavaBinding/ChangeLog	(working copy)
> @@ -1,3 +1,7 @@
> +2006-03-16 David Makovský (Yakeen) <yakeen at sannyas-on.net>
> +
> +	* JavaLanguageBinding.cs: Track changes in ILanguageBinding.
> +
>  2006-01-30 Lluis Sanchez Gual  <lluis at novell.com>   
>  
>  	* Parser/Resolver.cs:
> _______________________________________________
> Monodevelop-list mailing list
> Monodevelop-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monodevelop-list



More information about the Monodevelop-list mailing list