diff --git a/camino/src/application/MainController.h b/camino/src/application/MainController.h index 958a03191cf9..61831894b67f 100644 --- a/camino/src/application/MainController.h +++ b/camino/src/application/MainController.h @@ -108,6 +108,9 @@ typedef enum EBookmarkOpenBehavior // File menu actions. -(IBAction) newWindow:(id)aSender; +-(IBAction) newTab:(id)aSender; +-(IBAction) closeAllWindows:(id)aSender; +-(IBAction) closeTab:(id)aSender; -(IBAction) openFile:(id)aSender; -(IBAction) openLocation:(id)aSender; -(IBAction) savePage:(id)aSender; @@ -124,8 +127,6 @@ typedef enum EBookmarkOpenBehavior -(IBAction) goForward:(id)aSender; -(IBAction) goHome:(id)aSender; -(IBAction) doSearch:(id)aSender; --(IBAction) previousTab:(id)aSender; --(IBAction) nextTab:(id)aSender; // Local servers submenu -(IBAction) aboutServers:(id)aSender; @@ -134,6 +135,7 @@ typedef enum EBookmarkOpenBehavior // View menu actions. -(IBAction) toggleBookmarksToolbar:(id)aSender; -(IBAction) doReload:(id)aSender; +-(IBAction) doReloadAllTabs:(id)aSender; -(IBAction) doStop:(id)aSender; -(IBAction) biggerTextSize:(id)aSender; -(IBAction) smallerTextSize:(id)aSender; @@ -151,8 +153,9 @@ typedef enum EBookmarkOpenBehavior -(IBAction) openMenuBookmark:(id)aSender; // Window menu actions --(IBAction) newTab:(id)aSender; --(IBAction) closeTab:(id)aSender; +-(IBAction) zoomAll:(id)aSender; +-(IBAction) previousTab:(id)aSender; +-(IBAction) nextTab:(id)aSender; -(IBAction) downloadsWindow:(id)aSender; // Help menu actions diff --git a/camino/src/application/MainController.mm b/camino/src/application/MainController.mm index 28e7ec71efe2..bde513639bec 100644 --- a/camino/src/application/MainController.mm +++ b/camino/src/application/MainController.mm @@ -639,7 +639,68 @@ Otherwise, we return the URL we originally got. Right now this supports .url, } } -// XXX move to BWC +// +// Closes all windows (including minimized windows), respecting the "warn before closing multiple tabs" pref +// +-(IBAction)closeAllWindows:(id)aSender +{ + BOOL doCloseWindows = YES; + PreferenceManager* prefManager = [PreferenceManager sharedInstance]; + + if ([prefManager getBooleanPref:"camino.warn_when_closing" withSuccess:NULL]) { + NSString* closeAlertMsg = nil; + NSString* closeAlertExpl = nil; + + NSArray* openBrowserWins = [self browserWindows]; + // We need different warnings depending on whether there's only a single window with multiple tabs, + // or multiple windows open + if ([openBrowserWins count] == 1) { + BrowserWindowController* bwc = [self getMainWindowBrowserController]; + unsigned int numTabs = [[bwc getTabBrowser] numberOfTabViewItems]; + if (numTabs > 1) { // only show the warning if there are multiple tabs + closeAlertMsg = NSLocalizedString(@"CloseWindowWithMultipleTabsMsg", @""); + closeAlertExpl = [NSString stringWithFormat:NSLocalizedString(@"CloseWindowWithMultipleTabsExplFormat", @""), + numTabs]; + } + } else if ([openBrowserWins count] > 1) { + closeAlertMsg = NSLocalizedString(@"CloseMultipleWindowsMsg", @""); + closeAlertExpl = [NSString stringWithFormat:NSLocalizedString(@"CloseMultipleWindowsExpl", @""), + [openBrowserWins count]]; + } + + // make the warning dialog + if (closeAlertMsg) { + [NSApp activateIgnoringOtherApps:YES]; + nsAlertController* controller = CHBrowserService::GetAlertController(); + BOOL dontShowAgain = NO; + + NS_DURING + doCloseWindows = [controller confirmCheckEx:nil + title:closeAlertMsg + text:closeAlertExpl + button1:NSLocalizedString(@"OKButtonText", @"") + button2:NSLocalizedString(@"CancelButtonText", @"") + button3:nil + checkMsg:NSLocalizedString(@"CloseMultipleWindowsCheckboxLabel", @"") + checkValue:&dontShowAgain]; + NS_HANDLER + NS_ENDHANDLER + + if (dontShowAgain) + [prefManager setPref:"camino.warn_when_closing" toBoolean:NO]; + } + } + + // Actually close the windows + if (doCloseWindows) { + NSArray* windows = [NSApp windows]; + NSEnumerator* windowEnum = [windows objectEnumerator]; + NSWindow* curWindow; + while (curWindow = [windowEnum nextObject]) + [curWindow close]; + } +} + -(IBAction)closeTab:(id)aSender { BrowserWindowController* browserController = [self getMainWindowBrowserController]; @@ -647,7 +708,6 @@ Otherwise, we return the URL we originally got. Right now this supports .url, [browserController closeCurrentTab:aSender]; } -// XXX move to BWC -(IBAction) previousTab:(id)aSender { BrowserWindowController* browserController = [self getMainWindowBrowserController]; @@ -655,7 +715,6 @@ Otherwise, we return the URL we originally got. Right now this supports .url, [browserController previousTab:aSender]; } -// XXX move to BWC -(IBAction) nextTab:(id)aSender { BrowserWindowController* browserController = [self getMainWindowBrowserController]; @@ -812,7 +871,6 @@ Otherwise, we return the URL we originally got. Right now this supports .url, [mFindDialog showWindow:self]; } -// XXX move to BWC -(IBAction) goBack:(id)aSender { BrowserWindowController* browserController = [self getMainWindowBrowserController]; @@ -820,7 +878,6 @@ Otherwise, we return the URL we originally got. Right now this supports .url, [browserController back: aSender]; } -// XXX move to BWC -(IBAction) goForward:(id)aSender { BrowserWindowController* browserController = [self getMainWindowBrowserController]; @@ -828,7 +885,6 @@ Otherwise, we return the URL we originally got. Right now this supports .url, [browserController forward: aSender]; } -// XXX move to BWC -(IBAction) doReload:(id)aSender { BrowserWindowController* browserController = [self getMainWindowBrowserController]; @@ -836,7 +892,13 @@ Otherwise, we return the URL we originally got. Right now this supports .url, [browserController reload: aSender]; } -// XXX move to BWC +-(IBAction) doReloadAllTabs:(id)aSender +{ + BrowserWindowController* browserController = [self getMainWindowBrowserController]; + if (browserController) + [browserController reloadAllTabs:aSender]; +} + -(IBAction) reloadWithCharset:(id)aSender { // Figure out which charset to tell gecko to load based on the sender's tag. There @@ -859,7 +921,6 @@ Otherwise, we return the URL we originally got. Right now this supports .url, [self doReload:nil]; } -// XXX move to BWC -(IBAction) doStop:(id)aSender { BrowserWindowController* browserController = [self getMainWindowBrowserController]; @@ -1426,7 +1487,8 @@ Otherwise, we return the URL we originally got. Right now this supports .url, // only activate if we've got multiple tabs open. if (action == @selector(nextTab:) || - action == @selector(previousTab:)) + action == @selector(previousTab:) || + action == @selector(doReloadAllTabs:)) { return (browserController && [[browserController getTabBrowser] numberOfTabViewItems] > 1); } @@ -1496,6 +1558,15 @@ Otherwise, we return the URL we originally got. Right now this supports .url, [defaults setInteger: ((showToolbar) ? 0 : 1) forKey: USER_DEFAULTS_HIDE_PERS_TOOLBAR_KEY]; } +-(IBAction) zoomAll:(id)aSender +{ + NSArray* windows = [NSApp windows]; + NSEnumerator* windowEnum = [windows objectEnumerator]; + NSWindow* curWindow; + while (curWindow = [windowEnum nextObject]) + [curWindow zoom:aSender]; +} + -(IBAction) supportLink:(id)aSender; { NSString* pageToLoad = NSLocalizedStringFromTable(@"SupportPageDefault", @"WebsiteDefaults", nil); diff --git a/camino/src/browser/BrowserWindow.mm b/camino/src/browser/BrowserWindow.mm index acdd7382762d..4be163a0b19c 100644 --- a/camino/src/browser/BrowserWindow.mm +++ b/camino/src/browser/BrowserWindow.mm @@ -104,7 +104,6 @@ static const int kEscapeKeyCode = 53; // Pass command-return off to the controller so that locations/searches may be opened in a new tab. // Pass command-plus off to the controller to enlarge the text size. -// Pass command-shift-r off to the controller for force-reload. // Pass command-1..9 to the controller to load that bookmark bar item - (BOOL)performKeyEquivalent:(NSEvent *)theEvent { @@ -119,9 +118,6 @@ static const int kEscapeKeyCode = 53; } else if (keyChar == '+') { [windowController biggerTextSize:nil]; handled = YES; - } else if (keyChar == 'R') { // Capital letter implies shift key. - [windowController reload:nil]; // The window controller does the check for the shift key. - handled = YES; } else if (keyChar >= '1' && keyChar <= '9') { BOOL cmdKeyIsDown = (([theEvent modifierFlags] & NSCommandKeyMask) != 0); if (cmdKeyIsDown) {