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

version 1.42, 2002/03/03 12:53:10 version 1.56, 2002/04/08 23:33:41
Line 1 Line 1
/*/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 *  BrowserWindowController.mm/* ***** BEGIN LICENSE BLOCK *****
 */ * Version: NPL 1.1/GPL 2.0/LGPL 2.1
  * The contents of this file are subject to the Netscape Public License
  * Version 1.1 (the "License"); you may not use this file except in
  * compliance with the License. You may obtain a copy of the License at
  * http://www.mozilla.org/NPL/
  * Software distributed under the License is distributed on an "AS IS" basis,
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  * for the specific language governing rights and limitations under the
  * License.
  * The Original Code is mozilla.org code.
  * The Initial Developer of the Original Code is 
  * Netscape Communications Corporation.
  * Portions created by the Initial Developer are Copyright (C) 2002
  * the Initial Developer. All Rights Reserved.
  * Contributor(s):
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or 
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the NPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the NPL, the GPL or the LGPL.
  * ***** END LICENSE BLOCK ***** */
 #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 19  static NSString *PrintToolbarItemIdentif Line 54  static NSString *PrintToolbarItemIdentif
 @interface BrowserWindowController(Private)  @interface BrowserWindowController(Private)
 - (void)setupToolbar;  - (void)setupToolbar;
   - (void)setupSidebarTabs;
 @end  @end
 @implementation BrowserWindowController  @implementation BrowserWindowController
Line 46  static NSString *PrintToolbarItemIdentif Line 82  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;
 }  }
     if (mShouldAutosave)
       [[self window] saveFrameUsingName: @"NavigatorWindow"];
     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 102  static NSString *PrintToolbarItemIdentif Line 165  static NSString *PrintToolbarItemIdentif
     }      }
     [mSidebarDrawer setDelegate: self];      [mSidebarDrawer setDelegate: self];
//    [mBrowserView makePrimaryBrowserView: tab urlbar: mURLBar status: mStatus    [self setupSidebarTabs];
  //      progress: mProgress windowController: self]; 
 }  }
 - (void)drawerWillOpen: (NSNotification*)aNotification  - (void)drawerWillOpen: (NSNotification*)aNotification
Line 115  static NSString *PrintToolbarItemIdentif Line 177  static NSString *PrintToolbarItemIdentif
 - (void)drawerDidOpen:(NSNotification *)aNotification  - (void)drawerDidOpen:(NSNotification *)aNotification
 {  {
     // XXXdwh This is temporary.      // XXXdwh This is temporary.
    [[mSidebarBrowserView getBrowserView] loadURI: [NSURL URLWithString: @"http://tinderbox.mozilla.org/SeaMonkey/panel.html"] flags:NSLoadFlagsNone];  //  [[mSidebarBrowserView getBrowserView] loadURI: [NSURL URLWithString: @"http://tinderbox.mozilla.org/SeaMonkey/panel.html"] flags:NSLoadFlagsNone];
     [mSidebarToolbarItem setImage:[NSImage imageNamed:@"sidebarOpened"]];
 }  }
 - (void)drawerDidClose:(NSNotification *)aNotification  - (void)drawerDidClose:(NSNotification *)aNotification
 {  {
     // Unload the Gecko web page in "My Panels" to save memory.      // Unload the Gecko web page in "My Panels" to save memory.
    [[mSidebarBrowserView getBrowserView] loadURI: [NSURL URLWithString: @"about:blank"] flags:NSLoadFlagsNone];    [mSidebarToolbarItem setImage:[NSImage imageNamed:@"sidebarClosed"]];
   //  [[mSidebarBrowserView getBrowserView] loadURI: [NSURL URLWithString: @"about:blank"] flags:NSLoadFlagsNone];
 }  }
 - (void)setupToolbar  - (void)setupToolbar
Line 209  static NSString *PrintToolbarItemIdentif Line 273  static NSString *PrintToolbarItemIdentif
         [toolbarItem setLabel:@"Sidebar"];          [toolbarItem setLabel:@"Sidebar"];
         [toolbarItem setPaletteLabel:@"Toggle Sidebar"];          [toolbarItem setPaletteLabel:@"Toggle Sidebar"];
         [toolbarItem setToolTip:@"Show or hide the Sidebar"];          [toolbarItem setToolTip:@"Show or hide the Sidebar"];
        [toolbarItem setImage:[NSImage imageNamed:@"sidebar"]];        [toolbarItem setImage:[NSImage imageNamed:@"sidebarClosed"]];
         [toolbarItem setTarget:self];          [toolbarItem setTarget:self];
         [toolbarItem setAction:@selector(toggleSidebar:)];          [toolbarItem setAction:@selector(toggleSidebar:)];
           mSidebarToolbarItem = toolbarItem;
     } else if ( [itemIdent isEqual:LocationToolbarItemIdentifier] ) {      } else if ( [itemIdent isEqual:LocationToolbarItemIdentifier] ) {
         NSMenuItem *menuFormRep = [[[NSMenuItem alloc] init] autorelease];          NSMenuItem *menuFormRep = [[[NSMenuItem alloc] init] autorelease];
Line 327  static NSString *PrintToolbarItemIdentif Line 392  static NSString *PrintToolbarItemIdentif
     [[mBrowserView getBrowserView] printPreview];      [[mBrowserView getBrowserView] printPreview];
 }  }
- (void)findInPage- (void)findInPage:(NSString*)text
 {  {
    [[mBrowserView getBrowserView] findInPage];    [[mBrowserView getBrowserView] findInPage:text];
 }  }
 - (void)findAgain  - (void)findAgain
Line 385  static NSString *PrintToolbarItemIdentif Line 450  static NSString *PrintToolbarItemIdentif
     [[self window] makeFirstResponder: resp];      [[self window] makeFirstResponder: resp];
 }  }
 -(void)loadURL:(NSURL*)aURL  -(void)loadURL:(NSURL*)aURL
 {  {
     if (mInitialized) {      if (mInitialized) {
Line 418  static NSString *PrintToolbarItemIdentif Line 484  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];
//  MyBrowserView* newView = [[[MyBrowserView alloc] initWithFrame: [mBrowserView frame]] autorelease];    [newView setTab: newTab];
     [newTab setLabel: @"Untitled"];      [newTab setLabel: @"Untitled"];
     [newTab setView: newView];      [newTab setView: newView];
Line 440  static NSString *PrintToolbarItemIdentif Line 506  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 466  static NSString *PrintToolbarItemIdentif Line 533  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 474  static NSString *PrintToolbarItemIdentif Line 541  static NSString *PrintToolbarItemIdentif
 {  {
     return mBrowserView;      return mBrowserView;
 }  }
   -(void)openNewWindowWithURL: (NSURL*)aURL loadInBackground: (BOOL)aLoadInBG
     // Autosave our dimensions before we open a new window.  That ensures the size ends up matching.
     [self autosaveWindowFrame];
     BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
     [browser loadURL: aURL];
     if (aLoadInBG)
       [[browser window] orderWindow: NSWindowBelow relativeTo: [[self window] windowNumber]];
       [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.
       IconTabViewItem   *bookItem = [[IconTabViewItem alloc] initWithIdentifier:@"bookmarkSidebarIconTabViewItem"
                                     withTabIcon:[NSImage imageNamed:@"bookicon"]];
       IconTabViewItem   *histItem = [[IconTabViewItem alloc] initWithIdentifier:@"historySidebarIconTabViewItem"
                                     withTabIcon:[NSImage imageNamed:@"historyicon"]];
       IconTabViewItem *searchItem = [[IconTabViewItem alloc] initWithIdentifier:@"searchSidebarIconTabViewItem"
                                     withTabIcon:[NSImage imageNamed:@"searchicon"]];
       [bookItem   setView:[[mSidebarSourceTabView tabViewItemAtIndex:0] view]];
       [histItem   setView:[[mSidebarSourceTabView tabViewItemAtIndex:1] view]];
       [searchItem setView:[[mSidebarSourceTabView tabViewItemAtIndex:2] view]];
       [mSidebarTabView insertTabViewItem:bookItem   atIndex:0];
       [mSidebarTabView insertTabViewItem:histItem   atIndex:1];
       [mSidebarTabView insertTabViewItem:searchItem atIndex:2];
       [mSidebarTabView selectFirstTabViewItem:self];
 @end  @end

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

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