Kind of starting from scratch.

Recreated the project as an xcode 4 project.
Key Bindings are working and reloading.
Got rid of everything that wasn't being used right now.
This commit is contained in:
Corey Johnson
2011-10-26 11:12:18 -07:00
parent e64a0e64a1
commit 003effe5fd
48 changed files with 735 additions and 8868 deletions

View File

@@ -0,0 +1,67 @@
#import "AtomController.h"
#import "AtomApp.h"
#import <WebKit/WebKit.h>
#import "JSCocoa.h"
@implementation AtomController
@synthesize webView, URL;
- (void)dealloc {
[jscocoa unlinkAllReferences];
[jscocoa garbageCollect];
[jscocoa release]; jscocoa = nil;
[webView release];
[URL release];
[super dealloc];
}
- (id)initWithURL:(NSString *)_URL {
self = [super initWithWindowNibName:@"AtomWindow"];
self.URL = _URL;
return self;
}
- (void)windowDidLoad {
[super windowDidLoad];
[webView setUIDelegate:self];
[self setShouldCascadeWindows:YES];
[self setWindowFrameAutosaveName:@"atomController"];
if (self.URL) {
[webView setMainFrameURL:self.URL];
}
else {
jscocoa = [[JSCocoa alloc] initWithGlobalContext:[[webView mainFrame] globalContext]];
[jscocoa setObject:self withName:@"atomController"];
NSURL *resourceURL = [[NSBundle mainBundle] resourceURL];
NSURL *indexURL = [resourceURL URLByAppendingPathComponent:@"index.html"];
NSURLRequest *request = [NSURLRequest requestWithURL:indexURL];
[[webView mainFrame] loadRequest:request];
}
}
- (void)close {
[(AtomApp *)NSApp removeController:self];
[super close];
}
- (BOOL)handleKeyEvent:(NSEvent *)event {
// ICKY: Using a global function defined in App.js to deal with key events
JSValueRef returnValue = [jscocoa callJSFunctionNamed:@"handleKeyEvent" withArguments:event, nil];
return [jscocoa toBool:returnValue];
}
// WebUIDelegate Protocol
- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems {
return defaultMenuItems;
}
@end