зеркало из https://github.com/mozilla/pjs.git
Fix assumptions all over the code about the main window being a browser window; it can be a progress window, or the About window (and others in future). Ensure that the menu items that are enabled when a non-browser window is frontmost work as expected (e.g. Mange Bookmarks, opening a bookmark).
This commit is contained in:
Родитель
f99ea6f20f
Коммит
42ada52952
|
@ -55,8 +55,7 @@ static const NSString *kEllipsis = @"...";
|
||||||
- (nsIWebNavigation*) currentWebNavigation
|
- (nsIWebNavigation*) currentWebNavigation
|
||||||
{
|
{
|
||||||
// get controller for current window
|
// get controller for current window
|
||||||
BrowserWindowController *controller;
|
BrowserWindowController *controller = [[NSApp delegate] getMainWindowBrowserController];
|
||||||
controller = (BrowserWindowController*)[[NSApp mainWindow] windowController];
|
|
||||||
if (!controller) return nsnull;
|
if (!controller) return nsnull;
|
||||||
|
|
||||||
// get web navigation for current browser
|
// get web navigation for current browser
|
||||||
|
|
|
@ -141,6 +141,9 @@ class BookmarksService;
|
||||||
- (CHPreferenceManager *)preferenceManager;
|
- (CHPreferenceManager *)preferenceManager;
|
||||||
- (BOOL)isMainWindowABrowserWindow;
|
- (BOOL)isMainWindowABrowserWindow;
|
||||||
|
|
||||||
|
// if the main window is a browser window, return its controller, otherwise nil
|
||||||
|
- (BrowserWindowController*)getMainWindowBrowserController;
|
||||||
|
|
||||||
- (IBAction)showAboutBox:(id)sender;
|
- (IBAction)showAboutBox:(id)sender;
|
||||||
|
|
||||||
+ (NSImage*)createImageForDragging:(NSImage*)aIcon title:(NSString*)aTitle;
|
+ (NSImage*)createImageForDragging:(NSImage*)aIcon title:(NSString*)aTitle;
|
||||||
|
|
|
@ -176,22 +176,30 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction)newTab:(id)aSender
|
-(IBAction)newTab:(id)aSender
|
||||||
{
|
{
|
||||||
[(BrowserWindowController*)[[mApplication mainWindow] windowController] newTab:YES];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController newTab:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction)closeTab:(id)aSender
|
-(IBAction)closeTab:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] closeTab];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController closeTab];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) previousTab:(id)aSender
|
-(IBAction) previousTab:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] previousTab];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController previousTab];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) nextTab:(id)aSender;
|
-(IBAction) nextTab:(id)aSender;
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] nextTab];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController nextTab];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) openFile:(id)aSender
|
-(IBAction) openFile:(id)aSender
|
||||||
|
@ -213,10 +221,12 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
// ----------------------
|
// ----------------------
|
||||||
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:url];
|
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:url];
|
||||||
// ----------------------
|
// ----------------------
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
|
||||||
if (mainWindow) {
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
[[mainWindow windowController] loadURL:[url absoluteString] referrer:nil];
|
if (browserController)
|
||||||
[[[[mainWindow windowController] getBrowserWrapper] getBrowserView] setActive: YES];
|
{
|
||||||
|
[browserController loadURL:[url absoluteString] referrer:nil];
|
||||||
|
[[[browserController getBrowserWrapper] getBrowserView] setActive: YES];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
[self openBrowserWindowWithURL:[url absoluteString] andReferrer:nil];
|
[self openBrowserWindowWithURL:[url absoluteString] andReferrer:nil];
|
||||||
|
@ -225,28 +235,37 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction) openLocation:(id)aSender
|
-(IBAction) openLocation:(id)aSender
|
||||||
{
|
{
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
if (!mainWindow) {
|
if (!browserWindow) {
|
||||||
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
||||||
mainWindow = [mApplication mainWindow];
|
browserWindow = [mApplication mainWindow];
|
||||||
|
}
|
||||||
|
else if (![browserWindow isMainWindow]) {
|
||||||
|
[browserWindow makeKeyAndOrderFront:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[mainWindow windowController] performAppropriateLocationAction];
|
[[browserWindow windowController] performAppropriateLocationAction];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) savePage:(id)aSender
|
-(IBAction) savePage:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] saveDocument: mFilterView filterList: mFilterList];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController saveDocument: mFilterView filterList: mFilterList];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) printPage:(id)aSender
|
-(IBAction) printPage:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] printDocument];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController printDocument];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) printPreview:(id)aSender
|
-(IBAction) printPreview:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] printPreview];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController printPreview];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) toggleOfflineMode:(id)aSender
|
-(IBAction) toggleOfflineMode:(id)aSender
|
||||||
|
@ -304,27 +323,44 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction) goBack:(id)aSender
|
-(IBAction) goBack:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] back: aSender];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController back: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) goForward:(id)aSender
|
-(IBAction) goForward:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] forward: aSender];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController forward: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) doReload:(id)aSender
|
-(IBAction) doReload:(id)aSender
|
||||||
{
|
{
|
||||||
[(BrowserWindowController*)([[mApplication mainWindow] windowController]) reload: aSender];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController reload: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) doStop:(id)aSender
|
-(IBAction) doStop:(id)aSender
|
||||||
{
|
{
|
||||||
[(BrowserWindowController*)([[mApplication mainWindow] windowController]) stop: aSender];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController stop: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) goHome:(id)aSender
|
-(IBAction) goHome:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] home: aSender];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
|
if (browserWindow) {
|
||||||
|
if (![browserWindow isMainWindow])
|
||||||
|
[browserWindow makeKeyAndOrderFront:self];
|
||||||
|
|
||||||
|
[[browserWindow windowController] home: aSender];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[self newWindow:self];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)adjustBookmarksMenuItemsEnabling:(BOOL)inBrowserWindowFrontmost;
|
- (void)adjustBookmarksMenuItemsEnabling:(BOOL)inBrowserWindowFrontmost;
|
||||||
|
@ -403,7 +439,6 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
}
|
}
|
||||||
|
|
||||||
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
|
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -449,24 +484,28 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
return;
|
return;
|
||||||
NSURL* url = [urlArray objectAtIndex: 0];
|
NSURL* url = [urlArray objectAtIndex: 0];
|
||||||
|
|
||||||
NSWindow* window = [mApplication mainWindow];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
if (!window) {
|
if (!browserWindow) {
|
||||||
[self newWindow: self];
|
[self newWindow: self];
|
||||||
window = [mApplication mainWindow];
|
browserWindow = [mApplication mainWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[window windowController] importBookmarks: [url absoluteString]];
|
[[browserWindow windowController] importBookmarks: [url absoluteString]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) addBookmark:(id)aSender
|
-(IBAction) addBookmark:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: NO URL:nil title:nil];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController addBookmarkExtended: YES isFolder: NO URL:nil title:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) addFolder:(id)aSender
|
-(IBAction) addFolder:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: YES URL:nil title:nil];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController addBookmarkExtended: YES isFolder: YES URL:nil title:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) addSeparator:(id)aSender
|
-(IBAction) addSeparator:(id)aSender
|
||||||
|
@ -476,24 +515,24 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction) openMenuBookmark:(id)aSender
|
-(IBAction) openMenuBookmark:(id)aSender
|
||||||
{
|
{
|
||||||
NSWindow* mainWind = [mApplication mainWindow];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
if (!mainWind) {
|
if (!browserWindow) {
|
||||||
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
||||||
mainWind = [mApplication mainWindow];
|
browserWindow = [mApplication mainWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
BookmarksService::OpenMenuBookmark([mainWind windowController], aSender);
|
BookmarksService::OpenMenuBookmark([browserWindow windowController], aSender);
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction)manageBookmarks: (id)aSender
|
-(IBAction)manageBookmarks: (id)aSender
|
||||||
{
|
{
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
if (!mainWindow) {
|
if (!browserWindow) {
|
||||||
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
[self newWindow:self];
|
||||||
mainWindow = [mApplication mainWindow];
|
browserWindow = [mApplication mainWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[mainWindow windowController] manageBookmarks: aSender];
|
[[browserWindow windowController] manageBookmarks: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CHPreferenceManager *)preferenceManager
|
- (CHPreferenceManager *)preferenceManager
|
||||||
|
@ -544,28 +583,40 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
- (IBAction)biggerTextSize:(id)aSender
|
- (IBAction)biggerTextSize:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] biggerTextSize];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController biggerTextSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)smallerTextSize:(id)aSender
|
- (IBAction)smallerTextSize:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] smallerTextSize];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController smallerTextSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) viewSource:(id)aSender
|
-(IBAction) viewSource:(id)aSender
|
||||||
{
|
{
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
if (mainWindow && [[mainWindow windowController] respondsToSelector:@selector(viewSource:)] )
|
if (browserController)
|
||||||
[[mainWindow windowController] viewSource: self];
|
[browserController viewSource: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-(BOOL)isMainWindowABrowserWindow
|
-(BOOL)isMainWindowABrowserWindow
|
||||||
{
|
{
|
||||||
// see also getFrontmostBrowserWindow
|
// see also getFrontmostBrowserWindow
|
||||||
return [[[mApplication mainWindow] windowController] isMemberOfClass:[BrowserWindowController class]];
|
return [[[mApplication mainWindow] windowController] isMemberOfClass:[BrowserWindowController class]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BrowserWindowController*)getMainWindowBrowserController
|
||||||
|
{
|
||||||
|
NSWindowController* mainWindowController = [[mApplication mainWindow] windowController];
|
||||||
|
if (mainWindowController && [mainWindowController isMemberOfClass:[BrowserWindowController class]])
|
||||||
|
return (BrowserWindowController*)mainWindowController;
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)adjustCloseWindowMenuItemKeyEquivalent:(BOOL)inHaveTabs
|
- (void)adjustCloseWindowMenuItemKeyEquivalent:(BOOL)inHaveTabs
|
||||||
{
|
{
|
||||||
// capitalization of the key equivalent affects whether the shift modifer is used.
|
// capitalization of the key equivalent affects whether the shift modifer is used.
|
||||||
|
@ -588,14 +639,18 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
// Close Tab/Close Window accordingly
|
// Close Tab/Close Window accordingly
|
||||||
- (void)fixCloseMenuItemKeyEquivalents
|
- (void)fixCloseMenuItemKeyEquivalents
|
||||||
{
|
{
|
||||||
BOOL windowWithMultipleTabs = ([[[[mApplication mainWindow] windowController] getTabBrowser] numberOfTabViewItems] > 1);
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController) {
|
||||||
[self adjustCloseWindowMenuItemKeyEquivalent:windowWithMultipleTabs];
|
BOOL windowWithMultipleTabs = ([[browserController getTabBrowser] numberOfTabViewItems] > 1);
|
||||||
[self adjustCloseTabMenuItemKeyEquivalent:windowWithMultipleTabs];
|
[self adjustCloseWindowMenuItemKeyEquivalent:windowWithMultipleTabs];
|
||||||
|
[self adjustCloseTabMenuItemKeyEquivalent:windowWithMultipleTabs];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(BOOL)validateMenuItem: (NSMenuItem*)aMenuItem
|
-(BOOL)validateMenuItem: (NSMenuItem*)aMenuItem
|
||||||
{
|
{
|
||||||
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
|
||||||
// disable items that aren't relevant if there's no main browser window open
|
// disable items that aren't relevant if there's no main browser window open
|
||||||
SEL action = [aMenuItem action];
|
SEL action = [aMenuItem action];
|
||||||
|
|
||||||
|
@ -611,14 +666,14 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
action == @selector(viewSource:) ||
|
action == @selector(viewSource:) ||
|
||||||
action == @selector(goHome:) ||
|
action == @selector(goHome:) ||
|
||||||
action == @selector(savePage:)) {
|
action == @selector(savePage:)) {
|
||||||
if ([self isMainWindowABrowserWindow])
|
if (browserController)
|
||||||
return YES;
|
return YES;
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if someone has previously done a find before allowing findAgain to be enabled
|
// check if someone has previously done a find before allowing findAgain to be enabled
|
||||||
if (action == @selector(findAgain:)) {
|
if (action == @selector(findAgain:)) {
|
||||||
if ([self isMainWindowABrowserWindow])
|
if (browserController)
|
||||||
return (mFindDialog && [[mFindDialog getSearchText] length] > 0);
|
return (mFindDialog && [[mFindDialog getSearchText] length] > 0);
|
||||||
else
|
else
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -628,8 +683,8 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
// window open. Popup windows that have the personal toolbar removed should always gray
|
// window open. Popup windows that have the personal toolbar removed should always gray
|
||||||
// out this menu.
|
// out this menu.
|
||||||
if (action == @selector(toggleBookmarksToolbar:)) {
|
if (action == @selector(toggleBookmarksToolbar:)) {
|
||||||
if ([self isMainWindowABrowserWindow]) {
|
if (browserController) {
|
||||||
NSView* bookmarkToolbar = [[[mApplication mainWindow] windowController] bookmarksToolbar];
|
NSView* bookmarkToolbar = [browserController bookmarksToolbar];
|
||||||
if ( bookmarkToolbar ) {
|
if ( bookmarkToolbar ) {
|
||||||
float height = [bookmarkToolbar frame].size.height;
|
float height = [bookmarkToolbar frame].size.height;
|
||||||
BOOL toolbarShowing = (height > 0);
|
BOOL toolbarShowing = (height > 0);
|
||||||
|
@ -651,21 +706,21 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
action == @selector (nextTab:) ||
|
action == @selector (nextTab:) ||
|
||||||
action == @selector (previousTab:)))
|
action == @selector (previousTab:)))
|
||||||
{
|
{
|
||||||
if ([[[[mApplication mainWindow] windowController] getTabBrowser] numberOfTabViewItems] > 1)
|
if (browserController && [[browserController getTabBrowser] numberOfTabViewItems] > 1)
|
||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( action == @selector(doStop:) ) {
|
if ( action == @selector(doStop:) ) {
|
||||||
if ([self isMainWindowABrowserWindow])
|
if (browserController)
|
||||||
return [[[[mApplication mainWindow] windowController] getBrowserWrapper] isBusy];
|
return [[browserController getBrowserWrapper] isBusy];
|
||||||
else
|
else
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
if ( action == @selector(goBack:) || action == @selector(goForward:) ) {
|
if ( action == @selector(goBack:) || action == @selector(goForward:) ) {
|
||||||
if ([self isMainWindowABrowserWindow]) {
|
if (browserController) {
|
||||||
CHBrowserView* browserView = [[[[mApplication mainWindow] windowController] getBrowserWrapper] getBrowserView];
|
CHBrowserView* browserView = [[browserController getBrowserWrapper] getBrowserView];
|
||||||
if (action == @selector(goBack:))
|
if (action == @selector(goBack:))
|
||||||
return [browserView canGoBack];
|
return [browserView canGoBack];
|
||||||
if (action == @selector(goForward:))
|
if (action == @selector(goForward:))
|
||||||
|
@ -681,20 +736,17 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction) toggleBookmarksToolbar:(id)aSender
|
-(IBAction) toggleBookmarksToolbar:(id)aSender
|
||||||
{
|
{
|
||||||
// do nothing if there is no window. we shouldn't get here in that case anyway, but
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
// just to be safe. If there is a browser window, toggle it's personal toolbar.
|
if (!browserController) return;
|
||||||
if ( [self isMainWindowABrowserWindow] ) {
|
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
|
||||||
|
|
||||||
float height = [[[mainWindow windowController] bookmarksToolbar] frame].size.height;
|
float height = [[browserController bookmarksToolbar] frame].size.height;
|
||||||
BOOL showToolbar = (BOOL)(!(height > 0));
|
BOOL showToolbar = (BOOL)(!(height > 0));
|
||||||
|
|
||||||
[[[mainWindow windowController] bookmarksToolbar] showBookmarksToolbar: showToolbar];
|
[[browserController bookmarksToolbar] showBookmarksToolbar: showToolbar];
|
||||||
|
|
||||||
// save prefs here
|
// save prefs here
|
||||||
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
|
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
|
||||||
[defaults setInteger: ((showToolbar) ? 0 : 1) forKey: USER_DEFAULTS_HIDE_PERS_TOOLBAR_KEY];
|
[defaults setInteger: ((showToolbar) ? 0 : 1) forKey: USER_DEFAULTS_HIDE_PERS_TOOLBAR_KEY];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) infoLink:(id)aSender
|
-(IBAction) infoLink:(id)aSender
|
||||||
|
|
|
@ -77,7 +77,7 @@ SecurityDialogs::UnknownIssuer(nsITransportSecurityInfo *socketInfo,
|
||||||
// HACK: there is no way to get which window this is for from the API. The
|
// HACK: there is no way to get which window this is for from the API. The
|
||||||
// security team in mozilla just cheats and assumes the frontmost window so
|
// security team in mozilla just cheats and assumes the frontmost window so
|
||||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||||
*outAddType = (PRBool)[controller unknownCert:[NSApp mainWindow]];
|
*outAddType = (PRBool)[controller unknownCert:[[NSApp delegate] getFrontmostBrowserWindow]];
|
||||||
switch ( *outAddType ) {
|
switch ( *outAddType ) {
|
||||||
case nsIBadCertListener::ADD_TRUSTED_FOR_SESSION:
|
case nsIBadCertListener::ADD_TRUSTED_FOR_SESSION:
|
||||||
case nsIBadCertListener::ADD_TRUSTED_PERMANENTLY:
|
case nsIBadCertListener::ADD_TRUSTED_PERMANENTLY:
|
||||||
|
@ -105,7 +105,7 @@ SecurityDialogs::MismatchDomain(nsITransportSecurityInfo *socketInfo,
|
||||||
// HACK: there is no way to get which window this is for from the API. The
|
// HACK: there is no way to get which window this is for from the API. The
|
||||||
// security team in mozilla just cheats and assumes the frontmost window so
|
// security team in mozilla just cheats and assumes the frontmost window so
|
||||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||||
*_retval = (PRBool)[controller badCert:[NSApp mainWindow]];
|
*_retval = (PRBool)[controller badCert:[[NSApp delegate] getFrontmostBrowserWindow]];
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ SecurityDialogs::CertExpired(nsITransportSecurityInfo *socketInfo,
|
||||||
// HACK: there is no way to get which window this is for from the API. The
|
// HACK: there is no way to get which window this is for from the API. The
|
||||||
// security team in mozilla just cheats and assumes the frontmost window so
|
// security team in mozilla just cheats and assumes the frontmost window so
|
||||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||||
*_retval = (PRBool)[controller expiredCert:[NSApp mainWindow]];
|
*_retval = (PRBool)[controller expiredCert:[[NSApp delegate] getFrontmostBrowserWindow]];
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ SecurityDialogs::ConfirmPostToInsecureFromSecure(nsIInterfaceRequestor *ctx,
|
||||||
// HACK: there is no way to get which window this is for from the API. The
|
// HACK: there is no way to get which window this is for from the API. The
|
||||||
// security team in mozilla just cheats and assumes the frontmost window so
|
// security team in mozilla just cheats and assumes the frontmost window so
|
||||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||||
*_result = (PRBool)[controller postToInsecureFromSecure:[NSApp mainWindow]];
|
*_result = (PRBool)[controller postToInsecureFromSecure:[[NSApp delegate] getFrontmostBrowserWindow]];
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,9 @@ class BookmarksService;
|
||||||
- (CHPreferenceManager *)preferenceManager;
|
- (CHPreferenceManager *)preferenceManager;
|
||||||
- (BOOL)isMainWindowABrowserWindow;
|
- (BOOL)isMainWindowABrowserWindow;
|
||||||
|
|
||||||
|
// if the main window is a browser window, return its controller, otherwise nil
|
||||||
|
- (BrowserWindowController*)getMainWindowBrowserController;
|
||||||
|
|
||||||
- (IBAction)showAboutBox:(id)sender;
|
- (IBAction)showAboutBox:(id)sender;
|
||||||
|
|
||||||
+ (NSImage*)createImageForDragging:(NSImage*)aIcon title:(NSString*)aTitle;
|
+ (NSImage*)createImageForDragging:(NSImage*)aIcon title:(NSString*)aTitle;
|
||||||
|
|
|
@ -176,22 +176,30 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction)newTab:(id)aSender
|
-(IBAction)newTab:(id)aSender
|
||||||
{
|
{
|
||||||
[(BrowserWindowController*)[[mApplication mainWindow] windowController] newTab:YES];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController newTab:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction)closeTab:(id)aSender
|
-(IBAction)closeTab:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] closeTab];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController closeTab];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) previousTab:(id)aSender
|
-(IBAction) previousTab:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] previousTab];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController previousTab];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) nextTab:(id)aSender;
|
-(IBAction) nextTab:(id)aSender;
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] nextTab];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController nextTab];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) openFile:(id)aSender
|
-(IBAction) openFile:(id)aSender
|
||||||
|
@ -213,10 +221,12 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
// ----------------------
|
// ----------------------
|
||||||
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:url];
|
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:url];
|
||||||
// ----------------------
|
// ----------------------
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
|
||||||
if (mainWindow) {
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
[[mainWindow windowController] loadURL:[url absoluteString] referrer:nil];
|
if (browserController)
|
||||||
[[[[mainWindow windowController] getBrowserWrapper] getBrowserView] setActive: YES];
|
{
|
||||||
|
[browserController loadURL:[url absoluteString] referrer:nil];
|
||||||
|
[[[browserController getBrowserWrapper] getBrowserView] setActive: YES];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
[self openBrowserWindowWithURL:[url absoluteString] andReferrer:nil];
|
[self openBrowserWindowWithURL:[url absoluteString] andReferrer:nil];
|
||||||
|
@ -225,28 +235,37 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction) openLocation:(id)aSender
|
-(IBAction) openLocation:(id)aSender
|
||||||
{
|
{
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
if (!mainWindow) {
|
if (!browserWindow) {
|
||||||
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
||||||
mainWindow = [mApplication mainWindow];
|
browserWindow = [mApplication mainWindow];
|
||||||
|
}
|
||||||
|
else if (![browserWindow isMainWindow]) {
|
||||||
|
[browserWindow makeKeyAndOrderFront:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[mainWindow windowController] performAppropriateLocationAction];
|
[[browserWindow windowController] performAppropriateLocationAction];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) savePage:(id)aSender
|
-(IBAction) savePage:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] saveDocument: mFilterView filterList: mFilterList];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController saveDocument: mFilterView filterList: mFilterList];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) printPage:(id)aSender
|
-(IBAction) printPage:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] printDocument];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController printDocument];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) printPreview:(id)aSender
|
-(IBAction) printPreview:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] printPreview];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController printPreview];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) toggleOfflineMode:(id)aSender
|
-(IBAction) toggleOfflineMode:(id)aSender
|
||||||
|
@ -304,27 +323,44 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction) goBack:(id)aSender
|
-(IBAction) goBack:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] back: aSender];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController back: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) goForward:(id)aSender
|
-(IBAction) goForward:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] forward: aSender];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController forward: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) doReload:(id)aSender
|
-(IBAction) doReload:(id)aSender
|
||||||
{
|
{
|
||||||
[(BrowserWindowController*)([[mApplication mainWindow] windowController]) reload: aSender];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController reload: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) doStop:(id)aSender
|
-(IBAction) doStop:(id)aSender
|
||||||
{
|
{
|
||||||
[(BrowserWindowController*)([[mApplication mainWindow] windowController]) stop: aSender];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController stop: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) goHome:(id)aSender
|
-(IBAction) goHome:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] home: aSender];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
|
if (browserWindow) {
|
||||||
|
if (![browserWindow isMainWindow])
|
||||||
|
[browserWindow makeKeyAndOrderFront:self];
|
||||||
|
|
||||||
|
[[browserWindow windowController] home: aSender];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[self newWindow:self];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)adjustBookmarksMenuItemsEnabling:(BOOL)inBrowserWindowFrontmost;
|
- (void)adjustBookmarksMenuItemsEnabling:(BOOL)inBrowserWindowFrontmost;
|
||||||
|
@ -403,7 +439,6 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
}
|
}
|
||||||
|
|
||||||
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
|
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -449,24 +484,28 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
return;
|
return;
|
||||||
NSURL* url = [urlArray objectAtIndex: 0];
|
NSURL* url = [urlArray objectAtIndex: 0];
|
||||||
|
|
||||||
NSWindow* window = [mApplication mainWindow];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
if (!window) {
|
if (!browserWindow) {
|
||||||
[self newWindow: self];
|
[self newWindow: self];
|
||||||
window = [mApplication mainWindow];
|
browserWindow = [mApplication mainWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[window windowController] importBookmarks: [url absoluteString]];
|
[[browserWindow windowController] importBookmarks: [url absoluteString]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) addBookmark:(id)aSender
|
-(IBAction) addBookmark:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: NO URL:nil title:nil];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController addBookmarkExtended: YES isFolder: NO URL:nil title:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) addFolder:(id)aSender
|
-(IBAction) addFolder:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: YES URL:nil title:nil];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController addBookmarkExtended: YES isFolder: YES URL:nil title:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) addSeparator:(id)aSender
|
-(IBAction) addSeparator:(id)aSender
|
||||||
|
@ -476,24 +515,24 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction) openMenuBookmark:(id)aSender
|
-(IBAction) openMenuBookmark:(id)aSender
|
||||||
{
|
{
|
||||||
NSWindow* mainWind = [mApplication mainWindow];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
if (!mainWind) {
|
if (!browserWindow) {
|
||||||
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
||||||
mainWind = [mApplication mainWindow];
|
browserWindow = [mApplication mainWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
BookmarksService::OpenMenuBookmark([mainWind windowController], aSender);
|
BookmarksService::OpenMenuBookmark([browserWindow windowController], aSender);
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction)manageBookmarks: (id)aSender
|
-(IBAction)manageBookmarks: (id)aSender
|
||||||
{
|
{
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
if (!mainWindow) {
|
if (!browserWindow) {
|
||||||
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
[self newWindow:self];
|
||||||
mainWindow = [mApplication mainWindow];
|
browserWindow = [mApplication mainWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[mainWindow windowController] manageBookmarks: aSender];
|
[[browserWindow windowController] manageBookmarks: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CHPreferenceManager *)preferenceManager
|
- (CHPreferenceManager *)preferenceManager
|
||||||
|
@ -544,28 +583,40 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
- (IBAction)biggerTextSize:(id)aSender
|
- (IBAction)biggerTextSize:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] biggerTextSize];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController biggerTextSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)smallerTextSize:(id)aSender
|
- (IBAction)smallerTextSize:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] smallerTextSize];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController smallerTextSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) viewSource:(id)aSender
|
-(IBAction) viewSource:(id)aSender
|
||||||
{
|
{
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
if (mainWindow && [[mainWindow windowController] respondsToSelector:@selector(viewSource:)] )
|
if (browserController)
|
||||||
[[mainWindow windowController] viewSource: self];
|
[browserController viewSource: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-(BOOL)isMainWindowABrowserWindow
|
-(BOOL)isMainWindowABrowserWindow
|
||||||
{
|
{
|
||||||
// see also getFrontmostBrowserWindow
|
// see also getFrontmostBrowserWindow
|
||||||
return [[[mApplication mainWindow] windowController] isMemberOfClass:[BrowserWindowController class]];
|
return [[[mApplication mainWindow] windowController] isMemberOfClass:[BrowserWindowController class]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BrowserWindowController*)getMainWindowBrowserController
|
||||||
|
{
|
||||||
|
NSWindowController* mainWindowController = [[mApplication mainWindow] windowController];
|
||||||
|
if (mainWindowController && [mainWindowController isMemberOfClass:[BrowserWindowController class]])
|
||||||
|
return (BrowserWindowController*)mainWindowController;
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)adjustCloseWindowMenuItemKeyEquivalent:(BOOL)inHaveTabs
|
- (void)adjustCloseWindowMenuItemKeyEquivalent:(BOOL)inHaveTabs
|
||||||
{
|
{
|
||||||
// capitalization of the key equivalent affects whether the shift modifer is used.
|
// capitalization of the key equivalent affects whether the shift modifer is used.
|
||||||
|
@ -588,14 +639,18 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
// Close Tab/Close Window accordingly
|
// Close Tab/Close Window accordingly
|
||||||
- (void)fixCloseMenuItemKeyEquivalents
|
- (void)fixCloseMenuItemKeyEquivalents
|
||||||
{
|
{
|
||||||
BOOL windowWithMultipleTabs = ([[[[mApplication mainWindow] windowController] getTabBrowser] numberOfTabViewItems] > 1);
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController) {
|
||||||
[self adjustCloseWindowMenuItemKeyEquivalent:windowWithMultipleTabs];
|
BOOL windowWithMultipleTabs = ([[browserController getTabBrowser] numberOfTabViewItems] > 1);
|
||||||
[self adjustCloseTabMenuItemKeyEquivalent:windowWithMultipleTabs];
|
[self adjustCloseWindowMenuItemKeyEquivalent:windowWithMultipleTabs];
|
||||||
|
[self adjustCloseTabMenuItemKeyEquivalent:windowWithMultipleTabs];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(BOOL)validateMenuItem: (NSMenuItem*)aMenuItem
|
-(BOOL)validateMenuItem: (NSMenuItem*)aMenuItem
|
||||||
{
|
{
|
||||||
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
|
||||||
// disable items that aren't relevant if there's no main browser window open
|
// disable items that aren't relevant if there's no main browser window open
|
||||||
SEL action = [aMenuItem action];
|
SEL action = [aMenuItem action];
|
||||||
|
|
||||||
|
@ -611,14 +666,14 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
action == @selector(viewSource:) ||
|
action == @selector(viewSource:) ||
|
||||||
action == @selector(goHome:) ||
|
action == @selector(goHome:) ||
|
||||||
action == @selector(savePage:)) {
|
action == @selector(savePage:)) {
|
||||||
if ([self isMainWindowABrowserWindow])
|
if (browserController)
|
||||||
return YES;
|
return YES;
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if someone has previously done a find before allowing findAgain to be enabled
|
// check if someone has previously done a find before allowing findAgain to be enabled
|
||||||
if (action == @selector(findAgain:)) {
|
if (action == @selector(findAgain:)) {
|
||||||
if ([self isMainWindowABrowserWindow])
|
if (browserController)
|
||||||
return (mFindDialog && [[mFindDialog getSearchText] length] > 0);
|
return (mFindDialog && [[mFindDialog getSearchText] length] > 0);
|
||||||
else
|
else
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -628,8 +683,8 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
// window open. Popup windows that have the personal toolbar removed should always gray
|
// window open. Popup windows that have the personal toolbar removed should always gray
|
||||||
// out this menu.
|
// out this menu.
|
||||||
if (action == @selector(toggleBookmarksToolbar:)) {
|
if (action == @selector(toggleBookmarksToolbar:)) {
|
||||||
if ([self isMainWindowABrowserWindow]) {
|
if (browserController) {
|
||||||
NSView* bookmarkToolbar = [[[mApplication mainWindow] windowController] bookmarksToolbar];
|
NSView* bookmarkToolbar = [browserController bookmarksToolbar];
|
||||||
if ( bookmarkToolbar ) {
|
if ( bookmarkToolbar ) {
|
||||||
float height = [bookmarkToolbar frame].size.height;
|
float height = [bookmarkToolbar frame].size.height;
|
||||||
BOOL toolbarShowing = (height > 0);
|
BOOL toolbarShowing = (height > 0);
|
||||||
|
@ -651,21 +706,21 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
action == @selector (nextTab:) ||
|
action == @selector (nextTab:) ||
|
||||||
action == @selector (previousTab:)))
|
action == @selector (previousTab:)))
|
||||||
{
|
{
|
||||||
if ([[[[mApplication mainWindow] windowController] getTabBrowser] numberOfTabViewItems] > 1)
|
if (browserController && [[browserController getTabBrowser] numberOfTabViewItems] > 1)
|
||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( action == @selector(doStop:) ) {
|
if ( action == @selector(doStop:) ) {
|
||||||
if ([self isMainWindowABrowserWindow])
|
if (browserController)
|
||||||
return [[[[mApplication mainWindow] windowController] getBrowserWrapper] isBusy];
|
return [[browserController getBrowserWrapper] isBusy];
|
||||||
else
|
else
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
if ( action == @selector(goBack:) || action == @selector(goForward:) ) {
|
if ( action == @selector(goBack:) || action == @selector(goForward:) ) {
|
||||||
if ([self isMainWindowABrowserWindow]) {
|
if (browserController) {
|
||||||
CHBrowserView* browserView = [[[[mApplication mainWindow] windowController] getBrowserWrapper] getBrowserView];
|
CHBrowserView* browserView = [[browserController getBrowserWrapper] getBrowserView];
|
||||||
if (action == @selector(goBack:))
|
if (action == @selector(goBack:))
|
||||||
return [browserView canGoBack];
|
return [browserView canGoBack];
|
||||||
if (action == @selector(goForward:))
|
if (action == @selector(goForward:))
|
||||||
|
@ -681,20 +736,17 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction) toggleBookmarksToolbar:(id)aSender
|
-(IBAction) toggleBookmarksToolbar:(id)aSender
|
||||||
{
|
{
|
||||||
// do nothing if there is no window. we shouldn't get here in that case anyway, but
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
// just to be safe. If there is a browser window, toggle it's personal toolbar.
|
if (!browserController) return;
|
||||||
if ( [self isMainWindowABrowserWindow] ) {
|
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
|
||||||
|
|
||||||
float height = [[[mainWindow windowController] bookmarksToolbar] frame].size.height;
|
float height = [[browserController bookmarksToolbar] frame].size.height;
|
||||||
BOOL showToolbar = (BOOL)(!(height > 0));
|
BOOL showToolbar = (BOOL)(!(height > 0));
|
||||||
|
|
||||||
[[[mainWindow windowController] bookmarksToolbar] showBookmarksToolbar: showToolbar];
|
[[browserController bookmarksToolbar] showBookmarksToolbar: showToolbar];
|
||||||
|
|
||||||
// save prefs here
|
// save prefs here
|
||||||
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
|
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
|
||||||
[defaults setInteger: ((showToolbar) ? 0 : 1) forKey: USER_DEFAULTS_HIDE_PERS_TOOLBAR_KEY];
|
[defaults setInteger: ((showToolbar) ? 0 : 1) forKey: USER_DEFAULTS_HIDE_PERS_TOOLBAR_KEY];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) infoLink:(id)aSender
|
-(IBAction) infoLink:(id)aSender
|
||||||
|
|
|
@ -55,8 +55,7 @@ static const NSString *kEllipsis = @"...";
|
||||||
- (nsIWebNavigation*) currentWebNavigation
|
- (nsIWebNavigation*) currentWebNavigation
|
||||||
{
|
{
|
||||||
// get controller for current window
|
// get controller for current window
|
||||||
BrowserWindowController *controller;
|
BrowserWindowController *controller = [[NSApp delegate] getMainWindowBrowserController];
|
||||||
controller = (BrowserWindowController*)[[NSApp mainWindow] windowController];
|
|
||||||
if (!controller) return nsnull;
|
if (!controller) return nsnull;
|
||||||
|
|
||||||
// get web navigation for current browser
|
// get web navigation for current browser
|
||||||
|
|
|
@ -77,7 +77,7 @@ SecurityDialogs::UnknownIssuer(nsITransportSecurityInfo *socketInfo,
|
||||||
// HACK: there is no way to get which window this is for from the API. The
|
// HACK: there is no way to get which window this is for from the API. The
|
||||||
// security team in mozilla just cheats and assumes the frontmost window so
|
// security team in mozilla just cheats and assumes the frontmost window so
|
||||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||||
*outAddType = (PRBool)[controller unknownCert:[NSApp mainWindow]];
|
*outAddType = (PRBool)[controller unknownCert:[[NSApp delegate] getFrontmostBrowserWindow]];
|
||||||
switch ( *outAddType ) {
|
switch ( *outAddType ) {
|
||||||
case nsIBadCertListener::ADD_TRUSTED_FOR_SESSION:
|
case nsIBadCertListener::ADD_TRUSTED_FOR_SESSION:
|
||||||
case nsIBadCertListener::ADD_TRUSTED_PERMANENTLY:
|
case nsIBadCertListener::ADD_TRUSTED_PERMANENTLY:
|
||||||
|
@ -105,7 +105,7 @@ SecurityDialogs::MismatchDomain(nsITransportSecurityInfo *socketInfo,
|
||||||
// HACK: there is no way to get which window this is for from the API. The
|
// HACK: there is no way to get which window this is for from the API. The
|
||||||
// security team in mozilla just cheats and assumes the frontmost window so
|
// security team in mozilla just cheats and assumes the frontmost window so
|
||||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||||
*_retval = (PRBool)[controller badCert:[NSApp mainWindow]];
|
*_retval = (PRBool)[controller badCert:[[NSApp delegate] getFrontmostBrowserWindow]];
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ SecurityDialogs::CertExpired(nsITransportSecurityInfo *socketInfo,
|
||||||
// HACK: there is no way to get which window this is for from the API. The
|
// HACK: there is no way to get which window this is for from the API. The
|
||||||
// security team in mozilla just cheats and assumes the frontmost window so
|
// security team in mozilla just cheats and assumes the frontmost window so
|
||||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||||
*_retval = (PRBool)[controller expiredCert:[NSApp mainWindow]];
|
*_retval = (PRBool)[controller expiredCert:[[NSApp delegate] getFrontmostBrowserWindow]];
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ SecurityDialogs::ConfirmPostToInsecureFromSecure(nsIInterfaceRequestor *ctx,
|
||||||
// HACK: there is no way to get which window this is for from the API. The
|
// HACK: there is no way to get which window this is for from the API. The
|
||||||
// security team in mozilla just cheats and assumes the frontmost window so
|
// security team in mozilla just cheats and assumes the frontmost window so
|
||||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||||
*_result = (PRBool)[controller postToInsecureFromSecure:[NSApp mainWindow]];
|
*_result = (PRBool)[controller postToInsecureFromSecure:[[NSApp delegate] getFrontmostBrowserWindow]];
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,7 @@ static const NSString *kEllipsis = @"...";
|
||||||
- (nsIWebNavigation*) currentWebNavigation
|
- (nsIWebNavigation*) currentWebNavigation
|
||||||
{
|
{
|
||||||
// get controller for current window
|
// get controller for current window
|
||||||
BrowserWindowController *controller;
|
BrowserWindowController *controller = [[NSApp delegate] getMainWindowBrowserController];
|
||||||
controller = (BrowserWindowController*)[[NSApp mainWindow] windowController];
|
|
||||||
if (!controller) return nsnull;
|
if (!controller) return nsnull;
|
||||||
|
|
||||||
// get web navigation for current browser
|
// get web navigation for current browser
|
||||||
|
|
|
@ -141,6 +141,9 @@ class BookmarksService;
|
||||||
- (CHPreferenceManager *)preferenceManager;
|
- (CHPreferenceManager *)preferenceManager;
|
||||||
- (BOOL)isMainWindowABrowserWindow;
|
- (BOOL)isMainWindowABrowserWindow;
|
||||||
|
|
||||||
|
// if the main window is a browser window, return its controller, otherwise nil
|
||||||
|
- (BrowserWindowController*)getMainWindowBrowserController;
|
||||||
|
|
||||||
- (IBAction)showAboutBox:(id)sender;
|
- (IBAction)showAboutBox:(id)sender;
|
||||||
|
|
||||||
+ (NSImage*)createImageForDragging:(NSImage*)aIcon title:(NSString*)aTitle;
|
+ (NSImage*)createImageForDragging:(NSImage*)aIcon title:(NSString*)aTitle;
|
||||||
|
|
|
@ -176,22 +176,30 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction)newTab:(id)aSender
|
-(IBAction)newTab:(id)aSender
|
||||||
{
|
{
|
||||||
[(BrowserWindowController*)[[mApplication mainWindow] windowController] newTab:YES];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController newTab:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction)closeTab:(id)aSender
|
-(IBAction)closeTab:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] closeTab];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController closeTab];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) previousTab:(id)aSender
|
-(IBAction) previousTab:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] previousTab];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController previousTab];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) nextTab:(id)aSender;
|
-(IBAction) nextTab:(id)aSender;
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] nextTab];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController nextTab];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) openFile:(id)aSender
|
-(IBAction) openFile:(id)aSender
|
||||||
|
@ -213,10 +221,12 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
// ----------------------
|
// ----------------------
|
||||||
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:url];
|
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:url];
|
||||||
// ----------------------
|
// ----------------------
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
|
||||||
if (mainWindow) {
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
[[mainWindow windowController] loadURL:[url absoluteString] referrer:nil];
|
if (browserController)
|
||||||
[[[[mainWindow windowController] getBrowserWrapper] getBrowserView] setActive: YES];
|
{
|
||||||
|
[browserController loadURL:[url absoluteString] referrer:nil];
|
||||||
|
[[[browserController getBrowserWrapper] getBrowserView] setActive: YES];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
[self openBrowserWindowWithURL:[url absoluteString] andReferrer:nil];
|
[self openBrowserWindowWithURL:[url absoluteString] andReferrer:nil];
|
||||||
|
@ -225,28 +235,37 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction) openLocation:(id)aSender
|
-(IBAction) openLocation:(id)aSender
|
||||||
{
|
{
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
if (!mainWindow) {
|
if (!browserWindow) {
|
||||||
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
||||||
mainWindow = [mApplication mainWindow];
|
browserWindow = [mApplication mainWindow];
|
||||||
|
}
|
||||||
|
else if (![browserWindow isMainWindow]) {
|
||||||
|
[browserWindow makeKeyAndOrderFront:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[mainWindow windowController] performAppropriateLocationAction];
|
[[browserWindow windowController] performAppropriateLocationAction];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) savePage:(id)aSender
|
-(IBAction) savePage:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] saveDocument: mFilterView filterList: mFilterList];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController saveDocument: mFilterView filterList: mFilterList];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) printPage:(id)aSender
|
-(IBAction) printPage:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] printDocument];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController printDocument];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) printPreview:(id)aSender
|
-(IBAction) printPreview:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] printPreview];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController printPreview];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) toggleOfflineMode:(id)aSender
|
-(IBAction) toggleOfflineMode:(id)aSender
|
||||||
|
@ -304,27 +323,44 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction) goBack:(id)aSender
|
-(IBAction) goBack:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] back: aSender];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController back: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) goForward:(id)aSender
|
-(IBAction) goForward:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] forward: aSender];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController forward: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) doReload:(id)aSender
|
-(IBAction) doReload:(id)aSender
|
||||||
{
|
{
|
||||||
[(BrowserWindowController*)([[mApplication mainWindow] windowController]) reload: aSender];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController reload: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) doStop:(id)aSender
|
-(IBAction) doStop:(id)aSender
|
||||||
{
|
{
|
||||||
[(BrowserWindowController*)([[mApplication mainWindow] windowController]) stop: aSender];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController stop: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) goHome:(id)aSender
|
-(IBAction) goHome:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] home: aSender];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
|
if (browserWindow) {
|
||||||
|
if (![browserWindow isMainWindow])
|
||||||
|
[browserWindow makeKeyAndOrderFront:self];
|
||||||
|
|
||||||
|
[[browserWindow windowController] home: aSender];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[self newWindow:self];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)adjustBookmarksMenuItemsEnabling:(BOOL)inBrowserWindowFrontmost;
|
- (void)adjustBookmarksMenuItemsEnabling:(BOOL)inBrowserWindowFrontmost;
|
||||||
|
@ -403,7 +439,6 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
}
|
}
|
||||||
|
|
||||||
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
|
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -449,24 +484,28 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
return;
|
return;
|
||||||
NSURL* url = [urlArray objectAtIndex: 0];
|
NSURL* url = [urlArray objectAtIndex: 0];
|
||||||
|
|
||||||
NSWindow* window = [mApplication mainWindow];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
if (!window) {
|
if (!browserWindow) {
|
||||||
[self newWindow: self];
|
[self newWindow: self];
|
||||||
window = [mApplication mainWindow];
|
browserWindow = [mApplication mainWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[window windowController] importBookmarks: [url absoluteString]];
|
[[browserWindow windowController] importBookmarks: [url absoluteString]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) addBookmark:(id)aSender
|
-(IBAction) addBookmark:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: NO URL:nil title:nil];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController addBookmarkExtended: YES isFolder: NO URL:nil title:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) addFolder:(id)aSender
|
-(IBAction) addFolder:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: YES URL:nil title:nil];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController addBookmarkExtended: YES isFolder: YES URL:nil title:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) addSeparator:(id)aSender
|
-(IBAction) addSeparator:(id)aSender
|
||||||
|
@ -476,24 +515,24 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction) openMenuBookmark:(id)aSender
|
-(IBAction) openMenuBookmark:(id)aSender
|
||||||
{
|
{
|
||||||
NSWindow* mainWind = [mApplication mainWindow];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
if (!mainWind) {
|
if (!browserWindow) {
|
||||||
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
||||||
mainWind = [mApplication mainWindow];
|
browserWindow = [mApplication mainWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
BookmarksService::OpenMenuBookmark([mainWind windowController], aSender);
|
BookmarksService::OpenMenuBookmark([browserWindow windowController], aSender);
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction)manageBookmarks: (id)aSender
|
-(IBAction)manageBookmarks: (id)aSender
|
||||||
{
|
{
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
if (!mainWindow) {
|
if (!browserWindow) {
|
||||||
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
[self newWindow:self];
|
||||||
mainWindow = [mApplication mainWindow];
|
browserWindow = [mApplication mainWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[mainWindow windowController] manageBookmarks: aSender];
|
[[browserWindow windowController] manageBookmarks: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CHPreferenceManager *)preferenceManager
|
- (CHPreferenceManager *)preferenceManager
|
||||||
|
@ -544,28 +583,40 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
- (IBAction)biggerTextSize:(id)aSender
|
- (IBAction)biggerTextSize:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] biggerTextSize];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController biggerTextSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)smallerTextSize:(id)aSender
|
- (IBAction)smallerTextSize:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] smallerTextSize];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController smallerTextSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) viewSource:(id)aSender
|
-(IBAction) viewSource:(id)aSender
|
||||||
{
|
{
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
if (mainWindow && [[mainWindow windowController] respondsToSelector:@selector(viewSource:)] )
|
if (browserController)
|
||||||
[[mainWindow windowController] viewSource: self];
|
[browserController viewSource: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-(BOOL)isMainWindowABrowserWindow
|
-(BOOL)isMainWindowABrowserWindow
|
||||||
{
|
{
|
||||||
// see also getFrontmostBrowserWindow
|
// see also getFrontmostBrowserWindow
|
||||||
return [[[mApplication mainWindow] windowController] isMemberOfClass:[BrowserWindowController class]];
|
return [[[mApplication mainWindow] windowController] isMemberOfClass:[BrowserWindowController class]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BrowserWindowController*)getMainWindowBrowserController
|
||||||
|
{
|
||||||
|
NSWindowController* mainWindowController = [[mApplication mainWindow] windowController];
|
||||||
|
if (mainWindowController && [mainWindowController isMemberOfClass:[BrowserWindowController class]])
|
||||||
|
return (BrowserWindowController*)mainWindowController;
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)adjustCloseWindowMenuItemKeyEquivalent:(BOOL)inHaveTabs
|
- (void)adjustCloseWindowMenuItemKeyEquivalent:(BOOL)inHaveTabs
|
||||||
{
|
{
|
||||||
// capitalization of the key equivalent affects whether the shift modifer is used.
|
// capitalization of the key equivalent affects whether the shift modifer is used.
|
||||||
|
@ -588,14 +639,18 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
// Close Tab/Close Window accordingly
|
// Close Tab/Close Window accordingly
|
||||||
- (void)fixCloseMenuItemKeyEquivalents
|
- (void)fixCloseMenuItemKeyEquivalents
|
||||||
{
|
{
|
||||||
BOOL windowWithMultipleTabs = ([[[[mApplication mainWindow] windowController] getTabBrowser] numberOfTabViewItems] > 1);
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController) {
|
||||||
[self adjustCloseWindowMenuItemKeyEquivalent:windowWithMultipleTabs];
|
BOOL windowWithMultipleTabs = ([[browserController getTabBrowser] numberOfTabViewItems] > 1);
|
||||||
[self adjustCloseTabMenuItemKeyEquivalent:windowWithMultipleTabs];
|
[self adjustCloseWindowMenuItemKeyEquivalent:windowWithMultipleTabs];
|
||||||
|
[self adjustCloseTabMenuItemKeyEquivalent:windowWithMultipleTabs];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(BOOL)validateMenuItem: (NSMenuItem*)aMenuItem
|
-(BOOL)validateMenuItem: (NSMenuItem*)aMenuItem
|
||||||
{
|
{
|
||||||
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
|
||||||
// disable items that aren't relevant if there's no main browser window open
|
// disable items that aren't relevant if there's no main browser window open
|
||||||
SEL action = [aMenuItem action];
|
SEL action = [aMenuItem action];
|
||||||
|
|
||||||
|
@ -611,14 +666,14 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
action == @selector(viewSource:) ||
|
action == @selector(viewSource:) ||
|
||||||
action == @selector(goHome:) ||
|
action == @selector(goHome:) ||
|
||||||
action == @selector(savePage:)) {
|
action == @selector(savePage:)) {
|
||||||
if ([self isMainWindowABrowserWindow])
|
if (browserController)
|
||||||
return YES;
|
return YES;
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if someone has previously done a find before allowing findAgain to be enabled
|
// check if someone has previously done a find before allowing findAgain to be enabled
|
||||||
if (action == @selector(findAgain:)) {
|
if (action == @selector(findAgain:)) {
|
||||||
if ([self isMainWindowABrowserWindow])
|
if (browserController)
|
||||||
return (mFindDialog && [[mFindDialog getSearchText] length] > 0);
|
return (mFindDialog && [[mFindDialog getSearchText] length] > 0);
|
||||||
else
|
else
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -628,8 +683,8 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
// window open. Popup windows that have the personal toolbar removed should always gray
|
// window open. Popup windows that have the personal toolbar removed should always gray
|
||||||
// out this menu.
|
// out this menu.
|
||||||
if (action == @selector(toggleBookmarksToolbar:)) {
|
if (action == @selector(toggleBookmarksToolbar:)) {
|
||||||
if ([self isMainWindowABrowserWindow]) {
|
if (browserController) {
|
||||||
NSView* bookmarkToolbar = [[[mApplication mainWindow] windowController] bookmarksToolbar];
|
NSView* bookmarkToolbar = [browserController bookmarksToolbar];
|
||||||
if ( bookmarkToolbar ) {
|
if ( bookmarkToolbar ) {
|
||||||
float height = [bookmarkToolbar frame].size.height;
|
float height = [bookmarkToolbar frame].size.height;
|
||||||
BOOL toolbarShowing = (height > 0);
|
BOOL toolbarShowing = (height > 0);
|
||||||
|
@ -651,21 +706,21 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
action == @selector (nextTab:) ||
|
action == @selector (nextTab:) ||
|
||||||
action == @selector (previousTab:)))
|
action == @selector (previousTab:)))
|
||||||
{
|
{
|
||||||
if ([[[[mApplication mainWindow] windowController] getTabBrowser] numberOfTabViewItems] > 1)
|
if (browserController && [[browserController getTabBrowser] numberOfTabViewItems] > 1)
|
||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( action == @selector(doStop:) ) {
|
if ( action == @selector(doStop:) ) {
|
||||||
if ([self isMainWindowABrowserWindow])
|
if (browserController)
|
||||||
return [[[[mApplication mainWindow] windowController] getBrowserWrapper] isBusy];
|
return [[browserController getBrowserWrapper] isBusy];
|
||||||
else
|
else
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
if ( action == @selector(goBack:) || action == @selector(goForward:) ) {
|
if ( action == @selector(goBack:) || action == @selector(goForward:) ) {
|
||||||
if ([self isMainWindowABrowserWindow]) {
|
if (browserController) {
|
||||||
CHBrowserView* browserView = [[[[mApplication mainWindow] windowController] getBrowserWrapper] getBrowserView];
|
CHBrowserView* browserView = [[browserController getBrowserWrapper] getBrowserView];
|
||||||
if (action == @selector(goBack:))
|
if (action == @selector(goBack:))
|
||||||
return [browserView canGoBack];
|
return [browserView canGoBack];
|
||||||
if (action == @selector(goForward:))
|
if (action == @selector(goForward:))
|
||||||
|
@ -681,20 +736,17 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction) toggleBookmarksToolbar:(id)aSender
|
-(IBAction) toggleBookmarksToolbar:(id)aSender
|
||||||
{
|
{
|
||||||
// do nothing if there is no window. we shouldn't get here in that case anyway, but
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
// just to be safe. If there is a browser window, toggle it's personal toolbar.
|
if (!browserController) return;
|
||||||
if ( [self isMainWindowABrowserWindow] ) {
|
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
|
||||||
|
|
||||||
float height = [[[mainWindow windowController] bookmarksToolbar] frame].size.height;
|
float height = [[browserController bookmarksToolbar] frame].size.height;
|
||||||
BOOL showToolbar = (BOOL)(!(height > 0));
|
BOOL showToolbar = (BOOL)(!(height > 0));
|
||||||
|
|
||||||
[[[mainWindow windowController] bookmarksToolbar] showBookmarksToolbar: showToolbar];
|
[[browserController bookmarksToolbar] showBookmarksToolbar: showToolbar];
|
||||||
|
|
||||||
// save prefs here
|
// save prefs here
|
||||||
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
|
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
|
||||||
[defaults setInteger: ((showToolbar) ? 0 : 1) forKey: USER_DEFAULTS_HIDE_PERS_TOOLBAR_KEY];
|
[defaults setInteger: ((showToolbar) ? 0 : 1) forKey: USER_DEFAULTS_HIDE_PERS_TOOLBAR_KEY];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) infoLink:(id)aSender
|
-(IBAction) infoLink:(id)aSender
|
||||||
|
|
|
@ -77,7 +77,7 @@ SecurityDialogs::UnknownIssuer(nsITransportSecurityInfo *socketInfo,
|
||||||
// HACK: there is no way to get which window this is for from the API. The
|
// HACK: there is no way to get which window this is for from the API. The
|
||||||
// security team in mozilla just cheats and assumes the frontmost window so
|
// security team in mozilla just cheats and assumes the frontmost window so
|
||||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||||
*outAddType = (PRBool)[controller unknownCert:[NSApp mainWindow]];
|
*outAddType = (PRBool)[controller unknownCert:[[NSApp delegate] getFrontmostBrowserWindow]];
|
||||||
switch ( *outAddType ) {
|
switch ( *outAddType ) {
|
||||||
case nsIBadCertListener::ADD_TRUSTED_FOR_SESSION:
|
case nsIBadCertListener::ADD_TRUSTED_FOR_SESSION:
|
||||||
case nsIBadCertListener::ADD_TRUSTED_PERMANENTLY:
|
case nsIBadCertListener::ADD_TRUSTED_PERMANENTLY:
|
||||||
|
@ -105,7 +105,7 @@ SecurityDialogs::MismatchDomain(nsITransportSecurityInfo *socketInfo,
|
||||||
// HACK: there is no way to get which window this is for from the API. The
|
// HACK: there is no way to get which window this is for from the API. The
|
||||||
// security team in mozilla just cheats and assumes the frontmost window so
|
// security team in mozilla just cheats and assumes the frontmost window so
|
||||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||||
*_retval = (PRBool)[controller badCert:[NSApp mainWindow]];
|
*_retval = (PRBool)[controller badCert:[[NSApp delegate] getFrontmostBrowserWindow]];
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ SecurityDialogs::CertExpired(nsITransportSecurityInfo *socketInfo,
|
||||||
// HACK: there is no way to get which window this is for from the API. The
|
// HACK: there is no way to get which window this is for from the API. The
|
||||||
// security team in mozilla just cheats and assumes the frontmost window so
|
// security team in mozilla just cheats and assumes the frontmost window so
|
||||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||||
*_retval = (PRBool)[controller expiredCert:[NSApp mainWindow]];
|
*_retval = (PRBool)[controller expiredCert:[[NSApp delegate] getFrontmostBrowserWindow]];
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ SecurityDialogs::ConfirmPostToInsecureFromSecure(nsIInterfaceRequestor *ctx,
|
||||||
// HACK: there is no way to get which window this is for from the API. The
|
// HACK: there is no way to get which window this is for from the API. The
|
||||||
// security team in mozilla just cheats and assumes the frontmost window so
|
// security team in mozilla just cheats and assumes the frontmost window so
|
||||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||||
*_result = (PRBool)[controller postToInsecureFromSecure:[NSApp mainWindow]];
|
*_result = (PRBool)[controller postToInsecureFromSecure:[[NSApp delegate] getFrontmostBrowserWindow]];
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,9 @@ class BookmarksService;
|
||||||
- (CHPreferenceManager *)preferenceManager;
|
- (CHPreferenceManager *)preferenceManager;
|
||||||
- (BOOL)isMainWindowABrowserWindow;
|
- (BOOL)isMainWindowABrowserWindow;
|
||||||
|
|
||||||
|
// if the main window is a browser window, return its controller, otherwise nil
|
||||||
|
- (BrowserWindowController*)getMainWindowBrowserController;
|
||||||
|
|
||||||
- (IBAction)showAboutBox:(id)sender;
|
- (IBAction)showAboutBox:(id)sender;
|
||||||
|
|
||||||
+ (NSImage*)createImageForDragging:(NSImage*)aIcon title:(NSString*)aTitle;
|
+ (NSImage*)createImageForDragging:(NSImage*)aIcon title:(NSString*)aTitle;
|
||||||
|
|
|
@ -176,22 +176,30 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction)newTab:(id)aSender
|
-(IBAction)newTab:(id)aSender
|
||||||
{
|
{
|
||||||
[(BrowserWindowController*)[[mApplication mainWindow] windowController] newTab:YES];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController newTab:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction)closeTab:(id)aSender
|
-(IBAction)closeTab:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] closeTab];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController closeTab];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) previousTab:(id)aSender
|
-(IBAction) previousTab:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] previousTab];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController previousTab];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) nextTab:(id)aSender;
|
-(IBAction) nextTab:(id)aSender;
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] nextTab];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController nextTab];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) openFile:(id)aSender
|
-(IBAction) openFile:(id)aSender
|
||||||
|
@ -213,10 +221,12 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
// ----------------------
|
// ----------------------
|
||||||
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:url];
|
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:url];
|
||||||
// ----------------------
|
// ----------------------
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
|
||||||
if (mainWindow) {
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
[[mainWindow windowController] loadURL:[url absoluteString] referrer:nil];
|
if (browserController)
|
||||||
[[[[mainWindow windowController] getBrowserWrapper] getBrowserView] setActive: YES];
|
{
|
||||||
|
[browserController loadURL:[url absoluteString] referrer:nil];
|
||||||
|
[[[browserController getBrowserWrapper] getBrowserView] setActive: YES];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
[self openBrowserWindowWithURL:[url absoluteString] andReferrer:nil];
|
[self openBrowserWindowWithURL:[url absoluteString] andReferrer:nil];
|
||||||
|
@ -225,28 +235,37 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction) openLocation:(id)aSender
|
-(IBAction) openLocation:(id)aSender
|
||||||
{
|
{
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
if (!mainWindow) {
|
if (!browserWindow) {
|
||||||
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
||||||
mainWindow = [mApplication mainWindow];
|
browserWindow = [mApplication mainWindow];
|
||||||
|
}
|
||||||
|
else if (![browserWindow isMainWindow]) {
|
||||||
|
[browserWindow makeKeyAndOrderFront:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[mainWindow windowController] performAppropriateLocationAction];
|
[[browserWindow windowController] performAppropriateLocationAction];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) savePage:(id)aSender
|
-(IBAction) savePage:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] saveDocument: mFilterView filterList: mFilterList];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController saveDocument: mFilterView filterList: mFilterList];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) printPage:(id)aSender
|
-(IBAction) printPage:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] printDocument];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController printDocument];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) printPreview:(id)aSender
|
-(IBAction) printPreview:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] printPreview];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController printPreview];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) toggleOfflineMode:(id)aSender
|
-(IBAction) toggleOfflineMode:(id)aSender
|
||||||
|
@ -304,27 +323,44 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction) goBack:(id)aSender
|
-(IBAction) goBack:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] back: aSender];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController back: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) goForward:(id)aSender
|
-(IBAction) goForward:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] forward: aSender];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController forward: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) doReload:(id)aSender
|
-(IBAction) doReload:(id)aSender
|
||||||
{
|
{
|
||||||
[(BrowserWindowController*)([[mApplication mainWindow] windowController]) reload: aSender];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController reload: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) doStop:(id)aSender
|
-(IBAction) doStop:(id)aSender
|
||||||
{
|
{
|
||||||
[(BrowserWindowController*)([[mApplication mainWindow] windowController]) stop: aSender];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController stop: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) goHome:(id)aSender
|
-(IBAction) goHome:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] home: aSender];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
|
if (browserWindow) {
|
||||||
|
if (![browserWindow isMainWindow])
|
||||||
|
[browserWindow makeKeyAndOrderFront:self];
|
||||||
|
|
||||||
|
[[browserWindow windowController] home: aSender];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[self newWindow:self];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)adjustBookmarksMenuItemsEnabling:(BOOL)inBrowserWindowFrontmost;
|
- (void)adjustBookmarksMenuItemsEnabling:(BOOL)inBrowserWindowFrontmost;
|
||||||
|
@ -403,7 +439,6 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
}
|
}
|
||||||
|
|
||||||
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
|
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -449,24 +484,28 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
return;
|
return;
|
||||||
NSURL* url = [urlArray objectAtIndex: 0];
|
NSURL* url = [urlArray objectAtIndex: 0];
|
||||||
|
|
||||||
NSWindow* window = [mApplication mainWindow];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
if (!window) {
|
if (!browserWindow) {
|
||||||
[self newWindow: self];
|
[self newWindow: self];
|
||||||
window = [mApplication mainWindow];
|
browserWindow = [mApplication mainWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[window windowController] importBookmarks: [url absoluteString]];
|
[[browserWindow windowController] importBookmarks: [url absoluteString]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) addBookmark:(id)aSender
|
-(IBAction) addBookmark:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: NO URL:nil title:nil];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController addBookmarkExtended: YES isFolder: NO URL:nil title:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) addFolder:(id)aSender
|
-(IBAction) addFolder:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: YES URL:nil title:nil];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController addBookmarkExtended: YES isFolder: YES URL:nil title:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) addSeparator:(id)aSender
|
-(IBAction) addSeparator:(id)aSender
|
||||||
|
@ -476,24 +515,24 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction) openMenuBookmark:(id)aSender
|
-(IBAction) openMenuBookmark:(id)aSender
|
||||||
{
|
{
|
||||||
NSWindow* mainWind = [mApplication mainWindow];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
if (!mainWind) {
|
if (!browserWindow) {
|
||||||
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
||||||
mainWind = [mApplication mainWindow];
|
browserWindow = [mApplication mainWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
BookmarksService::OpenMenuBookmark([mainWind windowController], aSender);
|
BookmarksService::OpenMenuBookmark([browserWindow windowController], aSender);
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction)manageBookmarks: (id)aSender
|
-(IBAction)manageBookmarks: (id)aSender
|
||||||
{
|
{
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||||
if (!mainWindow) {
|
if (!browserWindow) {
|
||||||
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
|
[self newWindow:self];
|
||||||
mainWindow = [mApplication mainWindow];
|
browserWindow = [mApplication mainWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[mainWindow windowController] manageBookmarks: aSender];
|
[[browserWindow windowController] manageBookmarks: aSender];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CHPreferenceManager *)preferenceManager
|
- (CHPreferenceManager *)preferenceManager
|
||||||
|
@ -544,28 +583,40 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
- (IBAction)biggerTextSize:(id)aSender
|
- (IBAction)biggerTextSize:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] biggerTextSize];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController biggerTextSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)smallerTextSize:(id)aSender
|
- (IBAction)smallerTextSize:(id)aSender
|
||||||
{
|
{
|
||||||
[[[mApplication mainWindow] windowController] smallerTextSize];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController)
|
||||||
|
[browserController smallerTextSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) viewSource:(id)aSender
|
-(IBAction) viewSource:(id)aSender
|
||||||
{
|
{
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
if (mainWindow && [[mainWindow windowController] respondsToSelector:@selector(viewSource:)] )
|
if (browserController)
|
||||||
[[mainWindow windowController] viewSource: self];
|
[browserController viewSource: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-(BOOL)isMainWindowABrowserWindow
|
-(BOOL)isMainWindowABrowserWindow
|
||||||
{
|
{
|
||||||
// see also getFrontmostBrowserWindow
|
// see also getFrontmostBrowserWindow
|
||||||
return [[[mApplication mainWindow] windowController] isMemberOfClass:[BrowserWindowController class]];
|
return [[[mApplication mainWindow] windowController] isMemberOfClass:[BrowserWindowController class]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BrowserWindowController*)getMainWindowBrowserController
|
||||||
|
{
|
||||||
|
NSWindowController* mainWindowController = [[mApplication mainWindow] windowController];
|
||||||
|
if (mainWindowController && [mainWindowController isMemberOfClass:[BrowserWindowController class]])
|
||||||
|
return (BrowserWindowController*)mainWindowController;
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)adjustCloseWindowMenuItemKeyEquivalent:(BOOL)inHaveTabs
|
- (void)adjustCloseWindowMenuItemKeyEquivalent:(BOOL)inHaveTabs
|
||||||
{
|
{
|
||||||
// capitalization of the key equivalent affects whether the shift modifer is used.
|
// capitalization of the key equivalent affects whether the shift modifer is used.
|
||||||
|
@ -588,14 +639,18 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
// Close Tab/Close Window accordingly
|
// Close Tab/Close Window accordingly
|
||||||
- (void)fixCloseMenuItemKeyEquivalents
|
- (void)fixCloseMenuItemKeyEquivalents
|
||||||
{
|
{
|
||||||
BOOL windowWithMultipleTabs = ([[[[mApplication mainWindow] windowController] getTabBrowser] numberOfTabViewItems] > 1);
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
if (browserController) {
|
||||||
[self adjustCloseWindowMenuItemKeyEquivalent:windowWithMultipleTabs];
|
BOOL windowWithMultipleTabs = ([[browserController getTabBrowser] numberOfTabViewItems] > 1);
|
||||||
[self adjustCloseTabMenuItemKeyEquivalent:windowWithMultipleTabs];
|
[self adjustCloseWindowMenuItemKeyEquivalent:windowWithMultipleTabs];
|
||||||
|
[self adjustCloseTabMenuItemKeyEquivalent:windowWithMultipleTabs];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(BOOL)validateMenuItem: (NSMenuItem*)aMenuItem
|
-(BOOL)validateMenuItem: (NSMenuItem*)aMenuItem
|
||||||
{
|
{
|
||||||
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
|
|
||||||
// disable items that aren't relevant if there's no main browser window open
|
// disable items that aren't relevant if there's no main browser window open
|
||||||
SEL action = [aMenuItem action];
|
SEL action = [aMenuItem action];
|
||||||
|
|
||||||
|
@ -611,14 +666,14 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
action == @selector(viewSource:) ||
|
action == @selector(viewSource:) ||
|
||||||
action == @selector(goHome:) ||
|
action == @selector(goHome:) ||
|
||||||
action == @selector(savePage:)) {
|
action == @selector(savePage:)) {
|
||||||
if ([self isMainWindowABrowserWindow])
|
if (browserController)
|
||||||
return YES;
|
return YES;
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if someone has previously done a find before allowing findAgain to be enabled
|
// check if someone has previously done a find before allowing findAgain to be enabled
|
||||||
if (action == @selector(findAgain:)) {
|
if (action == @selector(findAgain:)) {
|
||||||
if ([self isMainWindowABrowserWindow])
|
if (browserController)
|
||||||
return (mFindDialog && [[mFindDialog getSearchText] length] > 0);
|
return (mFindDialog && [[mFindDialog getSearchText] length] > 0);
|
||||||
else
|
else
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -628,8 +683,8 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
// window open. Popup windows that have the personal toolbar removed should always gray
|
// window open. Popup windows that have the personal toolbar removed should always gray
|
||||||
// out this menu.
|
// out this menu.
|
||||||
if (action == @selector(toggleBookmarksToolbar:)) {
|
if (action == @selector(toggleBookmarksToolbar:)) {
|
||||||
if ([self isMainWindowABrowserWindow]) {
|
if (browserController) {
|
||||||
NSView* bookmarkToolbar = [[[mApplication mainWindow] windowController] bookmarksToolbar];
|
NSView* bookmarkToolbar = [browserController bookmarksToolbar];
|
||||||
if ( bookmarkToolbar ) {
|
if ( bookmarkToolbar ) {
|
||||||
float height = [bookmarkToolbar frame].size.height;
|
float height = [bookmarkToolbar frame].size.height;
|
||||||
BOOL toolbarShowing = (height > 0);
|
BOOL toolbarShowing = (height > 0);
|
||||||
|
@ -651,21 +706,21 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
action == @selector (nextTab:) ||
|
action == @selector (nextTab:) ||
|
||||||
action == @selector (previousTab:)))
|
action == @selector (previousTab:)))
|
||||||
{
|
{
|
||||||
if ([[[[mApplication mainWindow] windowController] getTabBrowser] numberOfTabViewItems] > 1)
|
if (browserController && [[browserController getTabBrowser] numberOfTabViewItems] > 1)
|
||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( action == @selector(doStop:) ) {
|
if ( action == @selector(doStop:) ) {
|
||||||
if ([self isMainWindowABrowserWindow])
|
if (browserController)
|
||||||
return [[[[mApplication mainWindow] windowController] getBrowserWrapper] isBusy];
|
return [[browserController getBrowserWrapper] isBusy];
|
||||||
else
|
else
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
if ( action == @selector(goBack:) || action == @selector(goForward:) ) {
|
if ( action == @selector(goBack:) || action == @selector(goForward:) ) {
|
||||||
if ([self isMainWindowABrowserWindow]) {
|
if (browserController) {
|
||||||
CHBrowserView* browserView = [[[[mApplication mainWindow] windowController] getBrowserWrapper] getBrowserView];
|
CHBrowserView* browserView = [[browserController getBrowserWrapper] getBrowserView];
|
||||||
if (action == @selector(goBack:))
|
if (action == @selector(goBack:))
|
||||||
return [browserView canGoBack];
|
return [browserView canGoBack];
|
||||||
if (action == @selector(goForward:))
|
if (action == @selector(goForward:))
|
||||||
|
@ -681,20 +736,17 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||||
|
|
||||||
-(IBAction) toggleBookmarksToolbar:(id)aSender
|
-(IBAction) toggleBookmarksToolbar:(id)aSender
|
||||||
{
|
{
|
||||||
// do nothing if there is no window. we shouldn't get here in that case anyway, but
|
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||||
// just to be safe. If there is a browser window, toggle it's personal toolbar.
|
if (!browserController) return;
|
||||||
if ( [self isMainWindowABrowserWindow] ) {
|
|
||||||
NSWindow* mainWindow = [mApplication mainWindow];
|
|
||||||
|
|
||||||
float height = [[[mainWindow windowController] bookmarksToolbar] frame].size.height;
|
float height = [[browserController bookmarksToolbar] frame].size.height;
|
||||||
BOOL showToolbar = (BOOL)(!(height > 0));
|
BOOL showToolbar = (BOOL)(!(height > 0));
|
||||||
|
|
||||||
[[[mainWindow windowController] bookmarksToolbar] showBookmarksToolbar: showToolbar];
|
[[browserController bookmarksToolbar] showBookmarksToolbar: showToolbar];
|
||||||
|
|
||||||
// save prefs here
|
// save prefs here
|
||||||
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
|
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
|
||||||
[defaults setInteger: ((showToolbar) ? 0 : 1) forKey: USER_DEFAULTS_HIDE_PERS_TOOLBAR_KEY];
|
[defaults setInteger: ((showToolbar) ? 0 : 1) forKey: USER_DEFAULTS_HIDE_PERS_TOOLBAR_KEY];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) infoLink:(id)aSender
|
-(IBAction) infoLink:(id)aSender
|
||||||
|
|
|
@ -55,8 +55,7 @@ static const NSString *kEllipsis = @"...";
|
||||||
- (nsIWebNavigation*) currentWebNavigation
|
- (nsIWebNavigation*) currentWebNavigation
|
||||||
{
|
{
|
||||||
// get controller for current window
|
// get controller for current window
|
||||||
BrowserWindowController *controller;
|
BrowserWindowController *controller = [[NSApp delegate] getMainWindowBrowserController];
|
||||||
controller = (BrowserWindowController*)[[NSApp mainWindow] windowController];
|
|
||||||
if (!controller) return nsnull;
|
if (!controller) return nsnull;
|
||||||
|
|
||||||
// get web navigation for current browser
|
// get web navigation for current browser
|
||||||
|
|
|
@ -77,7 +77,7 @@ SecurityDialogs::UnknownIssuer(nsITransportSecurityInfo *socketInfo,
|
||||||
// HACK: there is no way to get which window this is for from the API. The
|
// HACK: there is no way to get which window this is for from the API. The
|
||||||
// security team in mozilla just cheats and assumes the frontmost window so
|
// security team in mozilla just cheats and assumes the frontmost window so
|
||||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||||
*outAddType = (PRBool)[controller unknownCert:[NSApp mainWindow]];
|
*outAddType = (PRBool)[controller unknownCert:[[NSApp delegate] getFrontmostBrowserWindow]];
|
||||||
switch ( *outAddType ) {
|
switch ( *outAddType ) {
|
||||||
case nsIBadCertListener::ADD_TRUSTED_FOR_SESSION:
|
case nsIBadCertListener::ADD_TRUSTED_FOR_SESSION:
|
||||||
case nsIBadCertListener::ADD_TRUSTED_PERMANENTLY:
|
case nsIBadCertListener::ADD_TRUSTED_PERMANENTLY:
|
||||||
|
@ -105,7 +105,7 @@ SecurityDialogs::MismatchDomain(nsITransportSecurityInfo *socketInfo,
|
||||||
// HACK: there is no way to get which window this is for from the API. The
|
// HACK: there is no way to get which window this is for from the API. The
|
||||||
// security team in mozilla just cheats and assumes the frontmost window so
|
// security team in mozilla just cheats and assumes the frontmost window so
|
||||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||||
*_retval = (PRBool)[controller badCert:[NSApp mainWindow]];
|
*_retval = (PRBool)[controller badCert:[[NSApp delegate] getFrontmostBrowserWindow]];
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ SecurityDialogs::CertExpired(nsITransportSecurityInfo *socketInfo,
|
||||||
// HACK: there is no way to get which window this is for from the API. The
|
// HACK: there is no way to get which window this is for from the API. The
|
||||||
// security team in mozilla just cheats and assumes the frontmost window so
|
// security team in mozilla just cheats and assumes the frontmost window so
|
||||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||||
*_retval = (PRBool)[controller expiredCert:[NSApp mainWindow]];
|
*_retval = (PRBool)[controller expiredCert:[[NSApp delegate] getFrontmostBrowserWindow]];
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ SecurityDialogs::ConfirmPostToInsecureFromSecure(nsIInterfaceRequestor *ctx,
|
||||||
// HACK: there is no way to get which window this is for from the API. The
|
// HACK: there is no way to get which window this is for from the API. The
|
||||||
// security team in mozilla just cheats and assumes the frontmost window so
|
// security team in mozilla just cheats and assumes the frontmost window so
|
||||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||||
*_result = (PRBool)[controller postToInsecureFromSecure:[NSApp mainWindow]];
|
*_result = (PRBool)[controller postToInsecureFromSecure:[[NSApp delegate] getFrontmostBrowserWindow]];
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче