version 1.18, 2002/02/07 05:11:38
|
version 1.41, 2002/03/03 09:34:52
|
Line 5
|
Line 5
|
#import "BrowserWindowController.h" |
#import "BrowserWindowController.h" |
#import "MyBrowserView.h" |
#import "MyBrowserView.h" |
|
|
|
#include "nsIWebNavigation.h" |
|
|
static NSString *BrowserToolbarIdentifier = @"Browser Window Toolbar"; |
static NSString *BrowserToolbarIdentifier = @"Browser Window Toolbar"; |
static NSString *BackToolbarItemIdentifier = @"Back Toolbar Item"; |
static NSString *BackToolbarItemIdentifier = @"Back Toolbar Item"; |
static NSString *ForwardToolbarItemIdentifier = @"Forward Toolbar Item"; |
static NSString *ForwardToolbarItemIdentifier = @"Forward Toolbar Item"; |
Line 21 static NSString *PrintToolbarItemIdentif
|
Line 23 static NSString *PrintToolbarItemIdentif
|
|
|
@implementation BrowserWindowController |
@implementation BrowserWindowController |
|
|
- (id)init | -(void)enterModalSession |
{ |
{ |
mInitialized = NO; | mModalSession = [NSApp beginModalSessionForWindow: [self window]]; |
return [super init]; | [NSApp runModalSession: mModalSession]; |
| [NSApp endModalSession: mModalSession]; |
| mModalSession = nil; |
| } |
| |
| -(void)mouseMoved:(NSEvent*)aEvent |
| { |
| if (mMoveReentrant) |
| return; |
| |
| mMoveReentrant = YES; |
| NSView* view = [[[self window] contentView] hitTest: [aEvent locationInWindow]]; |
| [view mouseMoved: aEvent]; |
| [super mouseMoved: aEvent]; |
| mMoveReentrant = NO; |
| } |
| |
| - (id)initWithWindowNibName:(NSString *)windowNibName |
| { |
| if ( (self = [super initWithWindowNibName:(NSString *)windowNibName]) ) { |
| mInitialized = NO; |
| mMoveReentrant = NO; |
| } |
| return self; |
} |
} |
|
|
- (void)windowWillClose:(NSNotification *)notification |
- (void)windowWillClose:(NSNotification *)notification |
{ |
{ |
|
printf("Window will close notification.\n"); |
[self autorelease]; |
[self autorelease]; |
|
[mSidebarBookmarksDataSource windowClosing]; |
} |
} |
|
|
- (void)dealloc |
- (void)dealloc |
{ |
{ |
|
printf("Browser controller died.\n"); |
|
|
[mBrowserView windowClosed]; |
[mBrowserView windowClosed]; |
|
[mSidebarBrowserView windowClosed]; |
|
|
|
[mProgress release]; |
|
|
[super dealloc]; |
[super dealloc]; |
} |
} |
|
|
- (void)windowDidLoad |
- (void)windowDidLoad |
{ |
{ |
|
[super windowDidLoad]; |
|
|
|
if (mModalSession) |
|
[NSApp stopModal: mModalSession]; |
|
|
mInitialized = YES; |
mInitialized = YES; |
|
|
|
// Retain with a single extra refcount. This allows the MyBrowserViews |
|
// to remove the progress meter from its superview without having to |
|
// worry about retaining and releasing it. |
|
[mProgress retain]; |
|
|
|
[[self window] setAcceptsMouseMovedEvents: YES]; |
|
|
[self setupToolbar]; |
[self setupToolbar]; |
|
|
|
// 03/03/2002 mlj Changing strategy a bit here. The addTab: method was |
|
// duplicating a lot of the code found here. I have moved it to that method. |
|
// We now remove the IB tab, then add one of our own. |
|
|
|
[mTabBrowser removeTabViewItem:[mTabBrowser tabViewItemAtIndex:0]]; |
|
[self newTab]; |
|
|
if (mURL) { |
if (mURL) { |
[self loadURL: mURL]; |
[self loadURL: mURL]; |
Line 49 static NSString *PrintToolbarItemIdentif
|
Line 102 static NSString *PrintToolbarItemIdentif
|
} |
} |
|
|
[mSidebarDrawer setDelegate: self]; |
[mSidebarDrawer setDelegate: self]; |
|
|
|
// [mBrowserView makePrimaryBrowserView: tab urlbar: mURLBar status: mStatus |
|
// progress: mProgress windowController: self]; |
|
} |
|
|
|
- (void)drawerWillOpen: (NSNotification*)aNotification |
|
{ |
|
[mSidebarBookmarksDataSource ensureBookmarks]; |
} |
} |
|
|
- (void)drawerDidOpen:(NSNotification *)aNotification |
- (void)drawerDidOpen:(NSNotification *)aNotification |
{ |
{ |
|
// XXXdwh This is temporary. |
[[mSidebarBrowserView getBrowserView] loadURI: [NSURL URLWithString: @"http://tinderbox.mozilla.org/SeaMonkey/panel.html"] flags:NSLoadFlagsNone]; |
[[mSidebarBrowserView getBrowserView] loadURI: [NSURL URLWithString: @"http://tinderbox.mozilla.org/SeaMonkey/panel.html"] flags:NSLoadFlagsNone]; |
} |
} |
|
|
|
- (void)drawerDidClose:(NSNotification *)aNotification |
|
{ |
|
// Unload the Gecko web page in "My Panels" to save memory. |
|
[[mSidebarBrowserView getBrowserView] loadURI: [NSURL URLWithString: @"about:blank"] flags:NSLoadFlagsNone]; |
|
} |
|
|
- (void)setupToolbar |
- (void)setupToolbar |
{ |
{ |
NSToolbar *toolbar = [[[NSToolbar alloc] initWithIdentifier:BrowserToolbarIdentifier] autorelease]; |
NSToolbar *toolbar = [[[NSToolbar alloc] initWithIdentifier:BrowserToolbarIdentifier] autorelease]; |
Line 231 static NSString *PrintToolbarItemIdentif
|
Line 299 static NSString *PrintToolbarItemIdentif
|
[mLocationSheetWindow orderOut:self]; |
[mLocationSheetWindow orderOut:self]; |
[NSApp endSheet:mLocationSheetWindow returnCode:1]; |
[NSApp endSheet:mLocationSheetWindow returnCode:1]; |
[self loadURL:[NSURL URLWithString:[mLocationSheetURLField stringValue]]]; |
[self loadURL:[NSURL URLWithString:[mLocationSheetURLField stringValue]]]; |
|
|
|
// Focus and activate our content area. |
|
[[mBrowserView getBrowserView] setActive: YES]; |
} |
} |
|
|
- (IBAction)goToLocationFromToolbarURLField:(id)sender |
- (IBAction)goToLocationFromToolbarURLField:(id)sender |
{ |
{ |
[self loadURL:[NSURL URLWithString:[sender stringValue]]]; |
[self loadURL:[NSURL URLWithString:[sender stringValue]]]; |
|
|
|
// Focus and activate our content area. |
|
[[mBrowserView getBrowserView] setActive: YES]; |
} |
} |
|
|
- (void)saveDocument: (NSView*)aFilterView filterList: (NSPopUpButton*)aFilterList |
- (void)saveDocument: (NSView*)aFilterView filterList: (NSPopUpButton*)aFilterList |
Line 263 static NSString *PrintToolbarItemIdentif
|
Line 337 static NSString *PrintToolbarItemIdentif
|
[[mBrowserView getBrowserView] findAgain]; |
[[mBrowserView getBrowserView] findAgain]; |
} |
} |
|
|
|
- (void)addBookmark |
|
{ |
|
// XXXdwh Hack. Just go to the sidebar for now until we get our |
|
// menu data source going. |
|
[mSidebarBookmarksDataSource ensureBookmarks]; |
|
[mSidebarBookmarksDataSource addBookmark: self]; |
|
} |
|
|
- (IBAction)back:(id)aSender |
- (IBAction)back:(id)aSender |
{ |
{ |
[[mBrowserView getBrowserView] goBack]; |
[[mBrowserView getBrowserView] goBack]; |
Line 280 static NSString *PrintToolbarItemIdentif
|
Line 362 static NSString *PrintToolbarItemIdentif
|
|
|
- (IBAction)stop:(id)aSender |
- (IBAction)stop:(id)aSender |
{ |
{ |
[[mBrowserView getBrowserView] stop: 0]; | [[mBrowserView getBrowserView] stop: nsIWebNavigation::STOP_ALL]; |
} |
} |
|
|
- (IBAction)home:(id)aSender |
- (IBAction)home:(id)aSender |
Line 290 static NSString *PrintToolbarItemIdentif
|
Line 372 static NSString *PrintToolbarItemIdentif
|
|
|
- (IBAction)toggleSidebar:(id)aSender |
- (IBAction)toggleSidebar:(id)aSender |
{ |
{ |
if ( ([mSidebarDrawer state] == NSDrawerClosedState) || ([mSidebarDrawer state] == NSDrawerClosingState) ) { | NSResponder* resp = [[self window] firstResponder]; |
| [[self window] makeFirstResponder: nil]; |
| |
| if ( ([mSidebarDrawer state] == NSDrawerClosedState) || ([mSidebarDrawer state] == NSDrawerClosingState) ) { |
| // XXXHack to bypass sidebar crashes. |
[mSidebarDrawer open]; |
[mSidebarDrawer open]; |
} else { |
} else { |
[mSidebarDrawer close]; |
[mSidebarDrawer close]; |
} |
} |
|
|
|
[[self window] makeFirstResponder: resp]; |
} |
} |
|
|
-(void)loadURL:(NSURL*)aURL |
-(void)loadURL:(NSURL*)aURL |
{ |
{ |
if (mInitialized) | if (mInitialized) { |
[[mBrowserView getBrowserView] loadURI:aURL flags:NSLoadFlagsNone]; |
[[mBrowserView getBrowserView] loadURI:aURL flags:NSLoadFlagsNone]; |
|
} |
else { |
else { |
mURL = aURL; |
mURL = aURL; |
[mURL retain]; |
[mURL retain]; |
Line 325 static NSString *PrintToolbarItemIdentif
|
Line 414 static NSString *PrintToolbarItemIdentif
|
[[self window] update]; |
[[self window] update]; |
[[self window] display]; |
[[self window] display]; |
} |
} |
|
|
|
-(void)newTab |
|
{ |
|
NSTabViewItem* newTab = [[[NSTabViewItem alloc] initWithIdentifier: nil] autorelease]; |
|
MyBrowserView* newView = [[[MyBrowserView alloc] initWithFrame: [[newTab view] frame]] autorelease]; |
|
// MyBrowserView* newView = [[[MyBrowserView alloc] initWithFrame: [mBrowserView frame]] autorelease]; |
|
|
|
[newTab setLabel: @"Untitled"]; |
|
[newTab setView: newView]; |
|
|
|
[mTabBrowser addTabViewItem: newTab]; |
|
|
|
[[newView getBrowserView] loadURI:[NSURL URLWithString:@"about:blank"] flags:NSLoadFlagsNone]; |
|
|
|
[mTabBrowser selectLastTabViewItem: self]; |
|
|
|
if ( [[[self window] toolbar] isVisible] ) { |
|
if ( ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconAndLabel) || |
|
([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconOnly) ) { |
|
[self focusURLBar]; |
|
} |
|
} |
|
} |
|
|
|
- (void)tabView:(NSTabView *)aTabView didSelectTabViewItem:(NSTabViewItem *)aTabViewItem |
|
{ |
|
// Disconnect the old view, if one has been designated. |
|
// If the window has just been opened, none has been. |
|
if ( mBrowserView ) { |
|
[mBrowserView disconnectView]; |
|
} |
|
// Connect up the new view |
|
mBrowserView = [aTabViewItem view]; |
|
|
|
// Make the new view the primary content area. |
|
[mBrowserView makePrimaryBrowserView: aTabViewItem urlbar: mURLBar status: mStatus |
|
progress: mProgress windowController: self]; |
|
} |
|
|
|
-(MyBrowserView*)getMyBrowserView |
|
{ |
|
return mBrowserView; |
|
} |
@end |
@end |
|
|