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

version 1.2, 2002/01/29 19:53:45 version 1.15, 2002/02/05 06:19:25
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 "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)awakeFromNib  -(void)awakeFromNib
 {  {
  NSLog(@"HELLO?");    [self newWindow: self];
  [self newWindow: nil];    
     // 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) 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) 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
 {
 
 }  }
   
 -(IBAction) back:(id)aSender  -(IBAction) back:(id)aSender
Line 47 Line 141
     [[[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
   {
       nsCocoaBrowserService::TermEmbedding();
   }
 @end  @end

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


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