version 1.33, 2002/03/20 07:34:07
|
version 1.41, 2002/04/14 08:43:03
|
Line 44
|
Line 44
|
#include "nsCocoaBrowserService.h" |
#include "nsCocoaBrowserService.h" |
#import "AboutBox.h" |
#import "AboutBox.h" |
|
|
|
|
static const char* ioServiceContractID = "@mozilla.org/network/io-service;1"; |
static const char* ioServiceContractID = "@mozilla.org/network/io-service;1"; |
|
|
@implementation MainController |
@implementation MainController |
Line 51 static const char* ioServiceContractID =
|
Line 52 static const char* ioServiceContractID =
|
-(id)init |
-(id)init |
{ |
{ |
if ( (self = [super init]) ) { |
if ( (self = [super init]) ) { |
mSplashScreen = [[SplashScreenWindow alloc] splash]; | mSplashScreen = [[SplashScreenWindow alloc] splashImage:nil withFade:YES withStatusRect:NSMakeRect(0,0,0,0)]; |
} |
} |
|
mFindDialog = nil; |
|
mMenuBookmarks = nil; |
return self; |
return self; |
} |
} |
|
|
-(void)dealloc |
-(void)dealloc |
{ |
{ |
[super dealloc]; |
[super dealloc]; |
|
[mFindDialog release]; |
printf("Main controller died.\n"); |
printf("Main controller died.\n"); |
} |
} |
|
|
-(void)awakeFromNib |
-(void)awakeFromNib |
{ | { |
[self newWindow: self]; |
[self newWindow: self]; |
|
|
[mSplashScreen close]; |
|
|
|
|
[mSplashScreen close]; |
|
|
[mBookmarksMenu setAutoenablesItems: NO]; |
[mBookmarksMenu setAutoenablesItems: NO]; |
|
|
mMenuBookmarks = new BookmarksService(nil); |
mMenuBookmarks = new BookmarksService(nil); |
mMenuBookmarks->AddObserver(); |
mMenuBookmarks->AddObserver(); |
mMenuBookmarks->ConstructBookmarksMenu(mBookmarksMenu, nsnull); |
mMenuBookmarks->ConstructBookmarksMenu(mBookmarksMenu, nsnull); |
Line 96 static const char* ioServiceContractID =
|
Line 99 static const char* ioServiceContractID =
|
// If we have a key window, have it autosave its dimensions before |
// If we have a key window, have it autosave its dimensions before |
// we open a new window. That ensures the size ends up matching. |
// we open a new window. That ensures the size ends up matching. |
NSWindow* keyWindow = [mApplication keyWindow]; |
NSWindow* keyWindow = [mApplication keyWindow]; |
if (keyWindow) | if ( keyWindow && [keyWindow respondsToSelector:@selector(autosaveWindowFrame)] ) |
[[keyWindow windowController] autosaveWindowFrame]; |
[[keyWindow windowController] autosaveWindowFrame]; |
|
|
// Now open the new window. |
// Now open the new window. |
Line 152 static const char* ioServiceContractID =
|
Line 155 static const char* ioServiceContractID =
|
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:url]; |
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:url]; |
// ---------------------- |
// ---------------------- |
NSWindow* keyWindow = [mApplication keyWindow]; |
NSWindow* keyWindow = [mApplication keyWindow]; |
if (keyWindow) | if (keyWindow) { |
return [[keyWindow windowController] loadURL: url]; | [[keyWindow windowController] loadURL: url]; |
| [[[[keyWindow windowController] getMyBrowserView] getBrowserView] setActive: YES]; |
| } |
else |
else |
[self openBrowserWindowWithURL: url]; | [self openBrowserWindowWithURL: url]; |
} |
} |
} |
} |
|
|
Line 214 static const char* ioServiceContractID =
|
Line 219 static const char* ioServiceContractID =
|
} |
} |
|
|
// Edit menu actions. |
// Edit menu actions. |
|
|
|
|
|
// |
|
// -findInPage |
|
// |
|
// Called in response to "Find" in edit menu. Opens the find dialog. We only keep |
|
// one around for the whole app to use, showing/hiding as we see fit. |
|
// |
-(IBAction) findInPage:(id)aSender |
-(IBAction) findInPage:(id)aSender |
{ |
{ |
NSWindow* keyWindow = [mApplication keyWindow]; | if ( !mFindDialog ) |
if (keyWindow) | mFindDialog = [[FindDlgController alloc] initWithWindowNibName: @"FindDialog"]; |
[[keyWindow windowController] findInPage]; | [mFindDialog showWindow:self]; |
} |
} |
|
|
|
|
|
// |
|
// -findAgain |
|
// |
|
// Called in response to "Find Again" in edit menu. Tells the find controller |
|
// to find the next occurrance of what's already been found. |
|
// |
-(IBAction) findAgain:(id)aSender |
-(IBAction) findAgain:(id)aSender |
{ |
{ |
NSWindow* keyWindow = [mApplication keyWindow]; | if ( mFindDialog ) |
if (keyWindow) | [mFindDialog findAgain:aSender]; |
[[keyWindow windowController] findAgain]; | else |
| NSBeep(); |
} |
} |
|
|
-(IBAction) goBack:(id)aSender |
-(IBAction) goBack:(id)aSender |
Line 261 static const char* ioServiceContractID =
|
Line 282 static const char* ioServiceContractID =
|
-(BrowserWindowController*)openBrowserWindowWithURL: (NSURL*)aURL |
-(BrowserWindowController*)openBrowserWindowWithURL: (NSURL*)aURL |
{ |
{ |
BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"]; |
BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"]; |
[browser loadURL: aURL]; | [browser loadURL: aURL]; |
[browser showWindow: self]; |
[browser showWindow: self]; |
return browser; | return browser; |
} |
} |
|
|
-(void)applicationWillTerminate: (NSNotification*)aNotification |
-(void)applicationWillTerminate: (NSNotification*)aNotification |
{ |
{ |
printf("Termination notification.\n"); |
printf("Termination notification.\n"); |
|
|
|
// Autosave one of the windows. |
|
NSWindow* keyWindow = [mApplication keyWindow]; |
|
if (keyWindow) |
|
[[keyWindow windowController] autosaveWindowFrame]; |
|
|
mMenuBookmarks->RemoveObserver(); |
mMenuBookmarks->RemoveObserver(); |
delete mMenuBookmarks; |
delete mMenuBookmarks; |
mMenuBookmarks = nsnull; |
mMenuBookmarks = nsnull; |
Line 280 static const char* ioServiceContractID =
|
Line 307 static const char* ioServiceContractID =
|
{ |
{ |
NSWindow* keyWindow = [mApplication keyWindow]; |
NSWindow* keyWindow = [mApplication keyWindow]; |
if (keyWindow) |
if (keyWindow) |
[[keyWindow windowController] addBookmark]; | [[keyWindow windowController] addBookmarkExtended: YES]; |
} |
} |
|
|
-(IBAction) openMenuBookmark:(id)aSender |
-(IBAction) openMenuBookmark:(id)aSender |