From 1f0a558adc8d0f057df4ff7069abe975229ce40d Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Thu, 21 Feb 2013 21:52:12 +0100 Subject: [PATCH] Add performCloseAllTabs: action method Closes #808. --- Frameworks/DocumentWindow/src/DocumentController.h | 1 + Frameworks/DocumentWindow/src/DocumentController.mm | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/Frameworks/DocumentWindow/src/DocumentController.h b/Frameworks/DocumentWindow/src/DocumentController.h index f1cdf302..1fb180a4 100644 --- a/Frameworks/DocumentWindow/src/DocumentController.h +++ b/Frameworks/DocumentWindow/src/DocumentController.h @@ -46,6 +46,7 @@ PUBLIC @interface DocumentController : NSObject - (IBAction)performCloseTab:(id)sender; - (IBAction)performCloseSplit:(id)sender; - (IBAction)performCloseWindow:(id)sender; +- (IBAction)performCloseAllTabs:(id)sender; - (IBAction)performCloseOtherTabs:(id)sender; - (IBAction)saveDocument:(id)sender; diff --git a/Frameworks/DocumentWindow/src/DocumentController.mm b/Frameworks/DocumentWindow/src/DocumentController.mm index aaf494db..a88f9c7c 100644 --- a/Frameworks/DocumentWindow/src/DocumentController.mm +++ b/Frameworks/DocumentWindow/src/DocumentController.mm @@ -544,6 +544,17 @@ namespace [self.window performClose:self]; } +- (IBAction)performCloseAllTabs:(id)sender +{ + NSMutableIndexSet* allTabs = [NSMutableIndexSet indexSetWithIndexesInRange:NSMakeRange(0, _documents.size())]; + for(size_t i = 0; i < _documents.size(); ++i) + { + if(_documents[i]->is_modified() && _documents[i]->path() == NULL_STR) + [allTabs removeIndex:i]; + } + [self closeTabsAtIndexes:allTabs askToSaveChanges:YES createDocumentIfEmpty:YES]; +} + - (IBAction)performCloseOtherTabs:(id)sender { NSUInteger tabIndex = [sender isKindOfClass:[OakTabBarView class]] ? [sender tag] : _selectedTabIndex;