Skip to content

Commit

Permalink
Keep window open after closing last tab. Fixes #24.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mads-hartmann authored and sorbits committed Aug 11, 2012
1 parent b9d8d61 commit dc37506
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
17 changes: 17 additions & 0 deletions Frameworks/DocumentWindow/src/DocumentController.mm
Expand Up @@ -943,6 +943,23 @@ - (void)performCloseTab:(id)sender
{
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];
}

Expand Down
4 changes: 1 addition & 3 deletions Frameworks/OakAppKit/src/OakTabBarView.mm
Expand Up @@ -545,9 +545,7 @@ - (void)performClose:(id)sender
{
D(DBF_TabBarView, bug("\n"););
tag = selectedTab; // performCloseTab: asks for [sender tag]
if([tabTitles count] > 1)
[NSApp sendAction:@selector(performCloseTab:) to:nil from:self];
else [[self nextResponder] tryToPerform:_cmd with:sender];
[NSApp sendAction:@selector(performCloseTab:) to:nil from:self];
}

- (void)setSelectedTab:(NSUInteger)anIndex
Expand Down

0 comments on commit dc37506

Please sign in to comment.