Stub atom.open and atom.quit

This commit is contained in:
Corey Johnson
2012-02-22 15:52:30 -08:00
parent e0a8bc77a1
commit b8ca0b07d0
4 changed files with 29 additions and 13 deletions

View File

@@ -7,6 +7,7 @@
BOOL handlingSendEvent_;
}
- (void)open:(NSString *)path;
- (IBAction)runSpecs:(id)sender;
@end

View File

@@ -6,13 +6,15 @@
@implementation Atom
+ (NSApplication *)sharedApplication {
// Populate the settings based on command line arguments.
CefSettings settings;
AppGetSettings(settings);
// Initialize CEF.
CefRefPtr<CefApp> app;
CefInitialize(settings, app);
if (!NSApp) {
// Populate the settings based on command line arguments.
CefSettings settings;
AppGetSettings(settings);
// Initialize CEF.
CefRefPtr<CefApp> app;
CefInitialize(settings, app);
}
return [super sharedApplication];
}
@@ -30,10 +32,11 @@
[super sendEvent:event];
}
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
- (void)open:(NSString *)path {
}
- (IBAction)runSpecs:(id)sender {
[[AtomController alloc] initForSpecs];
}

View File

@@ -1,5 +1,6 @@
#import "native_handler.h"
#import "include/cef.h"
#import "Atom.h"
NSString *stringFromCefV8Value(const CefRefPtr<CefV8Value>& value) {
std::string cc_value = value->GetStringValue().ToString();
@@ -9,7 +10,7 @@ NSString *stringFromCefV8Value(const CefRefPtr<CefV8Value>& value) {
NativeHandler::NativeHandler() : CefV8Handler() {
m_object = CefV8Value::CreateObject(NULL);
const char *functionNames[] = {"exists", "read", "absolute", "list"};
const char *functionNames[] = {"exists", "read", "absolute", "list", "open", "terminate"};
NSUInteger arrayLength = sizeof(functionNames) / sizeof(const char *);
for (NSUInteger i = 0; i < arrayLength; i++) {
const char *functionName = functionNames[i];
@@ -86,6 +87,16 @@ bool NativeHandler::Execute(const CefString& name,
return true;
}
else if (name == "open") {
NSString *path = stringFromCefV8Value(arguments[0]);
[NSApp open:path];
return true;
}
else if (name == "quit") {
[NSApp terminate:nil];
return true;
}
return false;
};

View File

@@ -19,10 +19,11 @@ class App
@globalKeymap.bindKey(selector, pattern, eventName)
open: (url) ->
OSX.NSApp.open url
$native.open url
quit: ->
OSX.NSApp.terminate null
$native.terminate null
windows: ->
controller.jsWindow for controller in OSX.NSApp.controllers
# controller.jsWindow for controller in OSX.NSApp.controllers
[]