зеркало из https://github.com/mozilla/gecko-dev.git
Fix bug 196359: show an optional warning when closing a window with multiple tabs, or quitting when multiple windows or tabs are open. Patch partially by Nathaniel Madura.
This commit is contained in:
Родитель
ab2447d474
Коммит
a0e7cd8c30
|
@ -13,13 +13,19 @@
|
|||
SUPERCLASS = NSObject;
|
||||
},
|
||||
{
|
||||
ACTIONS = {checkboxStartPageClicked = id; defaultBrowserChange = id; };
|
||||
ACTIONS = {
|
||||
checkboxStartPageClicked = id;
|
||||
defaultBrowserChange = id;
|
||||
warningCheckboxClicked = id;
|
||||
};
|
||||
CLASS = OrgMozillaChimeraPreferenceNavigation;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {
|
||||
checkboxCheckDefaultBrowserOnLaunch = NSButton;
|
||||
checkboxNewTabBlank = NSButton;
|
||||
checkboxNewWindowBlank = NSButton;
|
||||
checkboxWarnWhenClosingWindow = NSButton;
|
||||
checkboxWarnWhenQuitting = NSButton;
|
||||
defaultBrowserPopUp = NSPopUpButton;
|
||||
textFieldHomePage = NSTextField;
|
||||
};
|
||||
|
|
Двоичные данные
camino/PreferencePanes/Navigation/English.lproj/Navigation.nib/keyedobjects.nib
сгенерированный
Двоичные данные
camino/PreferencePanes/Navigation/English.lproj/Navigation.nib/keyedobjects.nib
сгенерированный
Двоичный файл не отображается.
|
@ -41,15 +41,19 @@
|
|||
|
||||
@interface OrgMozillaChimeraPreferenceNavigation : PreferencePaneBase
|
||||
{
|
||||
IBOutlet NSTextField* textFieldHomePage;
|
||||
IBOutlet NSTextField* textFieldHomePage;
|
||||
|
||||
IBOutlet NSButton* checkboxNewTabBlank;
|
||||
IBOutlet NSButton* checkboxNewWindowBlank;
|
||||
IBOutlet NSPopUpButton* defaultBrowserPopUp;
|
||||
IBOutlet NSButton* checkboxCheckDefaultBrowserOnLaunch;
|
||||
|
||||
IBOutlet NSButton* checkboxWarnWhenClosingWindow;
|
||||
IBOutlet NSButton* checkboxWarnWhenQuitting;
|
||||
}
|
||||
|
||||
- (IBAction)checkboxStartPageClicked:(id)sender;
|
||||
- (IBAction)defaultBrowserChange:(id)sender;
|
||||
- (IBAction)warningCheckboxClicked:(id)sender;
|
||||
|
||||
@end
|
||||
|
|
|
@ -109,6 +109,12 @@ static int CompareBundleIDAppDisplayNames(id a, id b, void *context)
|
|||
if ([self getBooleanPref:"camino.check_default_browser" withSuccess:&gotPref] || !gotPref)
|
||||
[checkboxCheckDefaultBrowserOnLaunch setState:NSOnState];
|
||||
|
||||
if ([self getBooleanPref:"camino.warn_when_closing" withSuccess:&gotPref])
|
||||
[checkboxWarnWhenClosingWindow setState:NSOnState];
|
||||
|
||||
if ([self getBooleanPref:"camino.warn_when_quitting" withSuccess:&gotPref])
|
||||
[checkboxWarnWhenQuitting setState:NSOnState];
|
||||
|
||||
[textFieldHomePage setStringValue:[self getCurrentHomePage]];
|
||||
|
||||
// set up default browser menu
|
||||
|
@ -127,6 +133,9 @@ static int CompareBundleIDAppDisplayNames(id a, id b, void *context)
|
|||
[self setPref:"browser.tabs.startPage" toInt:[checkboxNewTabBlank state] ? 1 : 0];
|
||||
|
||||
[self setPref:"camino.check_default_browser" toBoolean:([checkboxCheckDefaultBrowserOnLaunch state] == NSOnState)];
|
||||
|
||||
[self setPref:"camino.warn_when_closing" toBoolean:([checkboxWarnWhenClosingWindow state] == NSOnState)];
|
||||
[self setPref:"camino.warn_when_quitting" toBoolean:([checkboxWarnWhenQuitting state] == NSOnState)];
|
||||
}
|
||||
|
||||
- (IBAction)checkboxStartPageClicked:(id)sender
|
||||
|
@ -144,6 +153,15 @@ static int CompareBundleIDAppDisplayNames(id a, id b, void *context)
|
|||
[self setPref:prefName toInt: [sender state] ? 1 : 0];
|
||||
}
|
||||
|
||||
- (IBAction)warningCheckboxClicked:(id)sender
|
||||
{
|
||||
if (sender == checkboxWarnWhenClosingWindow)
|
||||
[self setPref:"camino.warn_when_closing" toBoolean:([sender state] == NSOnState)];
|
||||
|
||||
if (sender == checkboxWarnWhenQuitting)
|
||||
[self setPref:"camino.warn_when_quitting" toBoolean:([sender state] == NSOnState)];
|
||||
}
|
||||
|
||||
- (NSString*)getCurrentHomePage
|
||||
{
|
||||
BOOL gotPref;
|
||||
|
|
|
@ -105,6 +105,8 @@ img[src*=".zedo.com"],
|
|||
img[src*=".mspaceads.com"],
|
||||
img[src*=".adbrite.com"],
|
||||
img[src*="ximages.offeroptimizer.com"],
|
||||
img[src*="kermit.macnn.com"],
|
||||
img[src*="media.adlegend.com"],
|
||||
|
||||
iframe[src*="/ad."],
|
||||
iframe[src*="/ads."],
|
||||
|
|
|
@ -54,6 +54,10 @@ pref("camino.use_system_proxy_settings", true);
|
|||
|
||||
pref("camino.enable_plugins", true);
|
||||
|
||||
// show warning when closing window or quitting
|
||||
pref("camino.warn_when_closing", true);
|
||||
pref("camino.warn_when_quitting", true);
|
||||
|
||||
// turn off dumping of JS and CSS errors to the console
|
||||
pref("chimera.log_js_to_console", false);
|
||||
|
||||
|
|
Двоичные данные
camino/resources/localized/English.lproj/Localizable.strings
Двоичные данные
camino/resources/localized/English.lproj/Localizable.strings
Двоичный файл не отображается.
|
@ -39,6 +39,7 @@
|
|||
|
||||
#import <Carbon/Carbon.h>
|
||||
|
||||
#import "NSArray+Utils.h"
|
||||
#import "NSString+Utils.h"
|
||||
#import "NSResponder+Utils.h"
|
||||
#import "NSMenu+Utils.h"
|
||||
|
@ -119,6 +120,8 @@ const int kReuseWindowOnAE = 2;
|
|||
- (void)showCertificatesNotification:(NSNotification*)inNotification;
|
||||
- (void)openPanelDidEnd:(NSOpenPanel*)inOpenPanel returnCode:(int)inReturnCode contextInfo:(void*)inContextInfo;
|
||||
|
||||
-(NSArray*)browserWindows;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
@ -181,7 +184,7 @@ const int kReuseWindowOnAE = 2;
|
|||
NSString* appName = NSLocalizedStringFromTable(@"CFBundleName", @"InfoPlist", nil);
|
||||
NSString* alert = [NSString stringWithFormat: NSLocalizedString(@"RequiredVersionNotMetTitle", @""), appName];
|
||||
NSString* message = [NSString stringWithFormat: NSLocalizedString(@"RequiredVersionNotMet", @""), appName];
|
||||
NSString* quit = NSLocalizedString(@"AlreadyRunningButton",@"");
|
||||
NSString* quit = NSLocalizedString(@"QuitButtonText",@"");
|
||||
NSRunAlertPanel(alert, message, quit, nil, nil);
|
||||
[NSApp terminate:self];
|
||||
}
|
||||
|
@ -342,7 +345,56 @@ const int kReuseWindowOnAE = 2;
|
|||
{
|
||||
ProgressDlgController* progressWindowController = [ProgressDlgController existingSharedDownloadController];
|
||||
if (progressWindowController)
|
||||
return [progressWindowController allowTerminate];
|
||||
{
|
||||
NSApplicationTerminateReply progressTerminateReply = [progressWindowController allowTerminate];
|
||||
if (progressTerminateReply != NSTerminateNow)
|
||||
return progressTerminateReply;
|
||||
}
|
||||
|
||||
PreferenceManager* prefManager = [PreferenceManager sharedInstanceDontCreate];
|
||||
if (!prefManager) return NSTerminateNow; // we didn't fully launch
|
||||
|
||||
if (![prefManager getBooleanPref:"camino.warn_when_quitting" withSuccess:NULL])
|
||||
return NSTerminateNow;
|
||||
|
||||
NSString* quitAlertMsg = nil;
|
||||
NSString* quitAlertExpl = nil;
|
||||
|
||||
NSArray* openBrowserWins = [self browserWindows];
|
||||
if ([openBrowserWins count] == 1)
|
||||
{
|
||||
BrowserWindowController* bwc = [[openBrowserWins firstObject] windowController];
|
||||
unsigned int numTabs = [[bwc getTabBrowser] numberOfTabViewItems];
|
||||
if (numTabs > 1)
|
||||
{
|
||||
quitAlertMsg = NSLocalizedString(@"QuitWithMultipleTabsMsg", @"");
|
||||
quitAlertExpl = [NSString stringWithFormat:NSLocalizedString(@"QuitWithMultipleTabsExpl", @""), numTabs];
|
||||
}
|
||||
}
|
||||
else if ([openBrowserWins count] > 1)
|
||||
{
|
||||
quitAlertMsg = NSLocalizedString(@"QuitWithMultipleWindowsMsg", @"");
|
||||
quitAlertExpl = [NSString stringWithFormat:NSLocalizedString(@"QuitWithMultipleWindowsExpl", @""), [openBrowserWins count]];
|
||||
}
|
||||
|
||||
if (quitAlertMsg)
|
||||
{
|
||||
nsAlertController* controller = CHBrowserService::GetAlertController();
|
||||
BOOL dontShowAgain = NO;
|
||||
BOOL confirmed = [controller confirmCheckEx:nil
|
||||
title:quitAlertMsg
|
||||
text:quitAlertExpl
|
||||
button1:NSLocalizedString(@"QuitButtonText", @"")
|
||||
button2:NSLocalizedString(@"CancelButtonText", @"")
|
||||
button3:nil
|
||||
checkMsg:NSLocalizedString(@"QuitWithMultipleTabsCheckboxLabel", @"")
|
||||
checkValue:&dontShowAgain];
|
||||
if (dontShowAgain)
|
||||
[prefManager setPref:"camino.warn_when_quitting" toBoolean:NO];
|
||||
|
||||
return (confirmed) ? NSTerminateNow : NSTerminateCancel;
|
||||
}
|
||||
|
||||
return NSTerminateNow;
|
||||
}
|
||||
|
||||
|
@ -978,33 +1030,55 @@ Otherwise, we return the URL we originally got. Right now this supports .url and
|
|||
- (NSView*)getSavePanelView
|
||||
{
|
||||
if (!mFilterView)
|
||||
{
|
||||
// note that this will cause our -awakeFromNib to get called again
|
||||
[NSBundle loadNibNamed:@"AccessoryViews" owner:self];
|
||||
}
|
||||
return mFilterView;
|
||||
}
|
||||
|
||||
-(NSArray*)browserWindows
|
||||
{
|
||||
NSEnumerator* windowEnum = [[NSApp orderedWindows] objectEnumerator];
|
||||
NSMutableArray* windowArray = [NSMutableArray array];
|
||||
|
||||
NSWindow* curWindow;
|
||||
while ((curWindow = [windowEnum nextObject]))
|
||||
{
|
||||
// not all browser windows are created equal. We only consider those with
|
||||
// an empty chrome mask, or ones with a toolbar, status bar, and resize control
|
||||
// to be real top-level browser windows for purposes of saving size and
|
||||
// loading urls in. Others are popups and are transient.
|
||||
if ([[curWindow windowController] isMemberOfClass:[BrowserWindowController class]] &&
|
||||
[[curWindow windowController] hasFullBrowserChrome])
|
||||
{
|
||||
[windowArray addObject:curWindow];
|
||||
}
|
||||
}
|
||||
|
||||
return windowArray;
|
||||
}
|
||||
|
||||
|
||||
-(NSWindow*)getFrontmostBrowserWindow
|
||||
{
|
||||
// for some reason, [NSApp mainWindow] doesn't always work, so we have to
|
||||
// do this manually
|
||||
NSArray *windowList = [NSApp orderedWindows];
|
||||
NSWindow *foundWindow = nil;
|
||||
NSEnumerator* windowEnum = [[NSApp orderedWindows] objectEnumerator];
|
||||
NSWindow* foundWindow = nil;
|
||||
|
||||
for (unsigned int i = 0; i < [windowList count]; i ++) {
|
||||
NSWindow* thisWindow = [windowList objectAtIndex:i];
|
||||
|
||||
NSWindow* curWindow;
|
||||
while ((curWindow = [windowEnum nextObject]))
|
||||
{
|
||||
// not all browser windows are created equal. We only consider those with
|
||||
// an empty chrome mask, or ones with a toolbar, status bar, and resize control
|
||||
// to be real top-level browser windows for purposes of saving size and
|
||||
// loading urls in. Others are popups and are transient.
|
||||
if ([[thisWindow windowController] isMemberOfClass:[BrowserWindowController class]]) {
|
||||
unsigned int chromeMask = [[thisWindow windowController] chromeMask];
|
||||
if (chromeMask == 0 ||
|
||||
(chromeMask & nsIWebBrowserChrome::CHROME_TOOLBAR &&
|
||||
chromeMask & nsIWebBrowserChrome::CHROME_STATUSBAR &&
|
||||
chromeMask & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE)) {
|
||||
foundWindow = thisWindow;
|
||||
break;
|
||||
}
|
||||
if ([[curWindow windowController] isMemberOfClass:[BrowserWindowController class]] &&
|
||||
[[curWindow windowController] hasFullBrowserChrome])
|
||||
{
|
||||
foundWindow = curWindow;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -290,6 +290,8 @@ typedef enum
|
|||
-(void)setChromeMask:(unsigned int)aMask;
|
||||
-(unsigned int)chromeMask;
|
||||
|
||||
-(BOOL)hasFullBrowserChrome;
|
||||
|
||||
// Called when a context menu should be shown.
|
||||
- (void)onShowContextMenu:(int)flags domEvent:(nsIDOMEvent*)aEvent domNode:(nsIDOMNode*)aNode;
|
||||
- (void)prepareAddToAddressBookMenuItem:(NSMenuItem*)addToAddressBookItem address:(NSString*)emailAddress;
|
||||
|
|
|
@ -562,6 +562,36 @@ enum BWCOpenDest {
|
|||
mShouldLoadHomePage = NO;
|
||||
}
|
||||
|
||||
- (BOOL)windowShouldClose:(id)sender
|
||||
{
|
||||
if ([[PreferenceManager sharedInstance] getBooleanPref:"camino.warn_when_closing" withSuccess:NULL])
|
||||
{
|
||||
unsigned int numberOfTabs = [mTabBrowser numberOfTabViewItems];
|
||||
if (numberOfTabs > 1)
|
||||
{
|
||||
NSString* closeMultipleTabWarning = NSLocalizedString(@"CloseWindowWithMultipleTabsExplFormat", @"");
|
||||
|
||||
nsAlertController* controller = CHBrowserService::GetAlertController();
|
||||
BOOL dontShowAgain = NO;
|
||||
// note that this is a pseudo-sheet (and causes Cocoa to complain about runModalForWindow:relativeToWindow).
|
||||
// Ideally, we'd be able to get a panel from nsAlertController and run it as a sheet ourselves.
|
||||
int result = [controller confirmCheckEx:[self window]
|
||||
title:NSLocalizedString(@"CloseWindowWithMultipleTabsMsg", @"")
|
||||
text:[NSString stringWithFormat:closeMultipleTabWarning, numberOfTabs]
|
||||
button1:NSLocalizedString(@"CloseWindowWithMultipleTabsButton", @"")
|
||||
button2:NSLocalizedString(@"CancelButtonText", @"")
|
||||
button3:nil
|
||||
checkMsg:NSLocalizedString(@"CloseWindowWithMultipleTabsCheckboxLabel", @"")
|
||||
checkValue:&dontShowAgain];
|
||||
if (dontShowAgain)
|
||||
[[PreferenceManager sharedInstance] setPref:"camino.warn_when_closing" toBoolean:NO];
|
||||
|
||||
return (result == NSAlertDefaultReturn);
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)windowWillClose:(NSNotification *)notification
|
||||
{
|
||||
mClosingWindow = YES;
|
||||
|
@ -2876,6 +2906,14 @@ enum BWCOpenDest {
|
|||
return mChromeMask;
|
||||
}
|
||||
|
||||
-(BOOL)hasFullBrowserChrome
|
||||
{
|
||||
return (mChromeMask == 0 ||
|
||||
(mChromeMask & nsIWebBrowserChrome::CHROME_TOOLBAR &&
|
||||
mChromeMask & nsIWebBrowserChrome::CHROME_STATUSBAR &&
|
||||
mChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE));
|
||||
}
|
||||
|
||||
- (IBAction)biggerTextSize:(id)aSender
|
||||
{
|
||||
[[mBrowserView getBrowserView] biggerTextSize];
|
||||
|
|
|
@ -574,7 +574,7 @@ static id gSharedProgressController = nil;
|
|||
NSString *alert = NSLocalizedString(@"QuitWithDownloadsMsg", nil);
|
||||
NSString *message = NSLocalizedString(@"QuitWithDownloadsExpl", nil);
|
||||
NSString *okButton = NSLocalizedString(@"QuitWithdownloadsButtonDefault", nil);
|
||||
NSString *altButton = NSLocalizedString(@"QuitWithdownloadsButtonAlt", nil);
|
||||
NSString *altButton = NSLocalizedString(@"QuitButtonText", nil);
|
||||
|
||||
// while the panel is up, download dialogs won't update (no timers firing) but
|
||||
// downloads continue (PLEvents being processed)
|
||||
|
|
|
@ -346,7 +346,7 @@ static BOOL gMadePrefManager;
|
|||
NSString* errorString = [NSString stringWithFormat:inTitleFormat, applicationName];
|
||||
NSString* messageString = [NSString stringWithFormat:inMessageFormat, applicationName];
|
||||
|
||||
NSRunAlertPanel(errorString, messageString, NSLocalizedString(@"QuitButton", @""), nil, nil);
|
||||
NSRunAlertPanel(errorString, messageString, NSLocalizedString(@"QuitButtonText", @""), nil, nil);
|
||||
[NSApp terminate:self];
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче