mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
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:
67
Atom/Classes/AtomController.m
Normal file
67
Atom/Classes/AtomController.m
Normal 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
|
||||
Reference in New Issue
Block a user