Annotation of chimera/BrowserWindowController.mm, revision 1.47

1.44      hyatt       1: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
                      2: /* ***** BEGIN LICENSE BLOCK *****
                      3:  * Version: NPL 1.1/GPL 2.0/LGPL 2.1
                      4:  *
                      5:  * The contents of this file are subject to the Netscape Public License
                      6:  * Version 1.1 (the "License"); you may not use this file except in
                      7:  * compliance with the License. You may obtain a copy of the License at
                      8:  * http://www.mozilla.org/NPL/
                      9:  *
                     10:  * Software distributed under the License is distributed on an "AS IS" basis,
                     11:  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
                     12:  * for the specific language governing rights and limitations under the
                     13:  * License.
                     14:  *
                     15:  * The Original Code is mozilla.org code.
                     16:  *
                     17:  * The Initial Developer of the Original Code is 
                     18:  * Netscape Communications Corporation.
                     19:  * Portions created by the Initial Developer are Copyright (C) 2002
                     20:  * the Initial Developer. All Rights Reserved.
                     21:  *
                     22:  * Contributor(s):
                     23:  *
                     24:  * Alternatively, the contents of this file may be used under the terms of
                     25:  * either the GNU General Public License Version 2 or later (the "GPL"), or 
                     26:  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
                     27:  * in which case the provisions of the GPL or the LGPL are applicable instead
                     28:  * of those above. If you wish to allow use of your version of this file only
                     29:  * under the terms of either the GPL or the LGPL, and not to allow others to
                     30:  * use your version of this file under the terms of the NPL, indicate your
                     31:  * decision by deleting the provisions above and replace them with the notice
                     32:  * and other provisions required by the GPL or the LGPL. If you do not delete
                     33:  * the provisions above, a recipient may use your version of this file under
                     34:  * the terms of any one of the NPL, the GPL or the LGPL.
                     35:  *
                     36:  * ***** END LICENSE BLOCK ***** */
1.1       hyatt      37: 
                     38: #import "BrowserWindowController.h"
                     39: #import "MyBrowserView.h"
                     40: 
1.37      hyatt      41: #include "nsIWebNavigation.h"
                     42: 
1.1       hyatt      43: static NSString *BrowserToolbarIdentifier  = @"Browser Window Toolbar";
                     44: static NSString *BackToolbarItemIdentifier = @"Back Toolbar Item";
                     45: static NSString *ForwardToolbarItemIdentifier  = @"Forward Toolbar Item";
                     46: static NSString *ReloadToolbarItemIdentifier = @"Reload Toolbar Item";
                     47: static NSString *StopToolbarItemIdentifier = @"Stop Toolbar Item";
                     48: static NSString *HomeToolbarItemIdentifier = @"Home Toolbar Item";
                     49: static NSString *LocationToolbarItemIdentifier = @"Location Toolbar Item";
                     50: static NSString *SidebarToolbarItemIdentifier  = @"Sidebar Toolbar Item";
1.11      macserv    51: static NSString *PrintToolbarItemIdentifier  = @"Print Toolbar Item";
1.1       hyatt      52: 
                     53: @interface BrowserWindowController(Private)
                     54: - (void)setupToolbar;
                     55: @end
                     56: 
                     57: @implementation BrowserWindowController
                     58: 
1.39      hyatt      59: -(void)enterModalSession
                     60: {
                     61:     mModalSession = [NSApp beginModalSessionForWindow: [self window]];
                     62:     [NSApp runModalSession: mModalSession];
                     63:     [NSApp endModalSession: mModalSession];
                     64:     mModalSession = nil;
                     65: }
                     66: 
1.35      hyatt      67: -(void)mouseMoved:(NSEvent*)aEvent
                     68: {
                     69:     if (mMoveReentrant)
                     70:         return;
                     71:         
                     72:     mMoveReentrant = YES;
                     73:     NSView* view = [[[self window] contentView] hitTest: [aEvent locationInWindow]];
                     74:     [view mouseMoved: aEvent];
                     75:     [super mouseMoved: aEvent];
                     76:     mMoveReentrant = NO;
                     77: }
                     78: 
1.41      macserv    79: - (id)initWithWindowNibName:(NSString *)windowNibName
1.4       hyatt      80: {
1.41      macserv    81:     if ( (self = [super initWithWindowNibName:(NSString *)windowNibName]) ) {
                     82:         mInitialized = NO;
                     83:         mMoveReentrant = NO;
                     84:     }
                     85:     return self;
1.4       hyatt      86: }
                     87: 
1.17      hyatt      88: - (void)windowWillClose:(NSNotification *)notification
                     89: {
1.40      hyatt      90:     printf("Window will close notification.\n");
1.17      hyatt      91:     [self autorelease];
1.21      hyatt      92:     [mSidebarBookmarksDataSource windowClosing];
1.17      hyatt      93: }
                     94: 
1.7       hyatt      95: - (void)dealloc
                     96: {
1.24      hyatt      97:     printf("Browser controller died.\n");
1.40      hyatt      98: 
1.10      hyatt      99:     [mBrowserView windowClosed];
1.25      hyatt     100:     [mSidebarBrowserView windowClosed];
                    101:     
1.38      hyatt     102:     [mProgress release];
1.40      hyatt     103:       
1.7       hyatt     104:     [super dealloc];
                    105: }
                    106: 
1.1       hyatt     107: - (void)windowDidLoad
                    108: {
1.35      hyatt     109:     [super windowDidLoad];
                    110:     
1.39      hyatt     111:     if (mModalSession)
                    112:       [NSApp stopModal: mModalSession];
                    113:       
1.4       hyatt     114:     mInitialized = YES;
1.38      hyatt     115:     
                    116:     // Retain with a single extra refcount.  This allows the MyBrowserViews
                    117:     // to remove the progress meter from its superview without having to 
                    118:     // worry about retaining and releasing it.
                    119:     [mProgress retain];
                    120:     
1.34      hyatt     121:     [[self window] setAcceptsMouseMovedEvents: YES];
                    122:     
1.1       hyatt     123:     [self setupToolbar];
1.30      hyatt     124: 
1.41      macserv   125: //  03/03/2002 mlj Changing strategy a bit here.  The addTab: method was
                    126: // duplicating a lot of the code found here.  I have moved it to that method.
                    127: // We now remove the IB tab, then add one of our own.
                    128: 
                    129:     [mTabBrowser removeTabViewItem:[mTabBrowser tabViewItemAtIndex:0]];
                    130:     [self newTab];
1.4       hyatt     131:     
                    132:     if (mURL) {
                    133:       [self loadURL: mURL];
                    134:       [mURL release];
                    135:     }
1.18      hyatt     136:     
                    137:     [mSidebarDrawer setDelegate: self];
                    138: }
                    139: 
1.22      hyatt     140: - (void)drawerWillOpen: (NSNotification*)aNotification
                    141: {
                    142:     [mSidebarBookmarksDataSource ensureBookmarks];
                    143: }
                    144: 
1.18      hyatt     145: - (void)drawerDidOpen:(NSNotification *)aNotification
                    146: {
1.23      hyatt     147:     // XXXdwh This is temporary.
                    148:     [[mSidebarBrowserView getBrowserView] loadURI: [NSURL URLWithString: @"http://tinderbox.mozilla.org/SeaMonkey/panel.html"] flags:NSLoadFlagsNone];
1.1       hyatt     149: }
                    150: 
1.19      hyatt     151: - (void)drawerDidClose:(NSNotification *)aNotification
                    152: {
                    153:     // Unload the Gecko web page in "My Panels" to save memory.
                    154:     [[mSidebarBrowserView getBrowserView] loadURI: [NSURL URLWithString: @"about:blank"] flags:NSLoadFlagsNone];
                    155: }
                    156: 
1.1       hyatt     157: - (void)setupToolbar
                    158: {
                    159:     NSToolbar *toolbar = [[[NSToolbar alloc] initWithIdentifier:BrowserToolbarIdentifier] autorelease];
                    160:     
                    161:     [toolbar setDisplayMode:NSToolbarDisplayModeDefault];
                    162:     [toolbar setAllowsUserCustomization:YES];
                    163:     [toolbar setAutosavesConfiguration:YES];
                    164:     [toolbar setDelegate:self];
                    165:     [[self window] setToolbar:toolbar];
                    166: }
                    167: 
                    168: 
                    169: - (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar
                    170: {
                    171:     return [NSArray arrayWithObjects:  BackToolbarItemIdentifier,
                    172:                                         ForwardToolbarItemIdentifier,
                    173:                                         ReloadToolbarItemIdentifier,
                    174:                                         StopToolbarItemIdentifier,
                    175:                                         HomeToolbarItemIdentifier,
                    176:                                         LocationToolbarItemIdentifier,
                    177:                                         SidebarToolbarItemIdentifier,
1.11      macserv   178:                                         PrintToolbarItemIdentifier,
1.1       hyatt     179:                                         NSToolbarCustomizeToolbarItemIdentifier,
                    180:                                         NSToolbarFlexibleSpaceItemIdentifier,
                    181:                                         NSToolbarSpaceItemIdentifier,
                    182:                                         NSToolbarSeparatorItemIdentifier,
                    183:                                         nil];
                    184: }
                    185: 
                    186: - (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar
                    187: {
                    188:     return [NSArray arrayWithObjects:  BackToolbarItemIdentifier,
                    189:                                         ForwardToolbarItemIdentifier,
                    190:                                         ReloadToolbarItemIdentifier,
                    191:                                         StopToolbarItemIdentifier,
                    192:                                         HomeToolbarItemIdentifier,
                    193:                                         LocationToolbarItemIdentifier,
                    194:                                         SidebarToolbarItemIdentifier,
                    195:                                         nil];
                    196: }
                    197: 
                    198: - (NSToolbarItem *) toolbar:(NSToolbar *)toolbar
                    199:       itemForItemIdentifier:(NSString *)itemIdent
                    200:   willBeInsertedIntoToolbar:(BOOL)willBeInserted
                    201: {
                    202:     NSToolbarItem *toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier:itemIdent] autorelease];
                    203:     if ( [itemIdent isEqual:BackToolbarItemIdentifier] ) {
                    204:         [toolbarItem setLabel:@"Back"];
                    205:         [toolbarItem setPaletteLabel:@"Go Back"];
                    206:         [toolbarItem setToolTip:@"Go back one page"];
                    207:         [toolbarItem setImage:[NSImage imageNamed:@"back"]];
                    208:         [toolbarItem setTarget:self];
                    209:         [toolbarItem setAction:@selector(back:)];
                    210:     } else if ( [itemIdent isEqual:ForwardToolbarItemIdentifier] ) {
                    211:         [toolbarItem setLabel:@"Forward"];
                    212:         [toolbarItem setPaletteLabel:@"Go Forward"];
                    213:         [toolbarItem setToolTip:@"Go forward one page"];
                    214:         [toolbarItem setImage:[NSImage imageNamed:@"forward"]];
                    215:         [toolbarItem setTarget:self];
                    216:         [toolbarItem setAction:@selector(forward:)];
                    217:     } else if ( [itemIdent isEqual:ReloadToolbarItemIdentifier] ) {
                    218:         [toolbarItem setLabel:@"Reload"];
                    219:         [toolbarItem setPaletteLabel:@"Reload Page"];
                    220:         [toolbarItem setToolTip:@"Reload current page"];
                    221:         [toolbarItem setImage:[NSImage imageNamed:@"reload"]];
                    222:         [toolbarItem setTarget:self];
                    223:         [toolbarItem setAction:@selector(reload:)];
                    224:     } else if ( [itemIdent isEqual:StopToolbarItemIdentifier] ) {
                    225:         [toolbarItem setLabel:@"Stop"];
                    226:         [toolbarItem setPaletteLabel:@"Stop Loading"];
                    227:         [toolbarItem setToolTip:@"Stop loading this page"];
                    228:         [toolbarItem setImage:[NSImage imageNamed:@"stop"]];
                    229:         [toolbarItem setTarget:self];
                    230:         [toolbarItem setAction:@selector(stop:)];
                    231:     } else if ( [itemIdent isEqual:HomeToolbarItemIdentifier] ) {
                    232:         [toolbarItem setLabel:@"Home"];
                    233:         [toolbarItem setPaletteLabel:@"Go Home"];
                    234:         [toolbarItem setToolTip:@"Go to home page"];
                    235:         [toolbarItem setImage:[NSImage imageNamed:@"home"]];
                    236:         [toolbarItem setTarget:self];
                    237:         [toolbarItem setAction:@selector(home:)];
                    238:     } else if ( [itemIdent isEqual:SidebarToolbarItemIdentifier] ) {
                    239:         [toolbarItem setLabel:@"Sidebar"];
                    240:         [toolbarItem setPaletteLabel:@"Toggle Sidebar"];
                    241:         [toolbarItem setToolTip:@"Show or hide the Sidebar"];
                    242:         [toolbarItem setImage:[NSImage imageNamed:@"sidebar"]];
                    243:         [toolbarItem setTarget:self];
                    244:         [toolbarItem setAction:@selector(toggleSidebar:)];
                    245:     } else if ( [itemIdent isEqual:LocationToolbarItemIdentifier] ) {
                    246:         
                    247:         NSMenuItem *menuFormRep = [[[NSMenuItem alloc] init] autorelease];
                    248:         
                    249:         [toolbarItem setLabel:@"Location"];
                    250:         [toolbarItem setPaletteLabel:@"Location"];
                    251:         [toolbarItem setImage:[NSImage imageNamed:@"Enter a web location."]];
                    252:         [toolbarItem setView:mLocationToolbarView];
                    253:         [toolbarItem setMinSize:NSMakeSize(128,32)];
                    254:         [toolbarItem setMaxSize:NSMakeSize(2560,32)];
                    255:         
                    256:         [menuFormRep setTarget:self];
1.5       macserv   257:         [menuFormRep setAction:@selector(performAppropriateLocationAction)];
1.1       hyatt     258:         [menuFormRep setTitle:[toolbarItem label]];
                    259:         
                    260:         [toolbarItem setMenuFormRepresentation:menuFormRep];
1.5       macserv   261:         mLocationToolbarItem = toolbarItem;
1.11      macserv   262: 
                    263:     } else if ( [itemIdent isEqual:PrintToolbarItemIdentifier] ) {
                    264:         [toolbarItem setLabel:@"Print"];
                    265:         [toolbarItem setPaletteLabel:@"Print"];
                    266:         [toolbarItem setToolTip:@"Print this page"];
                    267:         [toolbarItem setImage:[NSImage imageNamed:@"print"]];
                    268:         [toolbarItem setTarget:self];
                    269:         [toolbarItem setAction:@selector(printDocument)];
1.1       hyatt     270:     } else {
                    271:         toolbarItem = nil;
                    272:     }
                    273:         
                    274:     return toolbarItem;
                    275: }
                    276: 
                    277: // This method handles the enabling/disabling of the toolbar buttons.
                    278: - (BOOL)validateToolbarItem:(NSToolbarItem *)theItem
                    279: {
                    280:   // Check the action and see if it matches.
                    281:   SEL action = [theItem action];
                    282:   if (action == @selector(back:))
                    283:     return [[mBrowserView getBrowserView] canGoBack];
                    284:   else if (action == @selector(forward:))
                    285:     return [[mBrowserView getBrowserView] canGoForward];
                    286:   else if (action == @selector(reload:))
                    287:     return [mBrowserView isBusy] == NO;
                    288:   else if (action == @selector(stop:))
                    289:     return [mBrowserView isBusy];
                    290:   else
                    291:     return YES;
                    292: }
                    293:    
1.5       macserv   294: - (void)updateToolbarItems
1.1       hyatt     295: {
                    296:   [[[self window] toolbar] validateVisibleItems];
                    297: }
                    298: 
1.5       macserv   299: - (void)performAppropriateLocationAction
                    300: {
                    301:     if ( [[[self window] toolbar] isVisible] ) {
                    302:         if ( ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconAndLabel) ||
                    303:              ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconOnly) ) {
                    304:             [self focusURLBar];
                    305:         } else {
                    306:             [self beginLocationSheet];
                    307:         }
                    308:     } else {
                    309:         [self beginLocationSheet];
                    310:     }
                    311: }
                    312: 
                    313: - (void)focusURLBar
1.3       hyatt     314: {
                    315:     [mURLBar selectText: self];
                    316: }
                    317: 
1.5       macserv   318: - (void)beginLocationSheet
                    319: {
                    320:     [NSApp beginSheet: mLocationSheetWindow
                    321:        modalForWindow: [self window]
                    322:         modalDelegate: nil
                    323:        didEndSelector: nil
                    324:           contextInfo: nil];
                    325: }
                    326: 
                    327: - (IBAction)endLocationSheet:(id)sender
                    328: {
                    329:     [mLocationSheetWindow orderOut:self];
                    330:     [NSApp endSheet:mLocationSheetWindow returnCode:1];
                    331:     [self loadURL:[NSURL URLWithString:[mLocationSheetURLField stringValue]]];
1.32      hyatt     332:     
                    333:     // Focus and activate our content area.
                    334:     [[mBrowserView getBrowserView] setActive: YES];
1.5       macserv   335: }
                    336: 
                    337: - (IBAction)goToLocationFromToolbarURLField:(id)sender
                    338: {
                    339:     [self loadURL:[NSURL URLWithString:[sender stringValue]]];
1.32      hyatt     340:     
                    341:     // Focus and activate our content area.
                    342:     [[mBrowserView getBrowserView] setActive: YES];
1.5       macserv   343: }
                    344: 
1.7       hyatt     345: - (void)saveDocument: (NSView*)aFilterView filterList: (NSPopUpButton*)aFilterList
1.6       hyatt     346: {
1.7       hyatt     347:     [[mBrowserView getBrowserView] saveDocument: aFilterView filterList: aFilterList];
1.6       hyatt     348: }
                    349: 
1.12      hyatt     350: - (void)printDocument
                    351: {
                    352:     [[mBrowserView getBrowserView] printDocument];
                    353: }
                    354: 
1.15      hyatt     355: - (void)printPreview
                    356: {
                    357:     [[mBrowserView getBrowserView] printPreview];
                    358: }
                    359: 
1.16      hyatt     360: - (void)findInPage
                    361: {
                    362:     [[mBrowserView getBrowserView] findInPage];
                    363: }
                    364: 
                    365: - (void)findAgain
                    366: {
                    367:     [[mBrowserView getBrowserView] findAgain];
1.22      hyatt     368: }
                    369: 
                    370: - (void)addBookmark
                    371: {
                    372:     // XXXdwh Hack.  Just go to the sidebar for now until we get our
                    373:     // menu data source going.
                    374:     [mSidebarBookmarksDataSource ensureBookmarks];
                    375:     [mSidebarBookmarksDataSource addBookmark: self];
1.16      hyatt     376: }
                    377: 
1.5       macserv   378: - (IBAction)back:(id)aSender
1.1       hyatt     379: {
                    380:   [[mBrowserView getBrowserView] goBack];
                    381: }
                    382: 
1.5       macserv   383: - (IBAction)forward:(id)aSender
1.1       hyatt     384: {
                    385:   [[mBrowserView getBrowserView] goForward];
                    386: }
                    387: 
1.5       macserv   388: - (IBAction)reload:(id)aSender
1.1       hyatt     389: {
                    390:   [[mBrowserView getBrowserView] reload: 0];
                    391: }
                    392: 
1.5       macserv   393: - (IBAction)stop:(id)aSender
1.1       hyatt     394: {
1.37      hyatt     395:   [[mBrowserView getBrowserView] stop: nsIWebNavigation::STOP_ALL];
1.1       hyatt     396: }
                    397: 
1.5       macserv   398: - (IBAction)home:(id)aSender
1.1       hyatt     399: {
1.5       macserv   400:   [[mBrowserView getBrowserView] loadURI:[NSURL URLWithString:@"about:blank"] flags:NSLoadFlagsNone];
1.1       hyatt     401: }
                    402: 
1.5       macserv   403: - (IBAction)toggleSidebar:(id)aSender
1.1       hyatt     404: {
1.36      hyatt     405:     NSResponder* resp = [[self window] firstResponder];
                    406:     [[self window] makeFirstResponder: nil];
                    407:     
1.31      hyatt     408:     if ( ([mSidebarDrawer state] == NSDrawerClosedState) || ([mSidebarDrawer state] == NSDrawerClosingState) )   {
1.34      hyatt     409:         // XXXHack to bypass sidebar crashes.
1.1       hyatt     410:         [mSidebarDrawer open];
                    411:     } else {
                    412:         [mSidebarDrawer close];
                    413:     }
1.36      hyatt     414:     
                    415:     [[self window] makeFirstResponder: resp];
1.1       hyatt     416: }
                    417: 
1.4       hyatt     418: -(void)loadURL:(NSURL*)aURL
1.1       hyatt     419: {
1.32      hyatt     420:     if (mInitialized) {
1.4       hyatt     421:         [[mBrowserView getBrowserView] loadURI:aURL flags:NSLoadFlagsNone];
1.32      hyatt     422:     }
1.4       hyatt     423:     else {
                    424:         mURL = aURL;
                    425:         [mURL retain];
                    426:     }
1.1       hyatt     427: }
1.5       macserv   428: 
                    429: - (void)updateLocationFields:(NSString *)locationString
                    430: {
                    431: /* //commenting this out because it doesn't work right yet.
                    432:     if ( [locationString length] > 30 ) {
                    433:         [[mLocationToolbarItem menuFormRepresentation] setTitle:
                    434:             [NSString stringWithFormat:@"Location: %@...", [locationString substringToIndex:31]]];
                    435:     } else {
                    436:         [[mLocationToolbarItem menuFormRepresentation] setTitle:
                    437:             [NSString stringWithFormat:@"Location: %@", locationString]];
                    438:     }
                    439: */
                    440: 
                    441:     [mURLBar setStringValue:locationString];
                    442:     [mLocationSheetURLField setStringValue:locationString];
                    443: 
                    444:     [[self window] update];
                    445:     [[self window] display];
1.8       hyatt     446: }
1.27      hyatt     447: 
                    448: -(void)newTab
                    449: {
1.28      hyatt     450:     NSTabViewItem* newTab = [[[NSTabViewItem alloc] initWithIdentifier: nil] autorelease];
1.47    ! hyatt     451:     MyBrowserView* newView = [[[MyBrowserView alloc] initWithFrame: [mBrowserView frame]] autorelease];
        !           452:     [newView setTab: newTab];
1.41      macserv   453: 
                    454:     [newTab setLabel: @"Untitled"];
                    455:     [newTab setView: newView];
                    456: 
1.28      hyatt     457:     [mTabBrowser addTabViewItem: newTab];
1.42      macserv   458: 
1.28      hyatt     459:     [[newView getBrowserView] loadURI:[NSURL URLWithString:@"about:blank"] flags:NSLoadFlagsNone];
1.42      macserv   460: 
1.28      hyatt     461:     [mTabBrowser selectLastTabViewItem: self];
1.42      macserv   462: 
1.29      hyatt     463:     if ( [[[self window] toolbar] isVisible] ) {
                    464:         if ( ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconAndLabel) ||
                    465:              ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconOnly) ) {
                    466:             [self focusURLBar];
1.42      macserv   467:         }
1.29      hyatt     468:     }
1.42      macserv   469: }
                    470: 
                    471: -(void)closeTab
                    472: {
                    473:     if ( [mTabBrowser numberOfTabViewItems] > 1 ) {
                    474:         [mTabBrowser removeTabViewItem:[mTabBrowser selectedTabViewItem]];
                    475:     }
                    476: }
                    477: 
                    478: - (void)previousTab
                    479: {
                    480:     [mTabBrowser selectPreviousTabViewItem:self];
                    481: }
                    482: 
                    483: - (void)nextTab
                    484: {
                    485:     [mTabBrowser selectNextTabViewItem:self];
1.28      hyatt     486: }
1.27      hyatt     487: 
1.28      hyatt     488: - (void)tabView:(NSTabView *)aTabView didSelectTabViewItem:(NSTabViewItem *)aTabViewItem
                    489: {
1.41      macserv   490:     // Disconnect the old view, if one has been designated.
                    491:     // If the window has just been opened, none has been.
                    492:     if ( mBrowserView ) {
                    493:         [mBrowserView disconnectView];
                    494:     }
1.28      hyatt     495:     // Connect up the new view
                    496:     mBrowserView = [aTabViewItem view];
1.30      hyatt     497:        
1.28      hyatt     498:     // Make the new view the primary content area.
1.47    ! hyatt     499:     [mBrowserView makePrimaryBrowserView: mURLBar status: mStatus
1.28      hyatt     500:         progress: mProgress windowController: self];
1.27      hyatt     501: }
1.28      hyatt     502: 
1.31      hyatt     503: -(MyBrowserView*)getMyBrowserView
                    504: {
                    505:     return mBrowserView;
                    506: }
1.45      hyatt     507: 
                    508: -(void)openNewWindowWithURL: (NSURL*)aURL loadInBackground: (BOOL)aLoadInBG
                    509: {
                    510:     BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
                    511:     [browser loadURL: aURL];
1.46      hyatt     512:     if (aLoadInBG)
                    513:       [[browser window] orderWindow: NSWindowBelow relativeTo: [[self window] windowNumber]];
                    514:  else
                    515:       [browser showWindow: self];
1.47    ! hyatt     516:       
        !           517:     // XXXdwh Focus the content area.
        !           518: }
        !           519: 
        !           520: -(void)openNewTabWithURL: (NSURL*)aURL loadInBackground: (BOOL)aLoadInBG
        !           521: {
        !           522:     NSTabViewItem* newTab = [[[NSTabViewItem alloc] initWithIdentifier: nil] autorelease];
        !           523:     
        !           524:     NSTabViewItem* selectedTab = [mTabBrowser selectedTabViewItem];
        !           525:     int index = [mTabBrowser indexOfTabViewItem: selectedTab];
        !           526:     [mTabBrowser insertTabViewItem: newTab atIndex: index+1];
        !           527:     
        !           528:     MyBrowserView* newView = [[[MyBrowserView alloc] initWithFrame: [mBrowserView frame]] autorelease];
        !           529:     [newView setTab: newTab];
        !           530:     
        !           531:     [newTab setLabel: @"Loading..."];
        !           532:     [newTab setView: newView];
        !           533: 
        !           534:     [[newView getBrowserView] loadURI:aURL flags:NSLoadFlagsNone];
        !           535: 
        !           536:     if (!aLoadInBG)
        !           537:         [mTabBrowser selectTabViewItem: newTab];
        !           538:         
        !           539:     // XXXdwh Focus the content area.
1.45      hyatt     540: }
1.1       hyatt     541: @end
                    542: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>