mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-08 20:12:01 +03:00
Asking before closing window with multiple open tabs.
svn path=/trunk/netsurf/; revision=11559
This commit is contained in:
parent
fd23621211
commit
899c2e3305
@ -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]) {
|
||||
|
@ -24,5 +24,6 @@ extern NSString * const kHotlistFileOption;
|
||||
extern NSString * const kHomepageURLOption;
|
||||
extern NSString * const kOptionsFileOption;
|
||||
extern NSString * const kAlwaysCancelDownload;
|
||||
extern NSString * const kAlwaysCloseMultipleTabs;
|
||||
|
||||
void cocoa_autorelease( void );
|
||||
|
@ -46,6 +46,7 @@ NSString * const kHotlistFileOption = @"Hotlist";
|
||||
NSString * const kHomepageURLOption = @"HomepageURL";
|
||||
NSString * const kOptionsFileOption = @"ClassicOptionsFile";
|
||||
NSString * const kAlwaysCancelDownload = @"AlwaysCancelDownload";
|
||||
NSString * const kAlwaysCloseMultipleTabs = @"AlwaysCloseMultipleTabs";
|
||||
|
||||
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user