Diff for /chimera/BrowserWindowController.mm between versions 1.4 and 1.35

version 1.4, 2002/01/31 03:13:19 version 1.35, 2002/02/22 02:13:42
Line 13  static NSString *StopToolbarItemIdentifi Line 13  static NSString *StopToolbarItemIdentifi
 static NSString *HomeToolbarItemIdentifier      = @"Home Toolbar Item";  static NSString *HomeToolbarItemIdentifier      = @"Home Toolbar Item";
 static NSString *LocationToolbarItemIdentifier  = @"Location Toolbar Item";  static NSString *LocationToolbarItemIdentifier  = @"Location Toolbar Item";
 static NSString *SidebarToolbarItemIdentifier   = @"Sidebar Toolbar Item";  static NSString *SidebarToolbarItemIdentifier   = @"Sidebar Toolbar Item";
   static NSString *PrintToolbarItemIdentifier     = @"Print Toolbar Item";
   
 @interface BrowserWindowController(Private)  @interface BrowserWindowController(Private)
 - (void)setupToolbar;  - (void)setupToolbar;
Line 20  static NSString *SidebarToolbarItemIdent Line 21  static NSString *SidebarToolbarItemIdent
   
 @implementation BrowserWindowController  @implementation BrowserWindowController
   
   -(void)mouseMoved:(NSEvent*)aEvent
   {
       if (mMoveReentrant)
           return;
           
       mMoveReentrant = YES;
       NSView* view = [[[self window] contentView] hitTest: [aEvent locationInWindow]];
       [view mouseMoved: aEvent];
       [super mouseMoved: aEvent];
       mMoveReentrant = NO;
   }
   
 - (id)init   - (id)init 
 {  {
     mInitialized = NO;      mInitialized = NO;
       mMoveReentrant = NO;
     return [super init];      return [super init];
 }  }
   
   - (void)windowWillClose:(NSNotification *)notification
   {
       [self autorelease];
       [mSidebarBookmarksDataSource windowClosing];
   }
   
   - (void)dealloc
   {
       printf("Browser controller died.\n");
       
       [mBrowserView windowClosed];
       [mSidebarBrowserView windowClosed];
       
       [super dealloc];
   }
   
 - (void)windowDidLoad  - (void)windowDidLoad
 {  {
       [super windowDidLoad];
       
     mInitialized = YES;      mInitialized = YES;
       [[self window] setAcceptsMouseMovedEvents: YES];
       
     [self setupToolbar];      [self setupToolbar];
   
       // Our initial view is our primary view.  Connect it up.
       NSTabViewItem* tab = [mTabBrowser tabViewItemAtIndex: 0];
       NSView* view = [tab view];
       
       MyBrowserView* newView = [[[MyBrowserView alloc] initWithFrame: [view frame]] autorelease];
       [tab setView: newView];
       mBrowserView = newView;
           
     if (mURL) {      if (mURL) {
       [self loadURL: mURL];        [self loadURL: mURL];
       [mURL release];        [mURL release];
     }      }
       
       [mSidebarDrawer setDelegate: self];
       
       [mBrowserView makePrimaryBrowserView: tab urlbar: mURLBar status: mStatus
           progress: mProgress windowController: self];
   }
   
   - (void)drawerWillOpen: (NSNotification*)aNotification
   {
       [mSidebarBookmarksDataSource ensureBookmarks];
   }
   
   - (void)drawerDidOpen:(NSNotification *)aNotification
   {
       // XXXdwh This is temporary.
       [[mSidebarBrowserView getBrowserView] loadURI: [NSURL URLWithString: @"http://tinderbox.mozilla.org/SeaMonkey/panel.html"] flags:NSLoadFlagsNone];
   }
   
   - (void)drawerDidClose:(NSNotification *)aNotification
   {
       // Unload the Gecko web page in "My Panels" to save memory.
       [[mSidebarBrowserView getBrowserView] loadURI: [NSURL URLWithString: @"about:blank"] flags:NSLoadFlagsNone];
 }  }
   
 - (void)setupToolbar  - (void)setupToolbar
Line 58  static NSString *SidebarToolbarItemIdent Line 122  static NSString *SidebarToolbarItemIdent
                                         HomeToolbarItemIdentifier,                                          HomeToolbarItemIdentifier,
                                         LocationToolbarItemIdentifier,                                          LocationToolbarItemIdentifier,
                                         SidebarToolbarItemIdentifier,                                          SidebarToolbarItemIdentifier,
                                           PrintToolbarItemIdentifier,
                                         NSToolbarCustomizeToolbarItemIdentifier,                                          NSToolbarCustomizeToolbarItemIdentifier,
                                         NSToolbarFlexibleSpaceItemIdentifier,                                          NSToolbarFlexibleSpaceItemIdentifier,
                                         NSToolbarSpaceItemIdentifier,                                          NSToolbarSpaceItemIdentifier,
Line 136  static NSString *SidebarToolbarItemIdent Line 201  static NSString *SidebarToolbarItemIdent
         [toolbarItem setMaxSize:NSMakeSize(2560,32)];          [toolbarItem setMaxSize:NSMakeSize(2560,32)];
                   
         [menuFormRep setTarget:self];          [menuFormRep setTarget:self];
        [menuFormRep setAction:@selector(displayLocationSheet:)];        [menuFormRep setAction:@selector(performAppropriateLocationAction)];
         [menuFormRep setTitle:[toolbarItem label]];          [menuFormRep setTitle:[toolbarItem label]];
                   
         [toolbarItem setMenuFormRepresentation:menuFormRep];          [toolbarItem setMenuFormRepresentation:menuFormRep];
                mLocationToolbarItem = toolbarItem;
 
     } else if ( [itemIdent isEqual:PrintToolbarItemIdentifier] ) {
         [toolbarItem setLabel:@"Print"];
         [toolbarItem setPaletteLabel:@"Print"];
         [toolbarItem setToolTip:@"Print this page"];
         [toolbarItem setImage:[NSImage imageNamed:@"print"]];
         [toolbarItem setTarget:self];
         [toolbarItem setAction:@selector(printDocument)];
     } else {      } else {
         toolbarItem = nil;          toolbarItem = nil;
     }      }
Line 165  static NSString *SidebarToolbarItemIdent Line 238  static NSString *SidebarToolbarItemIdent
     return YES;      return YES;
 }  }
         
-(void)updateToolbarItems- (void)updateToolbarItems
 {  {
   [[[self window] toolbar] validateVisibleItems];    [[[self window] toolbar] validateVisibleItems];
 }  }
   
-(void) focusURLBar- (void)performAppropriateLocationAction
 {
     if ( [[[self window] toolbar] isVisible] ) {
         if ( ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconAndLabel) ||
              ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconOnly) ) {
             [self focusURLBar];
         } else {
             [self beginLocationSheet];
         }
     } else {
         [self beginLocationSheet];
     }
 }
 
 - (void)focusURLBar
 {  {
     [mURLBar selectText: self];      [mURLBar selectText: self];
 }  }
   
-(IBAction) back:(id)aSender- (void)beginLocationSheet
 {
     [NSApp beginSheet:  mLocationSheetWindow
        modalForWindow:  [self window]
         modalDelegate:  nil
        didEndSelector:  nil
           contextInfo:  nil];
 }
 
 - (IBAction)endLocationSheet:(id)sender
 {
     [mLocationSheetWindow orderOut:self];
     [NSApp endSheet:mLocationSheetWindow returnCode:1];
     [self loadURL:[NSURL URLWithString:[mLocationSheetURLField stringValue]]];
     
     // Focus and activate our content area.
     [[mBrowserView getBrowserView] setActive: YES];
 }
 
 - (IBAction)goToLocationFromToolbarURLField:(id)sender
 {
     [self loadURL:[NSURL URLWithString:[sender stringValue]]];
     
     // Focus and activate our content area.
     [[mBrowserView getBrowserView] setActive: YES];
 }
 
 - (void)saveDocument: (NSView*)aFilterView filterList: (NSPopUpButton*)aFilterList
 {
     [[mBrowserView getBrowserView] saveDocument: aFilterView filterList: aFilterList];
 }
 
 - (void)printDocument
 {
     [[mBrowserView getBrowserView] printDocument];
 }
 
 - (void)printPreview
 {
     [[mBrowserView getBrowserView] printPreview];
 }
 
 - (void)findInPage
 {
     [[mBrowserView getBrowserView] findInPage];
 }
 
 - (void)findAgain
 {
     [[mBrowserView getBrowserView] findAgain];
 }
 
 - (void)addBookmark
 {
     // XXXdwh Hack.  Just go to the sidebar for now until we get our
     // menu data source going.
     [mSidebarBookmarksDataSource ensureBookmarks];
     [mSidebarBookmarksDataSource addBookmark: self];
 }
 
 - (IBAction)back:(id)aSender
 {  {
   [[mBrowserView getBrowserView] goBack];    [[mBrowserView getBrowserView] goBack];
 }  }
   
-(IBAction) forward:(id)aSender- (IBAction)forward:(id)aSender
 {  {
   [[mBrowserView getBrowserView] goForward];    [[mBrowserView getBrowserView] goForward];
 }  }
   
-(IBAction) reload:(id)aSender- (IBAction)reload:(id)aSender
 {  {
   [[mBrowserView getBrowserView] reload: 0];    [[mBrowserView getBrowserView] reload: 0];
 }  }
   
-(IBAction) stop:(id)aSender- (IBAction)stop:(id)aSender
 {  {
   [[mBrowserView getBrowserView] stop: 0];    [[mBrowserView getBrowserView] stop: 0];
 }  }
   
-(IBAction) home:(id)aSender- (IBAction)home:(id)aSender
 {  {
  NSURL* url = [NSURL URLWithString:@"about:blank"];  [[mBrowserView getBrowserView] loadURI:[NSURL URLWithString:@"about:blank"] flags:NSLoadFlagsNone];
  [[mBrowserView getBrowserView] loadURI:url flags:NSLoadFlagsNone]; 
 }  }
   
-(IBAction) toggleSidebar:(id)aSender- (IBAction)toggleSidebar:(id)aSender
 {  {
    if ( ([mSidebarDrawer state] == NSDrawerClosedState) || ([mSidebarDrawer state] == NSDrawerClosingState) ) {    if ( ([mSidebarDrawer state] == NSDrawerClosedState) || ([mSidebarDrawer state] == NSDrawerClosingState) )  {
         // XXXHack to bypass sidebar crashes.
         [[self window] makeFirstResponder: nil];
         [mSidebarDrawer open];          [mSidebarDrawer open];
     } else {      } else {
         [mSidebarDrawer close];          [mSidebarDrawer close];
Line 212  static NSString *SidebarToolbarItemIdent Line 360  static NSString *SidebarToolbarItemIdent
   
 -(void)loadURL:(NSURL*)aURL  -(void)loadURL:(NSURL*)aURL
 {  {
    if (mInitialized)    if (mInitialized) {
         [[mBrowserView getBrowserView] loadURI:aURL flags:NSLoadFlagsNone];          [[mBrowserView getBrowserView] loadURI:aURL flags:NSLoadFlagsNone];
       }
     else {      else {
         mURL = aURL;          mURL = aURL;
         [mURL retain];          [mURL retain];
     }      }
 }  }
   
   - (void)updateLocationFields:(NSString *)locationString
   {
   /* //commenting this out because it doesn't work right yet.
       if ( [locationString length] > 30 ) {
           [[mLocationToolbarItem menuFormRepresentation] setTitle:
               [NSString stringWithFormat:@"Location: %@...", [locationString substringToIndex:31]]];
       } else {
           [[mLocationToolbarItem menuFormRepresentation] setTitle:
               [NSString stringWithFormat:@"Location: %@", locationString]];
       }
   */
   
       [mURLBar setStringValue:locationString];
       [mLocationSheetURLField setStringValue:locationString];
   
       [[self window] update];
       [[self window] display];
   }
   
   -(void)newTab
   {
       NSTabViewItem* newTab = [[[NSTabViewItem alloc] initWithIdentifier: nil] autorelease];
       [mTabBrowser addTabViewItem: newTab];
       
       MyBrowserView* newView = [[[MyBrowserView alloc] initWithFrame: [mBrowserView frame]] autorelease];
       [newTab setView: newView];
       [newTab setLabel: @"Untitled"];
       
       [[newView getBrowserView] loadURI:[NSURL URLWithString:@"about:blank"] flags:NSLoadFlagsNone];
       
       [mTabBrowser selectLastTabViewItem: self];
       
       if ( [[[self window] toolbar] isVisible] ) {
           if ( ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconAndLabel) ||
                ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconOnly) ) {
               [self focusURLBar];
           } 
       }
       
       //XXXdwh Do this if we ever support auto-hide.
       //if ([mTabBrowser numberOfTabViewItems] == 2)
       //    [mTabBrowser setTabViewType: NSTopTabsBezelBorder];
   }
   
   - (void)tabView:(NSTabView *)aTabView didSelectTabViewItem:(NSTabViewItem *)aTabViewItem
   {
       // Disconnect the old view.
       [mBrowserView disconnectView];
       
       // Connect up the new view
       mBrowserView = [aTabViewItem view];
          
       // Make the new view the primary content area.
       [mBrowserView makePrimaryBrowserView: aTabViewItem urlbar: mURLBar status: mStatus
           progress: mProgress windowController: self];
   }
   
   -(MyBrowserView*)getMyBrowserView
   {
       return mBrowserView;
   }
 @end  @end
   

Removed from v.1.4  
changed lines
  Added in v.1.35


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