Annotation of chimera/BrowserWindowController.mm, revision 1.53
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"
1.50 macserv 40: #import "IconTabViewItem.h"
1.1 hyatt 41:
1.37 hyatt 42: #include "nsIWebNavigation.h"
1.51 macserv 43: #include "nsCocoaBrowserService.h"
1.37 hyatt 44:
1.1 hyatt 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";
1.11 macserv 53: static NSString *PrintToolbarItemIdentifier = @"Print Toolbar Item";
1.1 hyatt 54:
55: @interface BrowserWindowController(Private)
56: - (void)setupToolbar;
1.52 macserv 57: - (void)setupSidebarTabs;
1.1 hyatt 58: @end
59:
60: @implementation BrowserWindowController
61:
1.39 hyatt 62: -(void)enterModalSession
63: {
64: mModalSession = [NSApp beginModalSessionForWindow: [self window]];
65: [NSApp runModalSession: mModalSession];
66: [NSApp endModalSession: mModalSession];
67: mModalSession = nil;
68: }
69:
1.35 hyatt 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:
1.41 macserv 82: - (id)initWithWindowNibName:(NSString *)windowNibName
1.4 hyatt 83: {
1.41 macserv 84: if ( (self = [super initWithWindowNibName:(NSString *)windowNibName]) ) {
1.51 macserv 85: if ( nsCocoaBrowserService::sNumBrowsers == 0 ) {
86: [self setShouldCascadeWindows:NO];
87: } else {
88: [self setShouldCascadeWindows:YES];
89: }
1.41 macserv 90: mInitialized = NO;
91: mMoveReentrant = NO;
1.48 hyatt 92: mShouldAutosave = YES;
1.41 macserv 93: }
94: return self;
1.4 hyatt 95: }
96:
1.48 hyatt 97: -(void)autosaveWindowFrame
98: {
99: if (mShouldAutosave)
100: [[self window] saveFrameUsingName: @"NavigatorWindow"];
101: }
102:
103: -(void)disableAutosave
104: {
105: mShouldAutosave = NO;
106: }
107:
1.17 hyatt 108: - (void)windowWillClose:(NSNotification *)notification
109: {
1.49 hyatt 110: printf("Window will close notification.\n");
111: [mSidebarBookmarksDataSource windowClosing];
1.48 hyatt 112:
1.49 hyatt 113: [self autosaveWindowFrame];
114: [self autorelease];
1.17 hyatt 115: }
116:
1.7 hyatt 117: - (void)dealloc
118: {
1.49 hyatt 119: printf("Browser controller died.\n");
1.40 hyatt 120:
1.49 hyatt 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];
1.7 hyatt 132: }
133:
1.1 hyatt 134: - (void)windowDidLoad
135: {
1.35 hyatt 136: [super windowDidLoad];
1.48 hyatt 137:
138: // Get our saved dimensions.
139: [[self window] setFrameUsingName: @"NavigatorWindow"];
1.35 hyatt 140:
1.39 hyatt 141: if (mModalSession)
142: [NSApp stopModal: mModalSession];
143:
1.4 hyatt 144: mInitialized = YES;
1.38 hyatt 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:
1.34 hyatt 151: [[self window] setAcceptsMouseMovedEvents: YES];
152:
1.1 hyatt 153: [self setupToolbar];
1.30 hyatt 154:
1.41 macserv 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];
1.4 hyatt 161:
162: if (mURL) {
163: [self loadURL: mURL];
164: [mURL release];
165: }
1.18 hyatt 166:
167: [mSidebarDrawer setDelegate: self];
1.50 macserv 168:
1.52 macserv 169: [self setupSidebarTabs];
1.18 hyatt 170: }
171:
1.22 hyatt 172: - (void)drawerWillOpen: (NSNotification*)aNotification
173: {
174: [mSidebarBookmarksDataSource ensureBookmarks];
175: }
176:
1.18 hyatt 177: - (void)drawerDidOpen:(NSNotification *)aNotification
178: {
1.23 hyatt 179: // XXXdwh This is temporary.
180: [[mSidebarBrowserView getBrowserView] loadURI: [NSURL URLWithString: @"http://tinderbox.mozilla.org/SeaMonkey/panel.html"] flags:NSLoadFlagsNone];
1.1 hyatt 181: }
182:
1.19 hyatt 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:
1.1 hyatt 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,
1.11 macserv 210: PrintToolbarItemIdentifier,
1.1 hyatt 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];
1.5 macserv 289: [menuFormRep setAction:@selector(performAppropriateLocationAction)];
1.1 hyatt 290: [menuFormRep setTitle:[toolbarItem label]];
291:
292: [toolbarItem setMenuFormRepresentation:menuFormRep];
1.5 macserv 293: mLocationToolbarItem = toolbarItem;
1.11 macserv 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)];
1.1 hyatt 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:
1.5 macserv 326: - (void)updateToolbarItems
1.1 hyatt 327: {
328: [[[self window] toolbar] validateVisibleItems];
329: }
330:
1.5 macserv 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
1.3 hyatt 346: {
347: [mURLBar selectText: self];
348: }
349:
1.5 macserv 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]]];
1.32 hyatt 364:
365: // Focus and activate our content area.
366: [[mBrowserView getBrowserView] setActive: YES];
1.5 macserv 367: }
368:
369: - (IBAction)goToLocationFromToolbarURLField:(id)sender
370: {
371: [self loadURL:[NSURL URLWithString:[sender stringValue]]];
1.32 hyatt 372:
373: // Focus and activate our content area.
374: [[mBrowserView getBrowserView] setActive: YES];
1.5 macserv 375: }
376:
1.7 hyatt 377: - (void)saveDocument: (NSView*)aFilterView filterList: (NSPopUpButton*)aFilterList
1.6 hyatt 378: {
1.7 hyatt 379: [[mBrowserView getBrowserView] saveDocument: aFilterView filterList: aFilterList];
1.6 hyatt 380: }
381:
1.12 hyatt 382: - (void)printDocument
383: {
384: [[mBrowserView getBrowserView] printDocument];
385: }
386:
1.15 hyatt 387: - (void)printPreview
388: {
389: [[mBrowserView getBrowserView] printPreview];
390: }
391:
1.16 hyatt 392: - (void)findInPage
393: {
394: [[mBrowserView getBrowserView] findInPage];
395: }
396:
397: - (void)findAgain
398: {
399: [[mBrowserView getBrowserView] findAgain];
1.22 hyatt 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];
1.16 hyatt 408: }
409:
1.5 macserv 410: - (IBAction)back:(id)aSender
1.1 hyatt 411: {
412: [[mBrowserView getBrowserView] goBack];
413: }
414:
1.5 macserv 415: - (IBAction)forward:(id)aSender
1.1 hyatt 416: {
417: [[mBrowserView getBrowserView] goForward];
418: }
419:
1.5 macserv 420: - (IBAction)reload:(id)aSender
1.1 hyatt 421: {
422: [[mBrowserView getBrowserView] reload: 0];
423: }
424:
1.5 macserv 425: - (IBAction)stop:(id)aSender
1.1 hyatt 426: {
1.37 hyatt 427: [[mBrowserView getBrowserView] stop: nsIWebNavigation::STOP_ALL];
1.1 hyatt 428: }
429:
1.5 macserv 430: - (IBAction)home:(id)aSender
1.1 hyatt 431: {
1.5 macserv 432: [[mBrowserView getBrowserView] loadURI:[NSURL URLWithString:@"about:blank"] flags:NSLoadFlagsNone];
1.1 hyatt 433: }
434:
1.5 macserv 435: - (IBAction)toggleSidebar:(id)aSender
1.1 hyatt 436: {
1.36 hyatt 437: NSResponder* resp = [[self window] firstResponder];
438: [[self window] makeFirstResponder: nil];
439:
1.31 hyatt 440: if ( ([mSidebarDrawer state] == NSDrawerClosedState) || ([mSidebarDrawer state] == NSDrawerClosingState) ) {
1.34 hyatt 441: // XXXHack to bypass sidebar crashes.
1.1 hyatt 442: [mSidebarDrawer open];
443: } else {
444: [mSidebarDrawer close];
445: }
1.36 hyatt 446:
447: [[self window] makeFirstResponder: resp];
1.1 hyatt 448: }
449:
1.4 hyatt 450: -(void)loadURL:(NSURL*)aURL
1.1 hyatt 451: {
1.32 hyatt 452: if (mInitialized) {
1.4 hyatt 453: [[mBrowserView getBrowserView] loadURI:aURL flags:NSLoadFlagsNone];
1.32 hyatt 454: }
1.4 hyatt 455: else {
456: mURL = aURL;
457: [mURL retain];
458: }
1.1 hyatt 459: }
1.5 macserv 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];
1.8 hyatt 478: }
1.27 hyatt 479:
480: -(void)newTab
481: {
1.28 hyatt 482: NSTabViewItem* newTab = [[[NSTabViewItem alloc] initWithIdentifier: nil] autorelease];
1.47 hyatt 483: MyBrowserView* newView = [[[MyBrowserView alloc] initWithFrame: [mBrowserView frame]] autorelease];
484: [newView setTab: newTab];
1.41 macserv 485:
486: [newTab setLabel: @"Untitled"];
487: [newTab setView: newView];
488:
1.28 hyatt 489: [mTabBrowser addTabViewItem: newTab];
1.42 macserv 490:
1.28 hyatt 491: [[newView getBrowserView] loadURI:[NSURL URLWithString:@"about:blank"] flags:NSLoadFlagsNone];
1.42 macserv 492:
1.28 hyatt 493: [mTabBrowser selectLastTabViewItem: self];
1.42 macserv 494:
1.29 hyatt 495: if ( [[[self window] toolbar] isVisible] ) {
496: if ( ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconAndLabel) ||
497: ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconOnly) ) {
498: [self focusURLBar];
1.42 macserv 499: }
1.29 hyatt 500: }
1.42 macserv 501: }
502:
503: -(void)closeTab
504: {
1.49 hyatt 505: if ( [mTabBrowser numberOfTabViewItems] > 1 ) {
506: [[[mTabBrowser selectedTabViewItem] view] windowClosed];
507: [mTabBrowser removeTabViewItem:[mTabBrowser selectedTabViewItem]];
508: }
1.42 macserv 509: }
510:
511: - (void)previousTab
512: {
513: [mTabBrowser selectPreviousTabViewItem:self];
514: }
515:
516: - (void)nextTab
517: {
518: [mTabBrowser selectNextTabViewItem:self];
1.28 hyatt 519: }
1.27 hyatt 520:
1.28 hyatt 521: - (void)tabView:(NSTabView *)aTabView didSelectTabViewItem:(NSTabViewItem *)aTabViewItem
522: {
1.41 macserv 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: }
1.28 hyatt 528: // Connect up the new view
529: mBrowserView = [aTabViewItem view];
1.30 hyatt 530:
1.28 hyatt 531: // Make the new view the primary content area.
1.47 hyatt 532: [mBrowserView makePrimaryBrowserView: mURLBar status: mStatus
1.28 hyatt 533: progress: mProgress windowController: self];
1.27 hyatt 534: }
1.28 hyatt 535:
1.31 hyatt 536: -(MyBrowserView*)getMyBrowserView
537: {
538: return mBrowserView;
539: }
1.45 hyatt 540:
541: -(void)openNewWindowWithURL: (NSURL*)aURL loadInBackground: (BOOL)aLoadInBG
542: {
1.48 hyatt 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.
1.47 hyatt 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.
1.45 hyatt 576: }
1.52 macserv 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];
1.53 ! macserv 594:
! 595: [mSidebarTabView selectFirstTabViewItem:self];
1.52 macserv 596: }
597:
598:
1.1 hyatt 599: @end
600:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>