File:  [mozdev] / chimera / MainController.mm
Revision 1.8: download - view: text, annotated - select for diffs - revision graph
Sun Feb 3 05:53:12 2002 UTC (17 years, 9 months ago) by hyatt
Branches: MAIN
CVS tags: HEAD
A huge amount of code for File/Save As...

    1: /*
    2:  *  MainController.mm
    3:  */
    4: 
    5: #import "MainController.h"
    6: #import "BrowserWindowController.h"
    7: 
    8: @implementation MainController
    9: 
   10: -(void)awakeFromNib
   11: {
   12:     [self newWindow: self];
   13: }
   14: 
   15: -(IBAction)newWindow:(id)aSender
   16: {
   17:     BrowserWindowController* controller = [self openBrowserWindowWithURLString:@"about:blank"];
   18:     [controller focusURLBar];
   19: }
   20: 
   21: -(IBAction) openFile:(id)aSender
   22: {
   23:     NSOpenPanel* openPanel = [[NSOpenPanel alloc] init];
   24:     [openPanel setCanChooseFiles: YES];
   25:     [openPanel setCanChooseDirectories: NO];
   26:     [openPanel setAllowsMultipleSelection: NO];
   27:     NSArray* array = [NSArray arrayWithObjects: @"htm",@"html",@"shtml",@"xhtml",@"xml",
   28:                                                 @"txt",@"text",
   29:                                                 @"gif",@"jpg",@"jpeg",@"png",@"bmp",
   30:                                                 nil];
   31:     int result = [openPanel runModalForTypes: array];
   32:     if (result == NSOKButton) {
   33:         NSArray* urlArray = [openPanel URLs];
   34:         if ([urlArray count] == 0)
   35:             return;
   36:         NSURL* url = [urlArray objectAtIndex: 0];
   37:         NSWindow* keyWindow = [mApplication keyWindow];
   38:         if (keyWindow)
   39:             return [[keyWindow windowController] loadURL: url];
   40:         else
   41:             [self openBrowserWindowWithURL: url];
   42:     }
   43: }
   44: 
   45: -(IBAction) openLocation:(id)aSender
   46: {
   47:     NSWindow* keyWindow = [mApplication keyWindow];
   48:     if (!keyWindow) {
   49:       [self openBrowserWindowWithURLString: @"about:blank"];
   50:       keyWindow = [mApplication keyWindow];
   51:     }
   52:     
   53:     [[keyWindow windowController] performAppropriateLocationAction];
   54: }
   55: 
   56: -(IBAction) savePage:(id)aSender
   57: {
   58:     NSWindow* keyWindow = [mApplication keyWindow];
   59:     if (keyWindow)
   60:       [[keyWindow windowController] saveDocument: mFilterView filterList: mFilterList];
   61: }
   62: 
   63: -(IBAction) toggleOfflineMode:(id)aSender
   64: {
   65:   // XXXdwh Write me!
   66: }
   67: 
   68: -(IBAction) back:(id)aSender
   69: {
   70:     [[[mApplication keyWindow] windowController] back: aSender]; 
   71: }
   72: 
   73: -(IBAction) forward:(id)aSender
   74: {
   75:     [[[mApplication keyWindow] windowController] forward: aSender]; 
   76: }
   77: 
   78: -(IBAction) reload:(id)aSender
   79: {
   80:     [[[mApplication keyWindow] windowController] reload: aSender]; 
   81: }
   82: 
   83: -(IBAction) stop:(id)aSender
   84: {
   85:     [[[mApplication keyWindow] windowController] stop: aSender]; 
   86: }
   87: 
   88: -(IBAction) home:(id)aSender
   89: {
   90:     [[[mApplication keyWindow] windowController] home: aSender];
   91: }
   92: 
   93: -(BrowserWindowController*)openBrowserWindowWithURLString: (NSString*)aURL
   94: {
   95:     return [self openBrowserWindowWithURL: [NSURL URLWithString:aURL]];
   96: }
   97: 
   98: -(BrowserWindowController*)openBrowserWindowWithURL: (NSURL*)aURL
   99: {
  100: 	BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
  101:     [browser loadURL: aURL];
  102: 	[browser showWindow: self];
  103:     return browser;
  104: }
  105: 
  106: @end

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