Keep window open after closing last tab. Fixes #24.

When the last tab is closed the window will be kept open if the
file browser is shown. It will close the existing document and
replace it with a scratch document.
This commit is contained in:
Mads Hartmann Jensen
2012-08-11 00:34:45 +02:00
committed by Allan Odgaard
parent b9d8d61298
commit dc37506831
2 changed files with 18 additions and 3 deletions

View File

@@ -943,6 +943,23 @@ NSString* const kUserDefaultsFileBrowserPlacementKey = @"fileBrowserPlacement";
{
D(DBF_DocumentController, bug("\n"););
ASSERT([sender isKindOfClass:[OakTabBarView class]]);
if(documentTabs.size() == 1 && !fileBrowserHidden)
{
document::document_ptr document = *documentTabs[0];
if(!document->is_modified())
{
if(document->path() == NULL_STR)
{
return [[self window] performClose:self];
}
else
{
[self newDocumentInTab:nil];
scratchDocument = [self selectedDocument]->identifier();
}
}
}
[self closeTabsAtIndexes:[NSIndexSet indexSetWithIndex:[sender tag]] quiet:NO];
}