Annotation of chimera/MainController.mm, revision 1.9

1.3       macserv     1: /*
                      2:  *  MainController.mm
                      3:  */
1.1       hyatt       4: 
                      5: #import "MainController.h"
                      6: #import "BrowserWindowController.h"
                      7: 
                      8: @implementation MainController
                      9: 
                     10: -(void)awakeFromNib
                     11: {
1.4       hyatt      12:     [self newWindow: self];
1.1       hyatt      13: }
                     14: 
                     15: -(IBAction)newWindow:(id)aSender
                     16: {
1.5       hyatt      17:     BrowserWindowController* controller = [self openBrowserWindowWithURLString:@"about:blank"];
1.4       hyatt      18:     [controller focusURLBar];
                     19: }
                     20: 
                     21: -(IBAction) openFile:(id)aSender
                     22: {
1.5       hyatt      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:     }
1.4       hyatt      43: }
                     44: 
                     45: -(IBAction) openLocation:(id)aSender
                     46: {
                     47:     NSWindow* keyWindow = [mApplication keyWindow];
                     48:     if (!keyWindow) {
1.5       hyatt      49:       [self openBrowserWindowWithURLString: @"about:blank"];
1.4       hyatt      50:       keyWindow = [mApplication keyWindow];
                     51:     }
                     52:     
1.6       macserv    53:     [[keyWindow windowController] performAppropriateLocationAction];
1.1       hyatt      54: }
                     55: 
1.7       hyatt      56: -(IBAction) savePage:(id)aSender
                     57: {
                     58:     NSWindow* keyWindow = [mApplication keyWindow];
                     59:     if (keyWindow)
1.8       hyatt      60:       [[keyWindow windowController] saveDocument: mFilterView filterList: mFilterList];
1.7       hyatt      61: }
                     62: 
1.9     ! hyatt      63: -(IBAction) printPage:(id)aSender
        !            64: {
        !            65:     NSWindow* keyWindow = [mApplication keyWindow];
        !            66:     if (keyWindow)
        !            67:       [[keyWindow windowController] printDocument];
        !            68: }
        !            69: 
1.7       hyatt      70: -(IBAction) toggleOfflineMode:(id)aSender
                     71: {
                     72:   // XXXdwh Write me!
                     73: }
                     74: 
1.2       hyatt      75: -(IBAction) back:(id)aSender
                     76: {
                     77:     [[[mApplication keyWindow] windowController] back: aSender]; 
                     78: }
                     79: 
                     80: -(IBAction) forward:(id)aSender
                     81: {
                     82:     [[[mApplication keyWindow] windowController] forward: aSender]; 
                     83: }
                     84: 
                     85: -(IBAction) reload:(id)aSender
                     86: {
                     87:     [[[mApplication keyWindow] windowController] reload: aSender]; 
                     88: }
                     89: 
                     90: -(IBAction) stop:(id)aSender
                     91: {
                     92:     [[[mApplication keyWindow] windowController] stop: aSender]; 
                     93: }
                     94: 
                     95: -(IBAction) home:(id)aSender
                     96: {
                     97:     [[[mApplication keyWindow] windowController] home: aSender];
                     98: }
                     99: 
1.5       hyatt     100: -(BrowserWindowController*)openBrowserWindowWithURLString: (NSString*)aURL
                    101: {
                    102:     return [self openBrowserWindowWithURL: [NSURL URLWithString:aURL]];
                    103: }
                    104: 
                    105: -(BrowserWindowController*)openBrowserWindowWithURL: (NSURL*)aURL
1.1       hyatt     106: {
1.3       macserv   107:        BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
1.5       hyatt     108:     [browser loadURL: aURL];
1.3       macserv   109:        [browser showWindow: self];
1.4       hyatt     110:     return browser;
1.1       hyatt     111: }
                    112: 
                    113: @end

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