mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
💄
This commit is contained in:
@@ -5,10 +5,11 @@
|
||||
#import <WebKit/WebKit.h>
|
||||
|
||||
@interface AtomController ()
|
||||
- (void)createWebView;
|
||||
|
||||
@property (nonatomic, retain) JSCocoa *jscocoa;
|
||||
@property (nonatomic, retain, readwrite) NSString *url;
|
||||
@property (nonatomic, retain, readwrite) NSString *bootstrapScript;
|
||||
|
||||
@end
|
||||
|
||||
@interface WebView (Atom)
|
||||
@@ -17,26 +18,18 @@
|
||||
- (void)startDebuggingJavaScript:(id)sender;
|
||||
@end
|
||||
|
||||
@interface AtomController ()
|
||||
- (void)createWebView;
|
||||
|
||||
@property (nonatomic, retain) JSCocoa *jscocoa;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AtomController
|
||||
|
||||
@synthesize
|
||||
webView = _webView,
|
||||
jscocoa = _jscocoa,
|
||||
url = _url,
|
||||
bootstrapScript = _bootstrapScript;
|
||||
@synthesize webView = _webView;
|
||||
@synthesize jscocoa = _jscocoa;
|
||||
@synthesize url = _url;
|
||||
@synthesize bootstrapScript = _bootstrapScript;
|
||||
|
||||
- (void)dealloc {
|
||||
[self.jscocoa unlinkAllReferences];
|
||||
[self.jscocoa garbageCollect];
|
||||
self.jscocoa = nil;
|
||||
self.webView = nil;;
|
||||
self.webView = nil;
|
||||
self.bootstrapScript = nil;
|
||||
self.url = nil;
|
||||
|
||||
@@ -60,6 +53,18 @@
|
||||
return [self initWithBootstrapScript:@"bootstrap" url:url];
|
||||
}
|
||||
|
||||
- (void)windowDidLoad {
|
||||
[super windowDidLoad];
|
||||
|
||||
[self.window setDelegate:self];
|
||||
[self.window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||
|
||||
[self setShouldCascadeWindows:YES];
|
||||
[self setWindowFrameAutosaveName:@"atomController"];
|
||||
|
||||
[self createWebView];
|
||||
}
|
||||
|
||||
- (BOOL)handleInputEvent:(NSEvent *)event {
|
||||
BOOL shouldReload = [event modifierFlags] & NSCommandKeyMask && [[event charactersIgnoringModifiers] hasPrefix:@"r"];
|
||||
if (shouldReload) {
|
||||
@@ -99,32 +104,13 @@
|
||||
[[self.webView inspector] showConsole:self];
|
||||
}
|
||||
|
||||
- (JSValueRefAndContextRef)jsWindow {
|
||||
JSValueRef window = [self.jscocoa evalJSString:@"window"];
|
||||
JSValueRefAndContextRef windowWithContext = {window, self.jscocoa.ctx};
|
||||
return windowWithContext;
|
||||
}
|
||||
|
||||
- (void)reload {
|
||||
[self.webView removeFromSuperview];
|
||||
[self createWebView];
|
||||
}
|
||||
|
||||
- (void)windowDidLoad {
|
||||
[super windowDidLoad];
|
||||
|
||||
[self.window setDelegate:self];
|
||||
[self.window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||
|
||||
[self setShouldCascadeWindows:YES];
|
||||
[self setWindowFrameAutosaveName:@"atomController"];
|
||||
|
||||
[self createWebView];
|
||||
}
|
||||
|
||||
- (void)close {
|
||||
[(AtomApp *)NSApp removeController:self];
|
||||
[self.jscocoa callJSFunctionNamed:@"triggerEvent" withArguments:@"window:close", nil, false, nil];
|
||||
[super close];
|
||||
}
|
||||
|
||||
@@ -132,6 +118,12 @@
|
||||
return PROJECT_DIR;
|
||||
}
|
||||
|
||||
- (JSValueRefAndContextRef)jsWindow {
|
||||
JSValueRef window = [self.jscocoa evalJSString:@"window"];
|
||||
JSValueRefAndContextRef windowWithContext = {window, self.jscocoa.ctx};
|
||||
return windowWithContext;
|
||||
}
|
||||
|
||||
#pragma mark NSWindowDelegate
|
||||
- (BOOL)windowShouldClose:(id)sender {
|
||||
[self close];
|
||||
|
||||
Reference in New Issue
Block a user