diff options
author | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2015-11-17 16:25:14 +0300 |
---|---|---|
committer | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2015-11-23 16:07:42 +0300 |
commit | 282cc6578b54ebe52b7007dab2e2e397809fa364 (patch) | |
tree | acde544cd40a41ead853776a2ed2612b14fac80e /main/src/core/MonoDevelop.Ide | |
parent | 66e120374d0272f5c441be2f0cb09318c4033987 (diff) |
[Ide] Abstract FileChooserAction.
Diffstat (limited to 'main/src/core/MonoDevelop.Ide')
13 files changed, 52 insertions, 24 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Extensions/ISelectFileDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Extensions/ISelectFileDialog.cs index 9784169415..6aac4de6d5 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Extensions/ISelectFileDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Extensions/ISelectFileDialog.cs @@ -50,7 +50,7 @@ namespace MonoDevelop.Components.Extensions FilterSet = new FileFilterSet (); } internal FileFilterSet FilterSet { get; set; } - public Gtk.FileChooserAction Action { get; set; } + public FileChooserAction Action { get; set; } public IList<SelectFileDialogFilter> Filters { get { return FilterSet.Filters; } } public FilePath CurrentFolder { get; set; } public bool SelectMultiple { get; set; } @@ -107,7 +107,7 @@ namespace MonoDevelop.Components.Extensions /// <summary> /// Action to perform with the file dialog. /// </summary> - public Gtk.FileChooserAction Action { + public FileChooserAction Action { get { return data.Action; } set { data.Action = value; } } @@ -269,7 +269,7 @@ namespace MonoDevelop.Components.Extensions internal void SetDefaultProperties (FileSelector fdiag) { fdiag.Title = Title; - fdiag.Action = Action; + fdiag.Action = Action.ToGtkAction (); fdiag.LocalOnly = true; fdiag.SelectMultiple = SelectMultiple; fdiag.TransientFor = TransientFor; @@ -328,4 +328,31 @@ namespace MonoDevelop.Components.Extensions } } } + + public enum FileChooserAction + { + Open, + Save, + SelectFolder, + CreateFolder, + } + + static class FileChooserActionExtensions + { + public static Gtk.FileChooserAction ToGtkAction(this FileChooserAction action) + { + switch (action) { + case FileChooserAction.Open: + return Gtk.FileChooserAction.Open; + case FileChooserAction.Save: + return Gtk.FileChooserAction.Save; + case FileChooserAction.SelectFolder: + return Gtk.FileChooserAction.SelectFolder; + case FileChooserAction.CreateFolder: + return Gtk.FileChooserAction.CreateFolder; + default: + throw new NotSupportedException (); + } + } + } }
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.PropertyGrid.Editors/FilePathEditor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.PropertyGrid.Editors/FilePathEditor.cs index 23df98afc8..9c6528a09e 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.PropertyGrid.Editors/FilePathEditor.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.PropertyGrid.Editors/FilePathEditor.cs @@ -26,8 +26,8 @@ using System; using System.Linq; -using Gtk; using MonoDevelop.Core; +using MonoDevelop.Components.Extensions; namespace MonoDevelop.Components.PropertyGrid.PropertyEditors { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/FileEntry.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/FileEntry.cs index a47612b712..110f5431c8 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/FileEntry.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/FileEntry.cs @@ -27,6 +27,7 @@ // using System.ComponentModel; +using MonoDevelop.Components.Extensions; namespace MonoDevelop.Components { @@ -40,7 +41,7 @@ namespace MonoDevelop.Components public FileEntry (string name) : base (name) { - Action = Gtk.FileChooserAction.Open; + Action = FileChooserAction.Open; } protected override string ShowBrowseDialog (string name, string startIn) @@ -57,6 +58,6 @@ namespace MonoDevelop.Components return null; } - public Gtk.FileChooserAction Action { get; set; } + public new FileChooserAction Action { get; set; } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/SelectFileDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/SelectFileDialog.cs index 45913593b5..d0db7ef86d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/SelectFileDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/SelectFileDialog.cs @@ -25,7 +25,6 @@ // THE SOFTWARE. using System; -using Gtk; using MonoDevelop.Components.Extensions;
@@ -44,7 +43,7 @@ namespace MonoDevelop.Components { } - public SelectFileDialog (string title, Gtk.FileChooserAction action) + public SelectFileDialog (string title, FileChooserAction action) { Title = title; Action = action; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/SelectFolderDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/SelectFolderDialog.cs index a2a253f162..8f2f7562b2 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/SelectFolderDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/SelectFolderDialog.cs @@ -39,14 +39,14 @@ namespace MonoDevelop.Components {
public SelectFolderDialog () { - Action = Gtk.FileChooserAction.SelectFolder; + Action = FileChooserAction.SelectFolder; } - public SelectFolderDialog (string title): this (title, Gtk.FileChooserAction.SelectFolder) + public SelectFolderDialog (string title): this (title, FileChooserAction.SelectFolder) { } - public SelectFolderDialog (string title, Gtk.FileChooserAction action) + public SelectFolderDialog (string title, FileChooserAction action) { Title = title; Action = action; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs index dd95a7feef..cf50dd519a 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs @@ -79,7 +79,7 @@ namespace MonoDevelop.Ide.Commands { protected override void Run () { - var dlg = new OpenFileDialog (GettextCatalog.GetString ("File to Open"), Gtk.FileChooserAction.Open) { + var dlg = new OpenFileDialog (GettextCatalog.GetString ("File to Open"), MonoDevelop.Components.Extensions.FileChooserAction.Open) { TransientFor = IdeApp.Workbench.RootWindow, ShowEncodingSelector = true, ShowViewerSelector = true, diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/OpenFileDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/OpenFileDialog.cs index 430502ff21..c55f47fb0b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/OpenFileDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/OpenFileDialog.cs @@ -43,11 +43,11 @@ namespace MonoDevelop.Ide.Gui.Dialogs { } - public OpenFileDialog (string title) : this (title, Gtk.FileChooserAction.Save) + public OpenFileDialog (string title) : this (title, FileChooserAction.Save) { } - public OpenFileDialog (string title, Gtk.FileChooserAction action) + public OpenFileDialog (string title, FileChooserAction action) { Title = title; Action = action; @@ -93,7 +93,7 @@ namespace MonoDevelop.Ide.Gui.Dialogs protected override bool RunDefault () { - var win = new FileSelectorDialog (Title, Action); + var win = new FileSelectorDialog (Title, Action.ToGtkAction ()); win.SelectedEncoding = Encoding != null ? Encoding.CodePage : 0; win.ShowEncodingSelector = ShowEncodingSelector; win.ShowViewerSelector = ShowViewerSelector; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs index 069845ada8..ce3f2375cf 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs @@ -414,7 +414,7 @@ namespace MonoDevelop.Ide.Gui } if (filename == null) { - var dlg = new OpenFileDialog (GettextCatalog.GetString ("Save as..."), FileChooserAction.Save) { + var dlg = new OpenFileDialog (GettextCatalog.GetString ("Save as..."), MonoDevelop.Components.Extensions.FileChooserAction.Save) { TransientFor = IdeApp.Workbench.RootWindow, Encoding = encoding, ShowEncodingSelector = (tbuffer != null), diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/AddFileDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/AddFileDialog.cs index 6377843060..2a28bc1c63 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/AddFileDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/AddFileDialog.cs @@ -42,7 +42,7 @@ namespace MonoDevelop.Ide.Projects public AddFileDialog (string title)
{ Title = title; - Action = FileChooserAction.Open; + Action = MonoDevelop.Components.Extensions.FileChooserAction.Open; data.SelectMultiple = true;
} diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/AssemblyReferencePanel.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/AssemblyReferencePanel.cs index 7c53d25e86..30d41905f2 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/AssemblyReferencePanel.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/AssemblyReferencePanel.cs @@ -150,7 +150,7 @@ namespace MonoDevelop.Ide.Projects void HandleClicked (object sender, EventArgs e) { - var dlg = new OpenFileDialog (GettextCatalog.GetString ("Select Assembly"), FileChooserAction.Open); + var dlg = new OpenFileDialog (GettextCatalog.GetString ("Select Assembly"), MonoDevelop.Components.Extensions.FileChooserAction.Open); // dlg.AddFilter (GettextCatalog.GetString ("Assemblies"), "*.[Dd][Ll][Ll]", "*.[Ee][Xx][Ee]"); dlg.AddFilter (GettextCatalog.GetString ("Assemblies"), "*.dll", "*.exe"); dlg.CurrentFolder = basePath; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/DefaultPolicyOptionsDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/DefaultPolicyOptionsDialog.cs index 2ac9f2edac..64a4d46e27 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/DefaultPolicyOptionsDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/DefaultPolicyOptionsDialog.cs @@ -221,7 +221,7 @@ namespace MonoDevelop.Ide.Projects void HandleFromFile (object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog (GettextCatalog.GetString ("Select Policy File")); - dlg.Action = FileChooserAction.Open; + dlg.Action = MonoDevelop.Components.Extensions.FileChooserAction.Open; dlg.TransientFor = this; dlg.AddFilter (BrandingService.BrandApplicationName (GettextCatalog.GetString ("MonoDevelop policy files")), "*.mdpolicy"); dlg.AddAllFilesFilter (); @@ -280,7 +280,7 @@ namespace MonoDevelop.Ide.Projects OpenFileDialog dlg = new OpenFileDialog (GettextCatalog.GetString ("Select Policy File")); dlg.TransientFor = this; dlg.InitialFileName = currentSet.Name + ".mdpolicy"; - dlg.Action = FileChooserAction.Save; + dlg.Action = MonoDevelop.Components.Extensions.FileChooserAction.Save; dlg.AddFilter (BrandingService.BrandApplicationName (GettextCatalog.GetString ("MonoDevelop policy files")), "*.mdpolicy"); dlg.AddAllFilesFilter (); dlg.CurrentFolder = ExportProjectPolicyDialog.DefaultFileDialogPolicyDir; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/ExportProjectPolicyDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/ExportProjectPolicyDialog.cs index 4f51bb1f38..1a158b21bd 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/ExportProjectPolicyDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/ExportProjectPolicyDialog.cs @@ -24,7 +24,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; -using Gtk; +using MonoDevelop.Components.Extensions; using MonoDevelop.Core; using MonoDevelop.Projects; using MonoDevelop.Projects.Policies; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs index d964ed1411..e944b75f55 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs @@ -53,6 +53,7 @@ using ICSharpCode.NRefactory.TypeSystem.Implementation; using System.Text; using MonoDevelop.Ide.TypeSystem; using ICSharpCode.NRefactory.TypeSystem; +using MonoDevelop.Components.Extensions; namespace MonoDevelop.Ide { @@ -656,7 +657,7 @@ namespace MonoDevelop.Ide WorkspaceItem res = null; var dlg = new SelectFileDialog () { - Action = Gtk.FileChooserAction.Open, + Action = FileChooserAction.Open, CurrentFolder = parentWorkspace.BaseDirectory, SelectMultiple = false, }; @@ -719,7 +720,7 @@ namespace MonoDevelop.Ide SolutionItem res = null; var dlg = new SelectFileDialog () { - Action = Gtk.FileChooserAction.Open, + Action = FileChooserAction.Open, CurrentFolder = parentFolder.BaseDirectory, SelectMultiple = false, }; @@ -1624,7 +1625,7 @@ namespace MonoDevelop.Ide { var dlg = new SelectFileDialog () { SelectMultiple = true, - Action = Gtk.FileChooserAction.Open, + Action = FileChooserAction.Open, CurrentFolder = folder.BaseDirectory, TransientFor = MessageService.RootWindow, }; |