mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-18 16:10:26 +02:00
Merge pull request #883 from bttelle/fix-sec-win-close-w-changed-inactive-tab
Fixes for incorrect SecondaryAllowClose logic
This commit is contained in:
commit
7e139f5d7c
1 changed files with 140 additions and 101 deletions
|
@ -1241,40 +1241,62 @@ namespace IDE
|
|||
if (mRunningTestScript)
|
||||
return true;
|
||||
|
||||
void CloseTabs()
|
||||
{
|
||||
WithDocumentTabbedViewsOf(window, scope (tabbedView) => {
|
||||
tabbedView.CloseTabs(false, true);
|
||||
});
|
||||
}
|
||||
|
||||
void CloseWindow()
|
||||
{
|
||||
mMainWindow.SetForeground();
|
||||
window.Close(true);
|
||||
}
|
||||
|
||||
List<String> changedList = scope List<String>();
|
||||
defer ClearAndDeleteItems(changedList);
|
||||
WithSourceViewPanels(scope (sourceViewPanel) =>
|
||||
WithSourceViewPanelsOf(window, scope (sourceViewPanel) =>
|
||||
{
|
||||
if ((sourceViewPanel.mWidgetWindow == window) && (sourceViewPanel.HasUnsavedChanges()))
|
||||
if (sourceViewPanel.HasUnsavedChanges())
|
||||
{
|
||||
var fileName = new String();
|
||||
Path.GetFileName(sourceViewPanel.mFilePath, fileName);
|
||||
changedList.Add(fileName);
|
||||
}
|
||||
});
|
||||
if (changedList.Count == 0)
|
||||
|
||||
if (changedList.Count == 0) {
|
||||
CloseTabs();
|
||||
return true;
|
||||
}
|
||||
var aDialog = QuerySaveFiles(changedList, (WidgetWindow)window);
|
||||
aDialog.mDefaultButton = aDialog.AddButton("Save", new (evt) =>
|
||||
{
|
||||
bool hadError = false;
|
||||
// We use a close delay after saving so the user can see we actually saved before closing down
|
||||
var _this = this;
|
||||
WithSourceViewPanels(scope [&] (sourceViewPanel) =>
|
||||
WithSourceViewPanelsOf(window, scope [&] (sourceViewPanel) =>
|
||||
{
|
||||
if ((!hadError) && (sourceViewPanel.mWidgetWindow == window) && (sourceViewPanel.HasUnsavedChanges()))
|
||||
if ((!hadError) && (sourceViewPanel.HasUnsavedChanges()))
|
||||
if (!_this.SaveFile(sourceViewPanel))
|
||||
hadError = true;
|
||||
});
|
||||
if (hadError)
|
||||
return;
|
||||
mMainWindow.SetForeground();
|
||||
window.Close(true);
|
||||
CloseTabs();
|
||||
CloseWindow();
|
||||
});
|
||||
aDialog.AddButton("Don't Save", new (evt) =>
|
||||
{
|
||||
mMainWindow.SetForeground();
|
||||
window.Close(true);
|
||||
var _this = this;
|
||||
WithSourceViewPanelsOf(window, scope [&] (sourceViewPanel) =>
|
||||
{
|
||||
if (sourceViewPanel.HasUnsavedChanges())
|
||||
_this.RevertSourceViewPanel(sourceViewPanel);
|
||||
});
|
||||
CloseTabs();
|
||||
CloseWindow();
|
||||
});
|
||||
|
||||
aDialog.mEscButton = aDialog.AddButton("Cancel");
|
||||
|
@ -5560,11 +5582,8 @@ namespace IDE
|
|||
});
|
||||
}
|
||||
|
||||
public void WithDocumentTabbedViews(delegate void(DarkTabbedView) func)
|
||||
public void WithDocumentTabbedViewsOf(BFWindow window, delegate void(DarkTabbedView) func)
|
||||
{
|
||||
for (int32 windowIdx = 0; windowIdx < mWindows.Count; windowIdx++)
|
||||
{
|
||||
var window = mWindows[windowIdx];
|
||||
var widgetWindow = window as WidgetWindow;
|
||||
if (widgetWindow != null)
|
||||
{
|
||||
|
@ -5583,6 +5602,11 @@ namespace IDE
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void WithDocumentTabbedViews(delegate void(DarkTabbedView) func)
|
||||
{
|
||||
for (let window in mWindows)
|
||||
WithDocumentTabbedViewsOf(window, func);
|
||||
}
|
||||
|
||||
public void EnsureDocumentArea()
|
||||
|
@ -5682,14 +5706,20 @@ namespace IDE
|
|||
return null;
|
||||
}
|
||||
|
||||
public void WithTabs(delegate void(TabbedView.TabButton) func)
|
||||
public void WithTabsOf(BFWindow window, delegate void(TabbedView.TabButton) func)
|
||||
{
|
||||
WithDocumentTabbedViews(scope (documentTabbedView) =>
|
||||
WithDocumentTabbedViewsOf(window, scope (documentTabbedView) =>
|
||||
{
|
||||
documentTabbedView.WithTabs(func);
|
||||
});
|
||||
}
|
||||
|
||||
public void WithTabs(delegate void(TabbedView.TabButton) func)
|
||||
{
|
||||
for (let window in mWindows)
|
||||
WithTabsOf(window, func);
|
||||
}
|
||||
|
||||
public TabbedView.TabButton GetTab(Widget content)
|
||||
{
|
||||
TabbedView.TabButton tab = null;
|
||||
|
@ -5701,9 +5731,9 @@ namespace IDE
|
|||
return tab;
|
||||
}
|
||||
|
||||
public void WithSourceViewPanels(delegate void(SourceViewPanel) func)
|
||||
public void WithSourceViewPanelsOf(BFWindow window, delegate void(SourceViewPanel) func)
|
||||
{
|
||||
WithTabs(scope (tab) =>
|
||||
WithTabsOf(window, scope (tab) =>
|
||||
{
|
||||
var sourceViewPanel = tab.mContent as SourceViewPanel;
|
||||
if (sourceViewPanel != null)
|
||||
|
@ -5711,6 +5741,12 @@ namespace IDE
|
|||
});
|
||||
}
|
||||
|
||||
public void WithSourceViewPanels(delegate void(SourceViewPanel) func)
|
||||
{
|
||||
for (let window in mWindows)
|
||||
WithSourceViewPanelsOf(window, func);
|
||||
}
|
||||
|
||||
TabbedView.TabButton SetupTab(TabbedView tabView, String name, float width, Widget content, bool ownsContent) // 2
|
||||
{
|
||||
TabbedView.TabButton tabButton = tabView.AddTab(name, width, content, ownsContent);
|
||||
|
@ -6463,21 +6499,7 @@ namespace IDE
|
|||
aDialog.PopupWindow(mMainWindow);
|
||||
}
|
||||
|
||||
public void CloseDocument(Widget documentPanel)
|
||||
{
|
||||
bool hasFocus = false;
|
||||
var sourceViewPanel = documentPanel as SourceViewPanel;
|
||||
|
||||
if ((documentPanel.mWidgetWindow != null) && (documentPanel.mWidgetWindow.mFocusWidget != null))
|
||||
{
|
||||
if (documentPanel.mWidgetWindow.mFocusWidget.HasParent(documentPanel))
|
||||
hasFocus = true;
|
||||
}
|
||||
|
||||
/*if (sourceViewPanel != null)
|
||||
hasFocus = sourceViewPanel.mEditWidget.mHasFocus;*/
|
||||
|
||||
if ((sourceViewPanel != null) && (sourceViewPanel.HasUnsavedChanges()))
|
||||
void RevertSourceViewPanel(SourceViewPanel sourceViewPanel)
|
||||
{
|
||||
// When we close a Beef file that has modified text, we need to revert by
|
||||
// reparsing from the actual source file
|
||||
|
@ -6532,6 +6554,23 @@ namespace IDE
|
|||
}
|
||||
}
|
||||
|
||||
public void CloseDocument(Widget documentPanel)
|
||||
{
|
||||
bool hasFocus = false;
|
||||
var sourceViewPanel = documentPanel as SourceViewPanel;
|
||||
|
||||
if ((documentPanel.mWidgetWindow != null) && (documentPanel.mWidgetWindow.mFocusWidget != null))
|
||||
{
|
||||
if (documentPanel.mWidgetWindow.mFocusWidget.HasParent(documentPanel))
|
||||
hasFocus = true;
|
||||
}
|
||||
|
||||
/*if (sourceViewPanel != null)
|
||||
hasFocus = sourceViewPanel.mEditWidget.mHasFocus;*/
|
||||
|
||||
if ((sourceViewPanel != null) && (sourceViewPanel.HasUnsavedChanges()))
|
||||
RevertSourceViewPanel(sourceViewPanel);
|
||||
|
||||
DarkTabbedView tabbedView = null;
|
||||
DarkTabbedView.DarkTabButton tabButton = null;
|
||||
WithTabs(scope [&] (tab) =>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue