Diff for /chimera/MainController.mm between versions 1.2 and 1.23

version 1.2, 2002/01/29 19:53:45 version 1.23, 2002/02/11 07:22:13
Line 1 Line 1
///*
//  MainController.mm *  MainController.mm
//  Chimera */
// 
//  Created by David Hyatt on Tue Jan 29 2002. 
//  Copyright (c) 2001 __MyCompanyName__. All rights reserved. 
// 
   
 #import "MainController.h"  #import "MainController.h"
 #import "BrowserWindowController.h"  #import "BrowserWindowController.h"
   #include "BookmarksService.h"
   #include "nsCOMPtr.h"
   #include "nsIServiceManager.h"
   #include "nsIIOService.h"
   #include "nsCocoaBrowserService.h"
   
   static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
   
 @implementation MainController  @implementation MainController
   
   -(void)dealloc
   {
       [super dealloc];
       printf("Main controller died.\n");
   }
   
 -(void)awakeFromNib  -(void)awakeFromNib
 {  {
  NSLog(@"HELLO?");    [self newWindow: self];
  [self newWindow: nil];    
     [mBookmarksMenu setAutoenablesItems: NO];
     
     mMenuBookmarks = new BookmarksService(nil);
     mMenuBookmarks->AddObserver();
     mMenuBookmarks->ConstructBookmarksMenu(mBookmarksMenu, nsnull);
     BookmarksService::gMainController = self;
     
     // Initialize offline mode.
     mOffline = NO;
     nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
     if (!ioService)
         return;
     PRBool offline = PR_FALSE;
     ioService->GetOffline(&offline);
     mOffline = offline;
     
     // Set the menu item's text to "Go Online" if we're currently
     // offline.
     if (mOffline)
         [mOfflineMenuItem setTitle: @"Go Online"];
 }  }
   
 -(IBAction)newWindow:(id)aSender  -(IBAction)newWindow:(id)aSender
 {  {
  [self openBrowserWindowWithURL: @"about:blank"];    BrowserWindowController* controller = [self openBrowserWindowWithURLString:@"about:blank"];
     [controller focusURLBar];
 }
 
 -(IBAction)newTab:(id)aSender
 {
     NSWindow* keyWindow = [mApplication keyWindow];
     if (keyWindow)
       [[keyWindow windowController] newTab];
 }
 
 -(IBAction) openFile:(id)aSender
 {
     NSOpenPanel* openPanel = [[NSOpenPanel alloc] init];
     [openPanel setCanChooseFiles: YES];
     [openPanel setCanChooseDirectories: NO];
     [openPanel setAllowsMultipleSelection: NO];
     NSArray* array = [NSArray arrayWithObjects: @"htm",@"html",@"shtml",@"xhtml",@"xml",
                                                 @"txt",@"text",
                                                 @"gif",@"jpg",@"jpeg",@"png",@"bmp",
                                                 nil];
     int result = [openPanel runModalForTypes: array];
     if (result == NSOKButton) {
         NSArray* urlArray = [openPanel URLs];
         if ([urlArray count] == 0)
             return;
         NSURL* url = [urlArray objectAtIndex: 0];
         NSWindow* keyWindow = [mApplication keyWindow];
         if (keyWindow)
             return [[keyWindow windowController] loadURL: url];
         else
             [self openBrowserWindowWithURL: url];
     }
 }
 
 -(IBAction) openLocation:(id)aSender
 {
     NSWindow* keyWindow = [mApplication keyWindow];
     if (!keyWindow) {
       [self openBrowserWindowWithURLString: @"about:blank"];
       keyWindow = [mApplication keyWindow];
     }
     
     [[keyWindow windowController] performAppropriateLocationAction];
 }
 
 -(IBAction) savePage:(id)aSender
 {
     NSWindow* keyWindow = [mApplication keyWindow];
     if (keyWindow)
       [[keyWindow windowController] saveDocument: mFilterView filterList: mFilterList];
 }
 
 -(IBAction) printPage:(id)aSender
 {
     NSWindow* keyWindow = [mApplication keyWindow];
     if (keyWindow)
       [[keyWindow windowController] printDocument];
 }
 
 -(IBAction) printPreview:(id)aSender
 {
     NSWindow* keyWindow = [mApplication keyWindow];
     if (keyWindow)
       [[keyWindow windowController] printPreview];
 }  }
   
-(IBAction) back:(id)aSender-(IBAction) toggleOfflineMode:(id)aSender
 {
     nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
     if (!ioService)
         return;
     PRBool offline = PR_FALSE;
     ioService->GetOffline(&offline);
     ioService->SetOffline(!offline);
     mOffline = !offline;
     
     // Update the menu item text.
     // Set the menu item's text to "Go Online" if we're currently
     // offline.
     if (mOffline)
         [mOfflineMenuItem setTitle: @"Go Online"];
     else
         [mOfflineMenuItem setTitle: @"Work Offline"];
         
     // Indicate that we are working offline.
     [[NSNotificationCenter defaultCenter] postNotificationName:@"offlineModeChanged" object:nil];
 }
 
 // Edit menu actions.
 -(IBAction) findInPage:(id)aSender
 {
     NSWindow* keyWindow = [mApplication keyWindow];
     if (keyWindow)
       [[keyWindow windowController] findInPage];
 }
 
 -(IBAction) findAgain:(id)aSender
 {
     NSWindow* keyWindow = [mApplication keyWindow];
     if (keyWindow)
       [[keyWindow windowController] findAgain];
 }
 
 -(IBAction) goBack:(id)aSender
 {  {
     [[[mApplication keyWindow] windowController] back: aSender];       [[[mApplication keyWindow] windowController] back: aSender]; 
 }  }
   
-(IBAction) forward:(id)aSender-(IBAction) goForward:(id)aSender
 {  {
     [[[mApplication keyWindow] windowController] forward: aSender];       [[[mApplication keyWindow] windowController] forward: aSender]; 
 }  }
   
-(IBAction) reload:(id)aSender-(IBAction) doReload:(id)aSender
 {  {
    [[[mApplication keyWindow] windowController] reload: aSender];     [(BrowserWindowController*)([[mApplication keyWindow] windowController]) reload: aSender]; 
 }  }
   
-(IBAction) stop:(id)aSender-(IBAction) doStop:(id)aSender
 {  {
    [[[mApplication keyWindow] windowController] stop: aSender];     [(BrowserWindowController*)([[mApplication keyWindow] windowController]) stop: aSender]; 
 }  }
   
-(IBAction) home:(id)aSender-(IBAction) goHome:(id)aSender
 {  {
     [[[mApplication keyWindow] windowController] home: aSender];      [[[mApplication keyWindow] windowController] home: aSender];
 }  }
   
-(void)openBrowserWindowWithURL: (NSString*)aURL-(BrowserWindowController*)openBrowserWindowWithURLString: (NSString*)aURL
 {  {
  NSLog(@"YARF!");    return [self openBrowserWindowWithURL: [NSURL URLWithString:aURL]];
  BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"]; 
  [browser loadURL: aURL]; 
  [browser showWindow: self]; 
 }  }
   
   -(BrowserWindowController*)openBrowserWindowWithURL: (NSURL*)aURL
   {
           BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
       [browser loadURL: aURL];
           [browser showWindow: self];
       return browser;
   }
   
   -(void)applicationWillTerminate: (NSNotification*)aNotification
   {
       mMenuBookmarks->RemoveObserver();
       delete mMenuBookmarks;
       nsCocoaBrowserService::TermEmbedding();
   }
   
   // Bookmarks menu actions.
   -(IBAction) addBookmark:(id)aSender
   {
       NSWindow* keyWindow = [mApplication keyWindow];
       if (keyWindow)
         [[keyWindow windowController] addBookmark];
   }
   
   -(IBAction) openMenuBookmark:(id)aSender
   {
       NSWindow* keyWindow = [mApplication keyWindow];
       if (!keyWindow) {
           [self openBrowserWindowWithURLString: @"about:blank"];
           keyWindow = [mApplication keyWindow];
       }
   
       BookmarksService::OpenMenuBookmark([keyWindow windowController], aSender);
   }
 @end  @end

Removed from v.1.2  
changed lines
  Added in v.1.23


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