diff --git a/Libraries/UniversalEditor.UserInterface/MainWindow.cs b/Libraries/UniversalEditor.UserInterface/MainWindow.cs index be0a3fc4..6ef66f61 100644 --- a/Libraries/UniversalEditor.UserInterface/MainWindow.cs +++ b/Libraries/UniversalEditor.UserInterface/MainWindow.cs @@ -196,6 +196,7 @@ namespace UniversalEditor.UserInterface { Layout = new BoxLayout(Orientation.Vertical); this.IconName = "universal-editor"; + LogoutInhibitor = new Inhibitor(InhibitorType.SystemLogout, "There are unsaved documents", this); this.CommandDisplayMode = CommandDisplayMode.CommandBar; @@ -1041,6 +1042,9 @@ namespace UniversalEditor.UserInterface OpenFile(documents); } + private Inhibitor LogoutInhibitor = null; + private int logoutInhibitorI = 0; + public void OpenFile(params Document[] documents) { foreach (Document doc in documents) @@ -1049,6 +1053,12 @@ namespace UniversalEditor.UserInterface { InitEditorPage(doc); + if (logoutInhibitorI == 0) + { + (Application.Instance as UIApplication).Inhibitors.Add(LogoutInhibitor); + } + logoutInhibitorI++; + if (doc == null) continue; @@ -1439,6 +1449,12 @@ namespace UniversalEditor.UserInterface dckContainer.Items.Remove(dw); documentWindowCount--; + logoutInhibitorI--; + if (logoutInhibitorI == 0) + { + (Application.Instance as UIApplication).Inhibitors.Remove(LogoutInhibitor); + } + if (documentWindowCount == 0) { CloseWindow ();