diff options
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs')
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs index 01ea62b0ca..58e4750c86 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs @@ -201,6 +201,14 @@ namespace MonoDevelop.Ide.Gui return false; if (toplevel == RootWindow) return true; + #if WIN32 + var app = System.Windows.Application.Current; + if (app != null) { + var wpfWindow = app.Windows.OfType<System.Windows.Window>().SingleOrDefault (x => x.IsActive); + if (wpfWindow != null) + return true; + } + #endif var dock = toplevel as DockFloatingWindow; return dock != null && dock.DockParent == RootWindow; } @@ -311,6 +319,37 @@ namespace MonoDevelop.Ide.Gui foreach (Document doc in docs) doc.Save (); } + + internal bool SaveAllDirtyFiles () + { + Document[] docs = Documents.Where (doc => doc.IsDirty && doc.Window.ViewContent != null).ToArray (); + if (!docs.Any ()) + return true; + + foreach (Document doc in docs) { + AlertButton result = PromptToSaveChanges (doc); + if (result == AlertButton.Cancel) + return false; + + doc.Save (); + if (doc.IsDirty) { + doc.Select (); + return false; + } + } + return true; + } + + static AlertButton PromptToSaveChanges (Document doc) + { + return MessageService.GenericAlert (MonoDevelop.Ide.Gui.Stock.Warning, + GettextCatalog.GetString ("Save the changes to document '{0}' before creating a new solution?", + doc.Window.ViewContent.IsUntitled + ? doc.Window.ViewContent.UntitledName + : System.IO.Path.GetFileName (doc.FileName)), + "", + AlertButton.Cancel, doc.Window.ViewContent.IsUntitled ? AlertButton.SaveAs : AlertButton.Save); + } public void CloseAllDocuments (bool leaveActiveDocumentOpen) { |