v8::Handle<v8::Value> ShowMessageBox(const v8::Arguments &args) {
v8::HandleScope scope;
- if (!args[0]->IsObject() || // window
- !args[1]->IsNumber() || // type
- !args[2]->IsArray() || // buttons
- !args[3]->IsString() || // title
- !args[4]->IsString() || // message
- !args[5]->IsString()) // detail
+ if (!args[0]->IsNumber() || // type
+ !args[1]->IsArray() || // buttons
+ !args[2]->IsString() || // title
+ !args[3]->IsString() || // message
+ !args[4]->IsString()) // detail
return node::ThrowTypeError("Bad argument");
- Window* window = Window::Unwrap<Window>(args[0]->ToObject());
- if (!window || !window->window())
- return node::ThrowError("Invalid window");
-
- gfx::NativeWindow owning_window = window->window()->GetNativeWindow();
-
- MessageBoxType type = (MessageBoxType)(args[1]->IntegerValue());
+ MessageBoxType type = (MessageBoxType)(args[0]->IntegerValue());
std::vector<std::string> buttons;
- v8::Handle<v8::Array> v8_buttons = v8::Handle<v8::Array>::Cast(args[2]);
+ v8::Handle<v8::Array> v8_buttons = v8::Handle<v8::Array>::Cast(args[1]);
for (uint32_t i = 0; i < v8_buttons->Length(); ++i)
buttons.push_back(*v8::String::Utf8Value(v8_buttons->Get(i)));
- std::string title(*v8::String::Utf8Value(args[3]));
- std::string message(*v8::String::Utf8Value(args[4]));
- std::string detail(*v8::String::Utf8Value(args[5]));
+ std::string title(*v8::String::Utf8Value(args[2]));
+ std::string message(*v8::String::Utf8Value(args[3]));
+ std::string detail(*v8::String::Utf8Value(args[4]));
- int result = atom::ShowMessageBox(
- owning_window, type, buttons, title, message, detail);
- return v8::Integer::New(result);
+ int chosen = atom::ShowMessageBox(type, buttons, title, message, detail);
+ return scope.Close(v8::Integer::New(chosen));
}
FileDialog::FileDialog(v8::Handle<v8::Object> wrapper)
openMultiFiles: (args...) ->
selectFileWrap args..., 4, 'Open Files'
- showMessageBox: (window, options) ->
- throw new TypeError('Need Window object') unless window.constructor is BrowserWindow
-
- options = {} unless options?
+ showMessageBox: (options) ->
+ options = type: 'none' unless options?
options.type = options.type ? 'none'
options.type = messageBoxTypes.indexOf options.type
throw new TypeError('Invalid message box type') unless options.type > -1
options.message = options.message ? ''
options.detail = options.detail ? ''
- binding.showMessageBox window, options.type, options.buttons,
+ binding.showMessageBox options.type, options.buttons,
String(options.title),
String(options.message),
String(options.detail)
#include <string>
#include <vector>
-#include "ui/gfx/native_widget_types.h"
-
namespace atom {
enum MessageBoxType {
MESSAGE_BOX_TYPE_WARNING
};
-int ShowMessageBox(gfx::NativeWindow parent,
- MessageBoxType type,
+int ShowMessageBox(MessageBoxType type,
const std::vector<std::string>& buttons,
const std::string& title,
const std::string& message,