Diff for /chimera/BrowserWindowController.mm between versions 1.46 and 1.51

version 1.46, 2002/03/08 01:53:07 version 1.51, 2002/03/11 23:38:05
Line 37 Line 37
   
 #import "BrowserWindowController.h"  #import "BrowserWindowController.h"
 #import "MyBrowserView.h"  #import "MyBrowserView.h"
   #import "IconTabViewItem.h"
   
 #include "nsIWebNavigation.h"  #include "nsIWebNavigation.h"
   #include "nsCocoaBrowserService.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";
Line 79  static NSString *PrintToolbarItemIdentif Line 81  static NSString *PrintToolbarItemIdentif
 - (id)initWithWindowNibName:(NSString *)windowNibName  - (id)initWithWindowNibName:(NSString *)windowNibName
 {  {
     if ( (self = [super initWithWindowNibName:(NSString *)windowNibName]) ) {      if ( (self = [super initWithWindowNibName:(NSString *)windowNibName]) ) {
           if ( nsCocoaBrowserService::sNumBrowsers == 0 ) {
               [self setShouldCascadeWindows:NO];
           } else {
               [self setShouldCascadeWindows:YES];
           }
         mInitialized = NO;          mInitialized = NO;
         mMoveReentrant = NO;          mMoveReentrant = NO;
           mShouldAutosave = YES;
     }      }
     return self;      return self;
 }  }
   
   -(void)autosaveWindowFrame
   {
     if (mShouldAutosave)
       [[self window] saveFrameUsingName: @"NavigatorWindow"];
   }
   
   -(void)disableAutosave
   {
     mShouldAutosave = NO;
   }
   
 - (void)windowWillClose:(NSNotification *)notification  - (void)windowWillClose:(NSNotification *)notification
 {  {
    printf("Window will close notification.\n");  printf("Window will close notification.\n");
    [self autorelease];  [mSidebarBookmarksDataSource windowClosing];
    [mSidebarBookmarksDataSource windowClosing];
   [self autosaveWindowFrame];
   [self autorelease];
 }  }
   
 - (void)dealloc  - (void)dealloc
 {  {
    printf("Browser controller died.\n");  printf("Browser controller died.\n");
   
    [mBrowserView windowClosed];  // Loop over all tabs, and tell them that the window is closed.
    [mSidebarBrowserView windowClosed];  int numTabs = [mTabBrowser numberOfTabViewItems];
      for (int i = 0; i < numTabs; i++) {
    [mProgress release];    NSTabViewItem* item = [mTabBrowser tabViewItemAtIndex: i];
          [[item view] windowClosed];
    [super dealloc];  }
   [mSidebarBrowserView windowClosed];
 
   [mProgress release];
   
   [super dealloc];
 }  }
   
 - (void)windowDidLoad  - (void)windowDidLoad
 {  {
     [super windowDidLoad];      [super windowDidLoad];
   
       // Get our saved dimensions.
       [[self window] setFrameUsingName: @"NavigatorWindow"];
           
     if (mModalSession)      if (mModalSession)
       [NSApp stopModal: mModalSession];        [NSApp stopModal: mModalSession];
Line 135  static NSString *PrintToolbarItemIdentif Line 164  static NSString *PrintToolbarItemIdentif
     }      }
           
     [mSidebarDrawer setDelegate: self];      [mSidebarDrawer setDelegate: self];
    
//    [mBrowserView makePrimaryBrowserView: tab urlbar: mURLBar status: mStatus    [mSidebarTabView addTabViewItem: //testing...
  //      progress: mProgress windowController: self];        [[[IconTabViewItem alloc] initWithIdentifier:nil withTabIcon:[NSImage imageNamed:@"bookicon"]] autorelease]];
 }  }
   
 - (void)drawerWillOpen: (NSNotification*)aNotification  - (void)drawerWillOpen: (NSNotification*)aNotification
Line 451  static NSString *PrintToolbarItemIdentif Line 480  static NSString *PrintToolbarItemIdentif
 -(void)newTab  -(void)newTab
 {  {
     NSTabViewItem* newTab = [[[NSTabViewItem alloc] initWithIdentifier: nil] autorelease];      NSTabViewItem* newTab = [[[NSTabViewItem alloc] initWithIdentifier: nil] autorelease];
    MyBrowserView* newView = [[[MyBrowserView alloc] initWithFrame: [[newTab view] frame]] autorelease];    MyBrowserView* newView = [[[MyBrowserView alloc] initWithFrame: [mBrowserView frame]] autorelease];
     [newView setTab: newTab];
   
     [newTab setLabel: @"Untitled"];      [newTab setLabel: @"Untitled"];
     [newTab setView: newView];      [newTab setView: newView];
Line 472  static NSString *PrintToolbarItemIdentif Line 502  static NSString *PrintToolbarItemIdentif
   
 -(void)closeTab  -(void)closeTab
 {  {
    if ( [mTabBrowser numberOfTabViewItems] > 1 ) {  if ( [mTabBrowser numberOfTabViewItems] > 1 ) {
        [mTabBrowser removeTabViewItem:[mTabBrowser selectedTabViewItem]];    [[[mTabBrowser selectedTabViewItem] view] windowClosed];
    }    [mTabBrowser removeTabViewItem:[mTabBrowser selectedTabViewItem]];
   }
 }  }
   
 - (void)previousTab  - (void)previousTab
Line 498  static NSString *PrintToolbarItemIdentif Line 529  static NSString *PrintToolbarItemIdentif
     mBrowserView = [aTabViewItem view];      mBrowserView = [aTabViewItem view];
                 
     // Make the new view the primary content area.      // Make the new view the primary content area.
    [mBrowserView makePrimaryBrowserView: aTabViewItem urlbar: mURLBar status: mStatus    [mBrowserView makePrimaryBrowserView: mURLBar status: mStatus
         progress: mProgress windowController: self];          progress: mProgress windowController: self];
 }  }
   
Line 509  static NSString *PrintToolbarItemIdentif Line 540  static NSString *PrintToolbarItemIdentif
   
 -(void)openNewWindowWithURL: (NSURL*)aURL loadInBackground: (BOOL)aLoadInBG  -(void)openNewWindowWithURL: (NSURL*)aURL loadInBackground: (BOOL)aLoadInBG
 {  {
    BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];  // Autosave our dimensions before we open a new window.  That ensures the size ends up matching.
    [browser loadURL: aURL];  [self autosaveWindowFrame];
    if (aLoadInBG)
      [[browser window] orderWindow: NSWindowBelow relativeTo: [[self window] windowNumber]];  BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
        else  [browser loadURL: aURL];
      [browser showWindow: self];  if (aLoadInBG)
     [[browser window] orderWindow: NSWindowBelow relativeTo: [[self window] windowNumber]];
   else
     [browser showWindow: self];
 
   // XXXdwh Focus the content area.
 }
 
 -(void)openNewTabWithURL: (NSURL*)aURL loadInBackground: (BOOL)aLoadInBG
 {
     NSTabViewItem* newTab = [[[NSTabViewItem alloc] initWithIdentifier: nil] autorelease];
     
     NSTabViewItem* selectedTab = [mTabBrowser selectedTabViewItem];
     int index = [mTabBrowser indexOfTabViewItem: selectedTab];
     [mTabBrowser insertTabViewItem: newTab atIndex: index+1];
     
     MyBrowserView* newView = [[[MyBrowserView alloc] initWithFrame: [mBrowserView frame]] autorelease];
     [newView setTab: newTab];
     
     [newTab setLabel: @"Loading..."];
     [newTab setView: newView];
 
     [[newView getBrowserView] loadURI:aURL flags:NSLoadFlagsNone];
 
     if (!aLoadInBG)
         [mTabBrowser selectTabViewItem: newTab];
         
     // XXXdwh Focus the content area.
 }  }
 @end  @end
   

Removed from v.1.46  
changed lines
  Added in v.1.51


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