mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-22 00:19:24 +03:00
c24c9e2003
Conflicts: native/atom_cef_client.h native/atom_cef_client_mac.mm src/app/atom.coffee
55 lines
2.1 KiB
Plaintext
55 lines
2.1 KiB
Plaintext
#import <AppKit/AppKit.h>
|
|
#import "include/cef_browser.h"
|
|
#import "include/cef_frame.h"
|
|
#import "native/atom_cef_client.h"
|
|
#import "atom_application.h"
|
|
#import "atom_window_controller.h"
|
|
|
|
void AtomCefClient::Open(std::string path) {
|
|
NSString *pathString = [NSString stringWithCString:path.c_str() encoding:NSUTF8StringEncoding];
|
|
[(AtomApplication *)[AtomApplication sharedApplication] open:pathString];
|
|
}
|
|
|
|
void AtomCefClient::Open() {
|
|
NSOpenPanel *panel = [NSOpenPanel openPanel];
|
|
[panel setCanChooseDirectories:YES];
|
|
if ([panel runModal] == NSFileHandlingPanelOKButton) {
|
|
NSURL *url = [[panel URLs] lastObject];
|
|
Open([[url path] UTF8String]);
|
|
}
|
|
}
|
|
|
|
void AtomCefClient::NewWindow() {
|
|
[(AtomApplication *)[AtomApplication sharedApplication] open:nil];
|
|
}
|
|
|
|
void AtomCefClient::Confirm(int replyId,
|
|
std::string message,
|
|
std::string detailedMessage,
|
|
std::vector<std::string> buttonLabels,
|
|
CefRefPtr<CefBrowser> browser) {
|
|
NSAlert *alert = [[[NSAlert alloc] init] autorelease];
|
|
[alert setMessageText:[NSString stringWithCString:message.c_str() encoding:NSUTF8StringEncoding]];
|
|
[alert setInformativeText:[NSString stringWithCString:detailedMessage.c_str() encoding:NSUTF8StringEncoding]];
|
|
|
|
for (int i = 0; i < buttonLabels.size(); i++) {
|
|
NSString *title = [NSString stringWithCString:buttonLabels[i].c_str() encoding:NSUTF8StringEncoding];
|
|
NSButton *button = [alert addButtonWithTitle:title];
|
|
[button setTag:i];
|
|
}
|
|
|
|
NSUInteger clickedButtonTag = [alert runModal];
|
|
|
|
CefRefPtr<CefProcessMessage> replyMessage = CefProcessMessage::Create("reply");
|
|
CefRefPtr<CefListValue> replyArguments = replyMessage->GetArgumentList();
|
|
replyArguments->SetSize(2);
|
|
replyArguments->SetInt(0, replyId);
|
|
replyArguments->SetInt(1, clickedButtonTag);
|
|
browser->SendProcessMessage(PID_RENDERER, replyMessage);
|
|
}
|
|
|
|
void AtomCefClient::ToggleDevTools(CefRefPtr<CefBrowser> browser) {
|
|
AtomWindowController *windowController = [[browser->GetHost()->GetWindowHandle() window] windowController];
|
|
[windowController toggleDevTools];
|
|
}
|