Diff for /chimera/MainController.mm between versions 1.29 and 1.39

version 1.29, 2002/03/09 23:16:50 version 1.39, 2002/04/12 19:45:37
Line 42 Line 42
 #include "nsIServiceManager.h"  #include "nsIServiceManager.h"
 #include "nsIIOService.h"  #include "nsIIOService.h"
 #include "nsCocoaBrowserService.h"  #include "nsCocoaBrowserService.h"
   #import "AboutBox.h"
   
   
 static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";  static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
   
 @implementation MainController  @implementation MainController
   
   -(id)init
   {
       if ( (self = [super init]) ) {
           mSplashScreen = [[SplashScreenWindow alloc] splashImage:nil withFade:YES withStatusRect:NSMakeRect(0,0,0,0)];
       }
       mFindDialog = nil;
       mMenuBookmarks = nil;
       return self;
   }
   
 -(void)dealloc  -(void)dealloc
 {  {
     [super dealloc];      [super dealloc];
       [mFindDialog release];
     printf("Main controller died.\n");      printf("Main controller died.\n");
 }  }
   
 -(void)awakeFromNib  -(void)awakeFromNib
{{    
     [self newWindow: self];      [self newWindow: self];
           
       [mSplashScreen close];
   
     [mBookmarksMenu setAutoenablesItems: NO];      [mBookmarksMenu setAutoenablesItems: NO];
       
     mMenuBookmarks = new BookmarksService(nil);      mMenuBookmarks = new BookmarksService(nil);
     mMenuBookmarks->AddObserver();      mMenuBookmarks->AddObserver();
     mMenuBookmarks->ConstructBookmarksMenu(mBookmarksMenu, nsnull);      mMenuBookmarks->ConstructBookmarksMenu(mBookmarksMenu, nsnull);
Line 77  static const char* ioServiceContractID = Line 91  static const char* ioServiceContractID =
     // offline.      // offline.
     if (mOffline)      if (mOffline)
         [mOfflineMenuItem setTitle: @"Go Online"];          [mOfflineMenuItem setTitle: @"Go Online"];
   
 }  }
   
 -(IBAction)newWindow:(id)aSender  -(IBAction)newWindow:(id)aSender
 {  {
    BrowserWindowController* controller = [self openBrowserWindowWithURLString:@"about:blank"];  // If we have a key window, have it autosave its dimensions before
    [controller focusURLBar];  // we open a new window.  That ensures the size ends up matching.
}  NSWindow* keyWindow = [mApplication keyWindow];
   if ( keyWindow && [keyWindow respondsToSelector:@selector(autosaveWindowFrame)] )
     [[keyWindow windowController] autosaveWindowFrame];
 
   // Now open the new window.
   BrowserWindowController* controller = [self openBrowserWindowWithURLString:@"about:blank"];
   [controller focusURLBar];
 }       
   
 -(IBAction)newTab:(id)aSender  -(IBAction)newTab:(id)aSender
 {  {
Line 129  static const char* ioServiceContractID = Line 151  static const char* ioServiceContractID =
         if ([urlArray count] == 0)          if ([urlArray count] == 0)
             return;              return;
         NSURL* url = [urlArray objectAtIndex: 0];          NSURL* url = [urlArray objectAtIndex: 0];
           // ----------------------
           [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:url];
           // ----------------------
         NSWindow* keyWindow = [mApplication keyWindow];          NSWindow* keyWindow = [mApplication keyWindow];
         if (keyWindow)          if (keyWindow)
             return [[keyWindow windowController] loadURL: url];              return [[keyWindow windowController] loadURL: url];
Line 192  static const char* ioServiceContractID = Line 217  static const char* ioServiceContractID =
 }  }
   
 // Edit menu actions.  // Edit menu actions.
   
   
   //
   // -findInPage
   //
   // Called in response to "Find" in edit menu. Opens the find dialog. We only keep
   // one around for the whole app to use, showing/hiding as we see fit.
   //
 -(IBAction) findInPage:(id)aSender  -(IBAction) findInPage:(id)aSender
 {  {
    NSWindow* keyWindow = [mApplication keyWindow];  if ( !mFindDialog )
    if (keyWindow)     mFindDialog = [[FindDlgController alloc] initWithWindowNibName: @"FindDialog"];
      [[keyWindow windowController] findInPage];  [mFindDialog showWindow:self];
 }  }
   
   
   //
   // -findAgain
   //
   // Called in response to "Find Again" in edit menu. Tells the find controller
   // to find the next occurrance of what's already been found.
   //
 -(IBAction) findAgain:(id)aSender  -(IBAction) findAgain:(id)aSender
 {  {
    NSWindow* keyWindow = [mApplication keyWindow];  if ( mFindDialog )
    if (keyWindow)    [mFindDialog findAgain:aSender];
      [[keyWindow windowController] findAgain];  else
     NSBeep();
 }  }
   
 -(IBAction) goBack:(id)aSender  -(IBAction) goBack:(id)aSender
Line 239  static const char* ioServiceContractID = Line 280  static const char* ioServiceContractID =
 -(BrowserWindowController*)openBrowserWindowWithURL: (NSURL*)aURL  -(BrowserWindowController*)openBrowserWindowWithURL: (NSURL*)aURL
 {  {
         BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];          BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
    [browser loadURL: aURL];  [browser loadURL: aURL];
         [browser showWindow: self];          [browser showWindow: self];
    return browser;  return browser;
 }  }
   
 -(void)applicationWillTerminate: (NSNotification*)aNotification  -(void)applicationWillTerminate: (NSNotification*)aNotification
 {  {
     printf("Termination notification.\n");      printf("Termination notification.\n");
   
       // Autosave one of the windows.
       NSWindow* keyWindow = [mApplication keyWindow];
       if (keyWindow)
         [[keyWindow windowController] autosaveWindowFrame];
       
     mMenuBookmarks->RemoveObserver();      mMenuBookmarks->RemoveObserver();
     delete mMenuBookmarks;      delete mMenuBookmarks;
     mMenuBookmarks = nsnull;      mMenuBookmarks = nsnull;
Line 285  static const char* ioServiceContractID = Line 332  static const char* ioServiceContractID =
     [[self preferencesController] showPreferences:nil] ;      [[self preferencesController] showPreferences:nil] ;
 }  }
   
   - (IBAction)showAboutBox:(id)sender
   {
       [[AboutBox sharedInstance] showPanel:sender];
   }
   
   - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
   {
       NSWindow* keyWindow = [mApplication keyWindow];
   
       if (keyWindow) {
           [[keyWindow windowController] loadURL:[NSURL fileURLWithPath:filename]];
       } else {
           [self openBrowserWindowWithURL:[NSURL fileURLWithPath:filename]];
       }
       
       return YES;
       
   }
   
   
 @end  @end

Removed from v.1.29  
changed lines
  Added in v.1.39


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