Diff for /chimera/MainController.mm between versions 1.33 and 1.46

version 1.33, 2002/03/20 07:34:07 version 1.46, 2002/04/18 15:42:03
Line 44 Line 44
 #include "nsCocoaBrowserService.h"  #include "nsCocoaBrowserService.h"
 #import "AboutBox.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
Line 51  static const char* ioServiceContractID = Line 52  static const char* ioServiceContractID =
 -(id)init  -(id)init
 {  {
     if ( (self = [super init]) ) {      if ( (self = [super init]) ) {
        mSplashScreen = [[SplashScreenWindow alloc] splash];        mSplashScreen = [[SplashScreenWindow alloc] splashImage:nil withStatusRect:NSMakeRect(0,0,0,0)];
     }      }
       mFindDialog = nil;
       mMenuBookmarks = nil;
     return self;      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];  
           
       [mSplashScreen close];
   
     [mBookmarksMenu setAutoenablesItems: NO];      [mBookmarksMenu setAutoenablesItems: NO];
        mMenuBookmarks = new BookmarksService((BookmarksDataSource*)nil);
    mMenuBookmarks = new BookmarksService(nil); 
     mMenuBookmarks->AddObserver();      mMenuBookmarks->AddObserver();
     mMenuBookmarks->ConstructBookmarksMenu(mBookmarksMenu, nsnull);      mMenuBookmarks->ConstructBookmarksMenu(mBookmarksMenu, nsnull);
     BookmarksService::gMainController = self;      BookmarksService::gMainController = self;
Line 95  static const char* ioServiceContractID = Line 98  static const char* ioServiceContractID =
 {  {
   // If we have a key window, have it autosave its dimensions before    // If we have a key window, have it autosave its dimensions before
   // we open a new window.  That ensures the size ends up matching.    // we open a new window.  That ensures the size ends up matching.
  NSWindow* keyWindow = [mApplication keyWindow];  NSWindow* mainWindow = [mApplication mainWindow];
  if (keyWindow)  if ( mainWindow && [mainWindow respondsToSelector:@selector(autosaveWindowFrame)] )
    [[keyWindow windowController] autosaveWindowFrame];    [[mainWindow windowController] autosaveWindowFrame];
   
   // Now open the new window.    // Now open the new window.
   BrowserWindowController* controller = [self openBrowserWindowWithURLString:@"about:blank"];    BrowserWindowController* controller = [self openBrowserWindowWithURLString:@"about:blank"];
Line 106  static const char* ioServiceContractID = Line 109  static const char* ioServiceContractID =
   
 -(IBAction)newTab:(id)aSender  -(IBAction)newTab:(id)aSender
 {  {
    NSWindow* keyWindow = [mApplication keyWindow];  [[[mApplication mainWindow] windowController] newTab];
    if (keyWindow) 
        [[keyWindow windowController] newTab]; 
 }  }
   
 -(IBAction)closeTab:(id)aSender  -(IBAction)closeTab:(id)aSender
 {  {
    NSWindow* keyWindow = [mApplication keyWindow];  [[[mApplication mainWindow] windowController] closeTab];
    if (keyWindow) 
        [[keyWindow windowController] closeTab]; 
 }  }
   
 -(IBAction) previousTab:(id)aSender  -(IBAction) previousTab:(id)aSender
 {  {
    NSWindow* keyWindow = [mApplication keyWindow];  [[[mApplication mainWindow] windowController] previousTab];
    if (keyWindow) 
        [[keyWindow windowController] previousTab]; 
 }  }
   
 -(IBAction) nextTab:(id)aSender;  -(IBAction) nextTab:(id)aSender;
 {  {
    NSWindow* keyWindow = [mApplication keyWindow];        [[[mApplication mainWindow] windowController] nextTab];
    if (keyWindow) 
        [[keyWindow windowController] nextTab]; 
 }  }
   
 -(IBAction) openFile:(id)aSender  -(IBAction) openFile:(id)aSender
Line 151  static const char* ioServiceContractID = Line 146  static const char* ioServiceContractID =
         // ----------------------          // ----------------------
         [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:url];          [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:url];
         // ----------------------          // ----------------------
        NSWindow* keyWindow = [mApplication keyWindow];        NSWindow* mainWindow = [mApplication mainWindow];
        if (keyWindow)        if (mainWindow) {
            return [[keyWindow windowController] loadURL: url];          [[mainWindow windowController] loadURL: url];
           [[[[mainWindow windowController] getMyBrowserView] getBrowserView] setActive: YES];
         }
         else          else
            [self openBrowserWindowWithURL: url];          [self openBrowserWindowWithURL: url];
     }      }
 }  }
   
 -(IBAction) openLocation:(id)aSender  -(IBAction) openLocation:(id)aSender
 {  {
    NSWindow* keyWindow = [mApplication keyWindow];    NSWindow* mainWindow = [mApplication mainWindow];
    if (!keyWindow) {    if (!mainWindow) {
       [self openBrowserWindowWithURLString: @"about:blank"];        [self openBrowserWindowWithURLString: @"about:blank"];
      keyWindow = [mApplication keyWindow];      mainWindow = [mApplication mainWindow];
     }      }
           
    [[keyWindow windowController] performAppropriateLocationAction];    [[mainWindow windowController] performAppropriateLocationAction];
 }  }
   
 -(IBAction) savePage:(id)aSender  -(IBAction) savePage:(id)aSender
 {  {
    NSWindow* keyWindow = [mApplication keyWindow];  [[[mApplication mainWindow] windowController] saveDocument: mFilterView filterList: mFilterList];
    if (keyWindow) 
      [[keyWindow windowController] saveDocument: mFilterView filterList: mFilterList]; 
 }  }
   
 -(IBAction) printPage:(id)aSender  -(IBAction) printPage:(id)aSender
 {  {
    NSWindow* keyWindow = [mApplication keyWindow];  [[[mApplication mainWindow] windowController] printDocument];
    if (keyWindow) 
      [[keyWindow windowController] printDocument]; 
 }  }
   
 -(IBAction) printPreview:(id)aSender  -(IBAction) printPreview:(id)aSender
 {  {
    NSWindow* keyWindow = [mApplication keyWindow];  [[[mApplication mainWindow] windowController] printPreview];
    if (keyWindow) 
      [[keyWindow windowController] printPreview]; 
 }  }
   
 -(IBAction) toggleOfflineMode:(id)aSender  -(IBAction) toggleOfflineMode:(id)aSender
Line 214  static const char* ioServiceContractID = Line 205  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
 {  {
    [[[mApplication keyWindow] windowController] back: aSender];     [[[mApplication mainWindow] windowController] back: aSender]; 
 }  }
   
 -(IBAction) goForward:(id)aSender  -(IBAction) goForward:(id)aSender
 {  {
    [[[mApplication keyWindow] windowController] forward: aSender];     [[[mApplication mainWindow] windowController] forward: aSender]; 
 }  }
   
 -(IBAction) doReload:(id)aSender  -(IBAction) doReload:(id)aSender
 {  {
    [(BrowserWindowController*)([[mApplication keyWindow] windowController]) reload: aSender];     [(BrowserWindowController*)([[mApplication mainWindow] windowController]) reload: aSender]; 
 }  }
   
 -(IBAction) doStop:(id)aSender  -(IBAction) doStop:(id)aSender
 {  {
    [(BrowserWindowController*)([[mApplication keyWindow] windowController]) stop: aSender];     [(BrowserWindowController*)([[mApplication mainWindow] windowController]) stop: aSender]; 
 }  }
   
 -(IBAction) goHome:(id)aSender  -(IBAction) goHome:(id)aSender
 {  {
    [[[mApplication keyWindow] windowController] home: aSender];    [[[mApplication mainWindow] windowController] home: aSender];
 }  }
   
 -(BrowserWindowController*)openBrowserWindowWithURLString: (NSString*)aURL  -(BrowserWindowController*)openBrowserWindowWithURLString: (NSString*)aURL
Line 261  static const char* ioServiceContractID = Line 268  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.
       [[[mApplication mainWindow] windowController] autosaveWindowFrame];
       
     mMenuBookmarks->RemoveObserver();      mMenuBookmarks->RemoveObserver();
     delete mMenuBookmarks;      delete mMenuBookmarks;
     mMenuBookmarks = nsnull;      mMenuBookmarks = nsnull;
Line 278  static const char* ioServiceContractID = Line 289  static const char* ioServiceContractID =
 // Bookmarks menu actions.  // Bookmarks menu actions.
 -(IBAction) addBookmark:(id)aSender  -(IBAction) addBookmark:(id)aSender
 {  {
    NSWindow* keyWindow = [mApplication keyWindow];  [[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: NO];
    if (keyWindow)}
      [[keyWindow windowController] addBookmark];
 -(IBAction) addFolder:(id)aSender
 {
   [[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: YES];
 }
 
 -(IBAction) addSeparator:(id)aSender
 {
 }  }
   
 -(IBAction) openMenuBookmark:(id)aSender  -(IBAction) openMenuBookmark:(id)aSender
 {  {
    NSWindow* keyWindow = [mApplication keyWindow];    NSWindow* mainWind = [mApplication mainWindow];
    if (!keyWindow) {    if (!mainWind) {
         [self openBrowserWindowWithURLString: @"about:blank"];          [self openBrowserWindowWithURLString: @"about:blank"];
        keyWindow = [mApplication keyWindow];        mainWind = [mApplication mainWindow];
     }      }
   
    BookmarksService::OpenMenuBookmark([keyWindow windowController], aSender);    BookmarksService::OpenMenuBookmark([mainWind windowController], aSender);
 }
 
 -(IBAction)manageBookmarks: (id)aSender
 {
   NSWindow* mainWindow = [mApplication mainWindow];
   if (!mainWindow) {
     [self openBrowserWindowWithURLString: @"about:blank"];
     mainWindow = [mApplication mainWindow];
   }
 
   [[mainWindow windowController] manageBookmarks: aSender];
 }  }
   
 - (MVPreferencesController *)preferencesController  - (MVPreferencesController *)preferencesController
Line 314  static const char* ioServiceContractID = Line 343  static const char* ioServiceContractID =
   
 - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename  - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
 {  {
    NSWindow* keyWindow = [mApplication keyWindow];    NSWindow* mainWindow = [mApplication mainWindow];
   
    if (keyWindow) {    if (mainWindow) {
        [[keyWindow windowController] loadURL:[NSURL fileURLWithPath:filename]];        [[mainWindow windowController] loadURL:[NSURL fileURLWithPath:filename]];
     } else {      } else {
         [self openBrowserWindowWithURL:[NSURL fileURLWithPath:filename]];          [self openBrowserWindowWithURL:[NSURL fileURLWithPath:filename]];
     }      }
Line 326  static const char* ioServiceContractID = Line 355  static const char* ioServiceContractID =
           
 }  }
   
   - (IBAction)biggerTextSize:(id)aSender
   {
     [[[mApplication mainWindow] windowController] biggerTextSize];
   }
   
   - (IBAction)smallerTextSize:(id)aSender
   {
     [[[mApplication mainWindow] windowController] smallerTextSize];
   }
   
   - (IBAction)toggleSmoothText:(id)aSender
   {
     // XXXdwh Grab the prefs service and just set the pref directly.
     
   }
   
   
 @end  @end

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


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