Diff for /chimera/BrowserWindowController.mm between versions 1.33 and 1.42

version 1.33, 2002/02/20 01:33:48 version 1.42, 2002/03/03 12:53:10
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
 {
     mModalSession = [NSApp beginModalSessionForWindow: [self window]];
     [NSApp runModalSession: mModalSession];
     [NSApp endModalSession: mModalSession];
     mModalSession = nil;
 }
 
 -(void)mouseMoved:(NSEvent*)aEvent
 {  {
    mInitialized = NO;    if (mMoveReentrant)
    return [super init];        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];      [mSidebarBookmarksDataSource windowClosing];
 }  }
Line 36  static NSString *PrintToolbarItemIdentif Line 62  static NSString *PrintToolbarItemIdentif
 - (void)dealloc  - (void)dealloc
 {  {
     printf("Browser controller died.\n");      printf("Browser controller died.\n");
    
     [mBrowserView windowClosed];      [mBrowserView windowClosed];
     [mSidebarBrowserView 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];
   
    // Our initial view is our primary view.  Connect it up.//  03/03/2002 mlj Changing strategy a bit here.  The addTab: method was
    NSTabViewItem* tab = [mTabBrowser tabViewItemAtIndex: 0];//      duplicating a lot of the code found here.  I have moved it to that method.
    NSView* view = [tab view];//      We now remove the IB tab, then add one of our own.
    
    MyBrowserView* newView = [[[MyBrowserView alloc] initWithFrame: [view frame]] autorelease];    [mTabBrowser removeTabViewItem:[mTabBrowser tabViewItemAtIndex:0]];
    [tab setView: newView];    [self newTab];
    mBrowserView = newView; 
           
     if (mURL) {      if (mURL) {
       [self loadURL: mURL];        [self loadURL: mURL];
Line 63  static NSString *PrintToolbarItemIdentif Line 103  static NSString *PrintToolbarItemIdentif
           
     [mSidebarDrawer setDelegate: self];      [mSidebarDrawer setDelegate: self];
           
    [mBrowserView makePrimaryBrowserView: tab urlbar: mURLBar status: mStatus//    [mBrowserView makePrimaryBrowserView: tab urlbar: mURLBar status: mStatus
        progress: mProgress windowController: self];  //      progress: mProgress windowController: self];
 }  }
   
 - (void)drawerWillOpen: (NSNotification*)aNotification  - (void)drawerWillOpen: (NSNotification*)aNotification
Line 322  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 332  static NSString *PrintToolbarItemIdentif Line 372  static NSString *PrintToolbarItemIdentif
   
 - (IBAction)toggleSidebar:(id)aSender  - (IBAction)toggleSidebar:(id)aSender
 {  {
    // XXXHack to bypass sidebar crashes.    NSResponder* resp = [[self window] firstResponder];
    [[self window] makeFirstResponder: mURLBar];    [[self window] makeFirstResponder: nil];
           
     if ( ([mSidebarDrawer state] == NSDrawerClosedState) || ([mSidebarDrawer state] == NSDrawerClosingState) )  {      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
Line 375  static NSString *PrintToolbarItemIdentif Line 418  static NSString *PrintToolbarItemIdentif
 -(void)newTab  -(void)newTab
 {  {
     NSTabViewItem* newTab = [[[NSTabViewItem alloc] initWithIdentifier: nil] autorelease];      NSTabViewItem* newTab = [[[NSTabViewItem alloc] initWithIdentifier: nil] autorelease];
    [mTabBrowser addTabViewItem: newTab];    MyBrowserView* newView = [[[MyBrowserView alloc] initWithFrame: [[newTab view] frame]] autorelease];
    //  MyBrowserView* newView = [[[MyBrowserView alloc] initWithFrame: [mBrowserView frame]] autorelease];
    MyBrowserView* newView = [[[MyBrowserView alloc] initWithFrame: [mBrowserView frame]] autorelease];
    [newTab setView: newView]; 
     [newTab setLabel: @"Untitled"];      [newTab setLabel: @"Untitled"];
        [newTab setView: newView];
 
     [mTabBrowser addTabViewItem: newTab];
 
     [[newView getBrowserView] loadURI:[NSURL URLWithString:@"about:blank"] flags:NSLoadFlagsNone];      [[newView getBrowserView] loadURI:[NSURL URLWithString:@"about:blank"] flags:NSLoadFlagsNone];
    
     [mTabBrowser selectLastTabViewItem: self];      [mTabBrowser selectLastTabViewItem: self];
    
     if ( [[[self window] toolbar] isVisible] ) {      if ( [[[self window] toolbar] isVisible] ) {
         if ( ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconAndLabel) ||          if ( ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconAndLabel) ||
              ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconOnly) ) {               ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconOnly) ) {
             [self focusURLBar];              [self focusURLBar];
        }         }
     }      }
    }
    //XXXdwh Do this if we ever support auto-hide.
    //if ([mTabBrowser numberOfTabViewItems] == 2)-(void)closeTab
    //    [mTabBrowser setTabViewType: NSTopTabsBezelBorder];{
     if ( [mTabBrowser numberOfTabViewItems] > 1 ) {
         [mTabBrowser removeTabViewItem:[mTabBrowser selectedTabViewItem]];
     }
 }
 
 - (void)previousTab
 {
     [mTabBrowser selectPreviousTabViewItem:self];
 }
 
 - (void)nextTab
 {
     [mTabBrowser selectNextTabViewItem:self];
 }  }
   
 - (void)tabView:(NSTabView *)aTabView didSelectTabViewItem:(NSTabViewItem *)aTabViewItem  - (void)tabView:(NSTabView *)aTabView didSelectTabViewItem:(NSTabViewItem *)aTabViewItem
 {  {
    // Disconnect the old view.    // Disconnect the old view, if one has been designated.
    [mBrowserView disconnectView];    // If the window has just been opened, none has been.
        if ( mBrowserView ) {
         [mBrowserView disconnectView];
     }
     // Connect up the new view      // Connect up the new view
     mBrowserView = [aTabViewItem view];      mBrowserView = [aTabViewItem view];
                 

Removed from v.1.33  
changed lines
  Added in v.1.42


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