File:  [mozdev] / chimera / BrowserWindowController.mm
Revision 1.53: download - view: text, annotated - select for diffs - revision graph
Wed Mar 13 09:34:38 2002 UTC (17 years, 9 months ago) by macserv
Branches: MAIN
CVS tags: HEAD
Making sure the Bookmarks tab gets selected at startup.  We should probably create an autosave method which fires when tabs switch, probably based on the tab's identifier.

    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 ***** */
   37: 
   38: #import "BrowserWindowController.h"
   39: #import "MyBrowserView.h"
   40: #import "IconTabViewItem.h"
   41: 
   42: #include "nsIWebNavigation.h"
   43: #include "nsCocoaBrowserService.h"
   44: 
   45: static NSString *BrowserToolbarIdentifier	= @"Browser Window Toolbar";
   46: static NSString *BackToolbarItemIdentifier	= @"Back Toolbar Item";
   47: static NSString *ForwardToolbarItemIdentifier	= @"Forward Toolbar Item";
   48: static NSString *ReloadToolbarItemIdentifier	= @"Reload Toolbar Item";
   49: static NSString *StopToolbarItemIdentifier	= @"Stop Toolbar Item";
   50: static NSString *HomeToolbarItemIdentifier	= @"Home Toolbar Item";
   51: static NSString *LocationToolbarItemIdentifier	= @"Location Toolbar Item";
   52: static NSString *SidebarToolbarItemIdentifier	= @"Sidebar Toolbar Item";
   53: static NSString *PrintToolbarItemIdentifier	= @"Print Toolbar Item";
   54: 
   55: @interface BrowserWindowController(Private)
   56: - (void)setupToolbar;
   57: - (void)setupSidebarTabs;
   58: @end
   59: 
   60: @implementation BrowserWindowController
   61: 
   62: -(void)enterModalSession
   63: {
   64:     mModalSession = [NSApp beginModalSessionForWindow: [self window]];
   65:     [NSApp runModalSession: mModalSession];
   66:     [NSApp endModalSession: mModalSession];
   67:     mModalSession = nil;
   68: }
   69: 
   70: -(void)mouseMoved:(NSEvent*)aEvent
   71: {
   72:     if (mMoveReentrant)
   73:         return;
   74:         
   75:     mMoveReentrant = YES;
   76:     NSView* view = [[[self window] contentView] hitTest: [aEvent locationInWindow]];
   77:     [view mouseMoved: aEvent];
   78:     [super mouseMoved: aEvent];
   79:     mMoveReentrant = NO;
   80: }
   81: 
   82: - (id)initWithWindowNibName:(NSString *)windowNibName
   83: {
   84:     if ( (self = [super initWithWindowNibName:(NSString *)windowNibName]) ) {
   85:         if ( nsCocoaBrowserService::sNumBrowsers == 0 ) {
   86:             [self setShouldCascadeWindows:NO];
   87:         } else {
   88:             [self setShouldCascadeWindows:YES];
   89:         }
   90:         mInitialized = NO;
   91:         mMoveReentrant = NO;
   92:         mShouldAutosave = YES;
   93:     }
   94:     return self;
   95: }
   96: 
   97: -(void)autosaveWindowFrame
   98: {
   99:   if (mShouldAutosave)
  100:     [[self window] saveFrameUsingName: @"NavigatorWindow"];
  101: }
  102: 
  103: -(void)disableAutosave
  104: {
  105:   mShouldAutosave = NO;
  106: }
  107: 
  108: - (void)windowWillClose:(NSNotification *)notification
  109: {
  110:   printf("Window will close notification.\n");
  111:   [mSidebarBookmarksDataSource windowClosing];
  112: 
  113:   [self autosaveWindowFrame];
  114:   [self autorelease];
  115: }
  116: 
  117: - (void)dealloc
  118: {
  119:   printf("Browser controller died.\n");
  120: 
  121:   // Loop over all tabs, and tell them that the window is closed.
  122:   int numTabs = [mTabBrowser numberOfTabViewItems];
  123:   for (int i = 0; i < numTabs; i++) {
  124:     NSTabViewItem* item = [mTabBrowser tabViewItemAtIndex: i];
  125:     [[item view] windowClosed];
  126:   }
  127:   [mSidebarBrowserView windowClosed];
  128: 
  129:   [mProgress release];
  130:   
  131:   [super dealloc];
  132: }
  133: 
  134: - (void)windowDidLoad
  135: {
  136:     [super windowDidLoad];
  137: 
  138:     // Get our saved dimensions.
  139:     [[self window] setFrameUsingName: @"NavigatorWindow"];
  140:     
  141:     if (mModalSession)
  142:       [NSApp stopModal: mModalSession];
  143:       
  144:     mInitialized = YES;
  145:     
  146:     // Retain with a single extra refcount.  This allows the MyBrowserViews
  147:     // to remove the progress meter from its superview without having to 
  148:     // worry about retaining and releasing it.
  149:     [mProgress retain];
  150:     
  151:     [[self window] setAcceptsMouseMovedEvents: YES];
  152:     
  153:     [self setupToolbar];
  154: 
  155: //  03/03/2002 mlj Changing strategy a bit here.  The addTab: method was
  156: //	duplicating a lot of the code found here.  I have moved it to that method.
  157: //	We now remove the IB tab, then add one of our own.
  158: 
  159:     [mTabBrowser removeTabViewItem:[mTabBrowser tabViewItemAtIndex:0]];
  160:     [self newTab];
  161:     
  162:     if (mURL) {
  163:       [self loadURL: mURL];
  164:       [mURL release];
  165:     }
  166:     
  167:     [mSidebarDrawer setDelegate: self];
  168: 
  169:     [self setupSidebarTabs];
  170: }
  171: 
  172: - (void)drawerWillOpen: (NSNotification*)aNotification
  173: {
  174:     [mSidebarBookmarksDataSource ensureBookmarks];
  175: }
  176: 
  177: - (void)drawerDidOpen:(NSNotification *)aNotification
  178: {
  179:     // XXXdwh This is temporary.
  180:     [[mSidebarBrowserView getBrowserView] loadURI: [NSURL URLWithString: @"http://tinderbox.mozilla.org/SeaMonkey/panel.html"] flags:NSLoadFlagsNone];
  181: }
  182: 
  183: - (void)drawerDidClose:(NSNotification *)aNotification
  184: {
  185:     // Unload the Gecko web page in "My Panels" to save memory.
  186:     [[mSidebarBrowserView getBrowserView] loadURI: [NSURL URLWithString: @"about:blank"] flags:NSLoadFlagsNone];
  187: }
  188: 
  189: - (void)setupToolbar
  190: {
  191:     NSToolbar *toolbar = [[[NSToolbar alloc] initWithIdentifier:BrowserToolbarIdentifier] autorelease];
  192:     
  193:     [toolbar setDisplayMode:NSToolbarDisplayModeDefault];
  194:     [toolbar setAllowsUserCustomization:YES];
  195:     [toolbar setAutosavesConfiguration:YES];
  196:     [toolbar setDelegate:self];
  197:     [[self window] setToolbar:toolbar];
  198: }
  199: 
  200: 
  201: - (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar
  202: {
  203:     return [NSArray arrayWithObjects:	BackToolbarItemIdentifier,
  204:                                         ForwardToolbarItemIdentifier,
  205:                                         ReloadToolbarItemIdentifier,
  206:                                         StopToolbarItemIdentifier,
  207:                                         HomeToolbarItemIdentifier,
  208:                                         LocationToolbarItemIdentifier,
  209:                                         SidebarToolbarItemIdentifier,
  210:                                         PrintToolbarItemIdentifier,
  211:                                         NSToolbarCustomizeToolbarItemIdentifier,
  212:                                         NSToolbarFlexibleSpaceItemIdentifier,
  213:                                         NSToolbarSpaceItemIdentifier,
  214:                                         NSToolbarSeparatorItemIdentifier,
  215:                                         nil];
  216: }
  217: 
  218: - (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar
  219: {
  220:     return [NSArray arrayWithObjects:	BackToolbarItemIdentifier,
  221:                                         ForwardToolbarItemIdentifier,
  222:                                         ReloadToolbarItemIdentifier,
  223:                                         StopToolbarItemIdentifier,
  224:                                         HomeToolbarItemIdentifier,
  225:                                         LocationToolbarItemIdentifier,
  226:                                         SidebarToolbarItemIdentifier,
  227:                                         nil];
  228: }
  229: 
  230: - (NSToolbarItem *) toolbar:(NSToolbar *)toolbar
  231:       itemForItemIdentifier:(NSString *)itemIdent
  232:   willBeInsertedIntoToolbar:(BOOL)willBeInserted
  233: {
  234:     NSToolbarItem *toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier:itemIdent] autorelease];
  235:     if ( [itemIdent isEqual:BackToolbarItemIdentifier] ) {
  236:         [toolbarItem setLabel:@"Back"];
  237:         [toolbarItem setPaletteLabel:@"Go Back"];
  238:         [toolbarItem setToolTip:@"Go back one page"];
  239:         [toolbarItem setImage:[NSImage imageNamed:@"back"]];
  240:         [toolbarItem setTarget:self];
  241:         [toolbarItem setAction:@selector(back:)];
  242:     } else if ( [itemIdent isEqual:ForwardToolbarItemIdentifier] ) {
  243:         [toolbarItem setLabel:@"Forward"];
  244:         [toolbarItem setPaletteLabel:@"Go Forward"];
  245:         [toolbarItem setToolTip:@"Go forward one page"];
  246:         [toolbarItem setImage:[NSImage imageNamed:@"forward"]];
  247:         [toolbarItem setTarget:self];
  248:         [toolbarItem setAction:@selector(forward:)];
  249:     } else if ( [itemIdent isEqual:ReloadToolbarItemIdentifier] ) {
  250:         [toolbarItem setLabel:@"Reload"];
  251:         [toolbarItem setPaletteLabel:@"Reload Page"];
  252:         [toolbarItem setToolTip:@"Reload current page"];
  253:         [toolbarItem setImage:[NSImage imageNamed:@"reload"]];
  254:         [toolbarItem setTarget:self];
  255:         [toolbarItem setAction:@selector(reload:)];
  256:     } else if ( [itemIdent isEqual:StopToolbarItemIdentifier] ) {
  257:         [toolbarItem setLabel:@"Stop"];
  258:         [toolbarItem setPaletteLabel:@"Stop Loading"];
  259:         [toolbarItem setToolTip:@"Stop loading this page"];
  260:         [toolbarItem setImage:[NSImage imageNamed:@"stop"]];
  261:         [toolbarItem setTarget:self];
  262:         [toolbarItem setAction:@selector(stop:)];
  263:     } else if ( [itemIdent isEqual:HomeToolbarItemIdentifier] ) {
  264:         [toolbarItem setLabel:@"Home"];
  265:         [toolbarItem setPaletteLabel:@"Go Home"];
  266:         [toolbarItem setToolTip:@"Go to home page"];
  267:         [toolbarItem setImage:[NSImage imageNamed:@"home"]];
  268:         [toolbarItem setTarget:self];
  269:         [toolbarItem setAction:@selector(home:)];
  270:     } else if ( [itemIdent isEqual:SidebarToolbarItemIdentifier] ) {
  271:         [toolbarItem setLabel:@"Sidebar"];
  272:         [toolbarItem setPaletteLabel:@"Toggle Sidebar"];
  273:         [toolbarItem setToolTip:@"Show or hide the Sidebar"];
  274:         [toolbarItem setImage:[NSImage imageNamed:@"sidebar"]];
  275:         [toolbarItem setTarget:self];
  276:         [toolbarItem setAction:@selector(toggleSidebar:)];
  277:     } else if ( [itemIdent isEqual:LocationToolbarItemIdentifier] ) {
  278:         
  279:         NSMenuItem *menuFormRep = [[[NSMenuItem alloc] init] autorelease];
  280:         
  281:         [toolbarItem setLabel:@"Location"];
  282:         [toolbarItem setPaletteLabel:@"Location"];
  283:         [toolbarItem setImage:[NSImage imageNamed:@"Enter a web location."]];
  284:         [toolbarItem setView:mLocationToolbarView];
  285:         [toolbarItem setMinSize:NSMakeSize(128,32)];
  286:         [toolbarItem setMaxSize:NSMakeSize(2560,32)];
  287:         
  288:         [menuFormRep setTarget:self];
  289:         [menuFormRep setAction:@selector(performAppropriateLocationAction)];
  290:         [menuFormRep setTitle:[toolbarItem label]];
  291:         
  292:         [toolbarItem setMenuFormRepresentation:menuFormRep];
  293:         mLocationToolbarItem = toolbarItem;
  294: 
  295:     } else if ( [itemIdent isEqual:PrintToolbarItemIdentifier] ) {
  296:         [toolbarItem setLabel:@"Print"];
  297:         [toolbarItem setPaletteLabel:@"Print"];
  298:         [toolbarItem setToolTip:@"Print this page"];
  299:         [toolbarItem setImage:[NSImage imageNamed:@"print"]];
  300:         [toolbarItem setTarget:self];
  301:         [toolbarItem setAction:@selector(printDocument)];
  302:     } else {
  303:         toolbarItem = nil;
  304:     }
  305:         
  306:     return toolbarItem;
  307: }
  308: 
  309: // This method handles the enabling/disabling of the toolbar buttons.
  310: - (BOOL)validateToolbarItem:(NSToolbarItem *)theItem
  311: {
  312:   // Check the action and see if it matches.
  313:   SEL action = [theItem action];
  314:   if (action == @selector(back:))
  315:     return [[mBrowserView getBrowserView] canGoBack];
  316:   else if (action == @selector(forward:))
  317:     return [[mBrowserView getBrowserView] canGoForward];
  318:   else if (action == @selector(reload:))
  319:     return [mBrowserView isBusy] == NO;
  320:   else if (action == @selector(stop:))
  321:     return [mBrowserView isBusy];
  322:   else
  323:     return YES;
  324: }
  325:    
  326: - (void)updateToolbarItems
  327: {
  328:   [[[self window] toolbar] validateVisibleItems];
  329: }
  330: 
  331: - (void)performAppropriateLocationAction
  332: {
  333:     if ( [[[self window] toolbar] isVisible] ) {
  334:         if ( ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconAndLabel) ||
  335:              ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconOnly) ) {
  336:             [self focusURLBar];
  337:         } else {
  338:             [self beginLocationSheet];
  339:         }
  340:     } else {
  341:         [self beginLocationSheet];
  342:     }
  343: }
  344: 
  345: - (void)focusURLBar
  346: {
  347:     [mURLBar selectText: self];
  348: }
  349: 
  350: - (void)beginLocationSheet
  351: {
  352:     [NSApp beginSheet:	mLocationSheetWindow
  353:        modalForWindow:	[self window]
  354:         modalDelegate:	nil
  355:        didEndSelector:	nil
  356:           contextInfo:	nil];
  357: }
  358: 
  359: - (IBAction)endLocationSheet:(id)sender
  360: {
  361:     [mLocationSheetWindow orderOut:self];
  362:     [NSApp endSheet:mLocationSheetWindow returnCode:1];
  363:     [self loadURL:[NSURL URLWithString:[mLocationSheetURLField stringValue]]];
  364:     
  365:     // Focus and activate our content area.
  366:     [[mBrowserView getBrowserView] setActive: YES];
  367: }
  368: 
  369: - (IBAction)goToLocationFromToolbarURLField:(id)sender
  370: {
  371:     [self loadURL:[NSURL URLWithString:[sender stringValue]]];
  372:     
  373:     // Focus and activate our content area.
  374:     [[mBrowserView getBrowserView] setActive: YES];
  375: }
  376: 
  377: - (void)saveDocument: (NSView*)aFilterView filterList: (NSPopUpButton*)aFilterList
  378: {
  379:     [[mBrowserView getBrowserView] saveDocument: aFilterView filterList: aFilterList];
  380: }
  381: 
  382: - (void)printDocument
  383: {
  384:     [[mBrowserView getBrowserView] printDocument];
  385: }
  386: 
  387: - (void)printPreview
  388: {
  389:     [[mBrowserView getBrowserView] printPreview];
  390: }
  391: 
  392: - (void)findInPage
  393: {
  394:     [[mBrowserView getBrowserView] findInPage];
  395: }
  396: 
  397: - (void)findAgain
  398: {
  399:     [[mBrowserView getBrowserView] findAgain];
  400: }
  401: 
  402: - (void)addBookmark
  403: {
  404:     // XXXdwh Hack.  Just go to the sidebar for now until we get our
  405:     // menu data source going.
  406:     [mSidebarBookmarksDataSource ensureBookmarks];
  407:     [mSidebarBookmarksDataSource addBookmark: self];
  408: }
  409: 
  410: - (IBAction)back:(id)aSender
  411: {
  412:   [[mBrowserView getBrowserView] goBack];
  413: }
  414: 
  415: - (IBAction)forward:(id)aSender
  416: {
  417:   [[mBrowserView getBrowserView] goForward];
  418: }
  419: 
  420: - (IBAction)reload:(id)aSender
  421: {
  422:   [[mBrowserView getBrowserView] reload: 0];
  423: }
  424: 
  425: - (IBAction)stop:(id)aSender
  426: {
  427:   [[mBrowserView getBrowserView] stop: nsIWebNavigation::STOP_ALL];
  428: }
  429: 
  430: - (IBAction)home:(id)aSender
  431: {
  432:   [[mBrowserView getBrowserView] loadURI:[NSURL URLWithString:@"about:blank"] flags:NSLoadFlagsNone];
  433: }
  434: 
  435: - (IBAction)toggleSidebar:(id)aSender
  436: {
  437:     NSResponder* resp = [[self window] firstResponder];
  438:     [[self window] makeFirstResponder: nil];
  439:     
  440:     if ( ([mSidebarDrawer state] == NSDrawerClosedState) || ([mSidebarDrawer state] == NSDrawerClosingState) ) 	{
  441:         // XXXHack to bypass sidebar crashes.
  442:         [mSidebarDrawer open];
  443:     } else {
  444:         [mSidebarDrawer close];
  445:     }
  446:     
  447:     [[self window] makeFirstResponder: resp];
  448: }
  449: 
  450: -(void)loadURL:(NSURL*)aURL
  451: {
  452:     if (mInitialized) {
  453:         [[mBrowserView getBrowserView] loadURI:aURL flags:NSLoadFlagsNone];
  454:     }
  455:     else {
  456:         mURL = aURL;
  457:         [mURL retain];
  458:     }
  459: }
  460: 
  461: - (void)updateLocationFields:(NSString *)locationString
  462: {
  463: /* //commenting this out because it doesn't work right yet.
  464:     if ( [locationString length] > 30 ) {
  465:         [[mLocationToolbarItem menuFormRepresentation] setTitle:
  466:             [NSString stringWithFormat:@"Location: %@...", [locationString substringToIndex:31]]];
  467:     } else {
  468:         [[mLocationToolbarItem menuFormRepresentation] setTitle:
  469:             [NSString stringWithFormat:@"Location: %@", locationString]];
  470:     }
  471: */
  472: 
  473:     [mURLBar setStringValue:locationString];
  474:     [mLocationSheetURLField setStringValue:locationString];
  475: 
  476:     [[self window] update];
  477:     [[self window] display];
  478: }
  479: 
  480: -(void)newTab
  481: {
  482:     NSTabViewItem* newTab = [[[NSTabViewItem alloc] initWithIdentifier: nil] autorelease];
  483:     MyBrowserView* newView = [[[MyBrowserView alloc] initWithFrame: [mBrowserView frame]] autorelease];
  484:     [newView setTab: newTab];
  485: 
  486:     [newTab setLabel: @"Untitled"];
  487:     [newTab setView: newView];
  488: 
  489:     [mTabBrowser addTabViewItem: newTab];
  490: 
  491:     [[newView getBrowserView] loadURI:[NSURL URLWithString:@"about:blank"] flags:NSLoadFlagsNone];
  492: 
  493:     [mTabBrowser selectLastTabViewItem: self];
  494: 
  495:     if ( [[[self window] toolbar] isVisible] ) {
  496:         if ( ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconAndLabel) ||
  497:              ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconOnly) ) {
  498:             [self focusURLBar];
  499:         }
  500:     }
  501: }
  502: 
  503: -(void)closeTab
  504: {
  505:   if ( [mTabBrowser numberOfTabViewItems] > 1 ) {
  506:     [[[mTabBrowser selectedTabViewItem] view] windowClosed];
  507:     [mTabBrowser removeTabViewItem:[mTabBrowser selectedTabViewItem]];
  508:   }
  509: }
  510: 
  511: - (void)previousTab
  512: {
  513:     [mTabBrowser selectPreviousTabViewItem:self];
  514: }
  515: 
  516: - (void)nextTab
  517: {
  518:     [mTabBrowser selectNextTabViewItem:self];
  519: }
  520: 
  521: - (void)tabView:(NSTabView *)aTabView didSelectTabViewItem:(NSTabViewItem *)aTabViewItem
  522: {
  523:     // Disconnect the old view, if one has been designated.
  524:     // If the window has just been opened, none has been.
  525:     if ( mBrowserView ) {
  526:         [mBrowserView disconnectView];
  527:     }
  528:     // Connect up the new view
  529:     mBrowserView = [aTabViewItem view];
  530:        
  531:     // Make the new view the primary content area.
  532:     [mBrowserView makePrimaryBrowserView: mURLBar status: mStatus
  533:         progress: mProgress windowController: self];
  534: }
  535: 
  536: -(MyBrowserView*)getMyBrowserView
  537: {
  538:     return mBrowserView;
  539: }
  540: 
  541: -(void)openNewWindowWithURL: (NSURL*)aURL loadInBackground: (BOOL)aLoadInBG
  542: {
  543:   // Autosave our dimensions before we open a new window.  That ensures the size ends up matching.
  544:   [self autosaveWindowFrame];
  545: 
  546:   BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
  547:   [browser loadURL: aURL];
  548:   if (aLoadInBG)
  549:     [[browser window] orderWindow: NSWindowBelow relativeTo: [[self window] windowNumber]];
  550:   else
  551:     [browser showWindow: self];
  552: 
  553:   // XXXdwh Focus the content area.
  554: }
  555: 
  556: -(void)openNewTabWithURL: (NSURL*)aURL loadInBackground: (BOOL)aLoadInBG
  557: {
  558:     NSTabViewItem* newTab = [[[NSTabViewItem alloc] initWithIdentifier: nil] autorelease];
  559:     
  560:     NSTabViewItem* selectedTab = [mTabBrowser selectedTabViewItem];
  561:     int index = [mTabBrowser indexOfTabViewItem: selectedTab];
  562:     [mTabBrowser insertTabViewItem: newTab atIndex: index+1];
  563:     
  564:     MyBrowserView* newView = [[[MyBrowserView alloc] initWithFrame: [mBrowserView frame]] autorelease];
  565:     [newView setTab: newTab];
  566:     
  567:     [newTab setLabel: @"Loading..."];
  568:     [newTab setView: newView];
  569: 
  570:     [[newView getBrowserView] loadURI:aURL flags:NSLoadFlagsNone];
  571: 
  572:     if (!aLoadInBG)
  573:         [mTabBrowser selectTabViewItem: newTab];
  574:         
  575:     // XXXdwh Focus the content area.
  576: }
  577: 
  578: -(void)setupSidebarTabs
  579: {
  580:     IconTabViewItem   *bookItem = [[IconTabViewItem alloc] initWithIdentifier:@"bookmarkSidebarIconTabViewItem"
  581:                                   withTabIcon:[NSImage imageNamed:@"bookicon"]];
  582:     IconTabViewItem   *histItem = [[IconTabViewItem alloc] initWithIdentifier:@"historySidebarIconTabViewItem"
  583:                                   withTabIcon:[NSImage imageNamed:@"historyicon"]];
  584:     IconTabViewItem *searchItem = [[IconTabViewItem alloc] initWithIdentifier:@"searchSidebarIconTabViewItem"
  585:                                   withTabIcon:[NSImage imageNamed:@"searchicon"]];
  586: 
  587:     [bookItem   setView:[[mSidebarSourceTabView tabViewItemAtIndex:0] view]];
  588:     [histItem   setView:[[mSidebarSourceTabView tabViewItemAtIndex:1] view]];
  589:     [searchItem setView:[[mSidebarSourceTabView tabViewItemAtIndex:2] view]];
  590: 
  591:     [mSidebarTabView insertTabViewItem:bookItem   atIndex:0];
  592:     [mSidebarTabView insertTabViewItem:histItem   atIndex:1];
  593:     [mSidebarTabView insertTabViewItem:searchItem atIndex:2];
  594: 
  595:     [mSidebarTabView selectFirstTabViewItem:self];
  596: }
  597: 
  598: 
  599: @end
  600: 

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