summaryrefslogtreecommitdiff
path: root/cocoa/BrowserWindowController.m
diff options
context:
space:
mode:
authorSven Weidauer <sven.weidauer@gmail.com>2011-01-31 08:07:22 +0000
committerSven Weidauer <sven.weidauer@gmail.com>2011-01-31 08:07:22 +0000
commit899c2e3305592725d646f5acf3c21eaad13699c7 (patch)
tree740afbfd9bd744068f7c958a765359b36b70e15f /cocoa/BrowserWindowController.m
parentfd23621211e814d86da1a12bf0f5a20368d4c037 (diff)
downloadnetsurf-899c2e3305592725d646f5acf3c21eaad13699c7.tar.gz
netsurf-899c2e3305592725d646f5acf3c21eaad13699c7.tar.bz2
Asking before closing window with multiple open tabs.
svn path=/trunk/netsurf/; revision=11559
Diffstat (limited to 'cocoa/BrowserWindowController.m')
-rw-r--r--cocoa/BrowserWindowController.m32
1 files changed, 32 insertions, 0 deletions
diff --git a/cocoa/BrowserWindowController.m b/cocoa/BrowserWindowController.m
index 4ed220015..f30607a8e 100644
--- a/cocoa/BrowserWindowController.m
+++ b/cocoa/BrowserWindowController.m
@@ -22,10 +22,18 @@
#import "PSMTabBarControl.h"
#import "PSMRolloverButton.h"
#import "URLFieldCell.h"
+#import "cocoa/gui.h"
#import "desktop/browser.h"
#import "desktop/options.h"
+@interface BrowserWindowController ()
+
+- (void) canCloseAlertDidEnd:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(void *)contextInfo;
+
+@end
+
+
@implementation BrowserWindowController
@synthesize tabBar;
@@ -99,6 +107,30 @@
}
}
+- (BOOL) windowShouldClose: (NSWindow *) window;
+{
+ if ([tabView numberOfTabViewItems] <= 1) return YES;
+ if ([[NSUserDefaults standardUserDefaults] boolForKey: kAlwaysCloseMultipleTabs]) return YES;
+
+ NSAlert *ask = [NSAlert alertWithMessageText: @"Do you really want to close this window?" defaultButton:@"Yes" alternateButton:@"No" otherButton:nil
+ informativeTextWithFormat: @"There are %d tabs open, do you want to close them all?", [tabView numberOfTabViewItems]];
+ [ask setShowsSuppressionButton:YES];
+
+ [ask beginSheetModalForWindow: window modalDelegate:self didEndSelector:@selector(canCloseAlertDidEnd:returnCode:contextInfo:)
+ contextInfo: NULL];
+
+ return NO;
+}
+
+- (void) canCloseAlertDidEnd:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(void *)contextInfo;
+{
+ if (returnCode == NSOKButton) {
+ [[NSUserDefaults standardUserDefaults] setBool: [[alert suppressionButton] state] == NSOnState
+ forKey: kAlwaysCloseMultipleTabs];
+ [[self window] close];
+ }
+}
+
- (void) windowWillClose: (NSNotification *)notification;
{
for (NSTabViewItem *tab in [tabView tabViewItems]) {