2
// MacSelectFileDialogHandler.cs
5
// Michael Hutchinson <mhutchinson@novell.com>
7
// Copyright (c) 2010 Novell, Inc. (http://www.novell.com)
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
using MonoDevelop.Components.Extensions;
29
using OSXIntegration.Framework;
30
using MonoDevelop.Ide.Extensions;
33
namespace MonoDevelop.Platform.Mac
35
class MacSelectFileDialogHandler : ISelectFileDialogHandler
37
public bool Run (SelectFileDialogData data)
39
var options = NavDialogCreationOptions.NewFromDefaults ();
40
NavDialog dialog = null;
43
options.Modality = WindowModality.AppModal;
45
if (!string.IsNullOrEmpty (data.Title))
46
options.WindowTitle = data.Title;
48
options.OptionFlags |= NavDialogOptionFlags.DontAddTranslateItems
49
& NavDialogOptionFlags.DontAutoTranslate & NavDialogOptionFlags.DontConfirmReplacement;
51
if (data.SelectMultiple)
52
options.OptionFlags |= NavDialogOptionFlags.AllowMultipleFiles;
54
options.OptionFlags ^= NavDialogOptionFlags.AllowMultipleFiles;
58
switch (data.Action) {
59
case FileChooserAction.CreateFolder:
60
dialog = NavDialog.CreateNewFolderDialog (options);
62
case FileChooserAction.Save:
63
options.SaveFileName = data.InitialFileName;
64
dialog = NavDialog.CreatePutFileDialog (options);
66
case FileChooserAction.Open:
67
dialog = NavDialog.CreateChooseFileDialog (options);
69
case FileChooserAction.SelectFolder:
70
dialog = NavDialog.CreateChooseFolderDialog (options);
73
throw new InvalidOperationException ("Unknown action " + data.Action.ToString ());
76
if (!string.IsNullOrEmpty (data.CurrentFolder))
77
dialog.SetLocation (data.CurrentFolder);
79
var action = dialog.Run ();
80
if (action == NavUserAction.Cancel || action == NavUserAction.None)
82
using (var reply = dialog.GetReply ()) {
94
class MacAddFileDialogHandler : IAddFileDialogHandler
96
public bool Run (AddFileDialogData data)
98
throw new NotImplementedException ();
102
class MacOpenFileDialogHandler : IOpenFileDialogHandler
104
public bool Run (OpenFileDialogData data)
106
throw new NotImplementedException ();