dialog.showMessageBox doesn't require window as parameter any more.
This commit is contained in:
parent
7e11743735
commit
ca1b8ada99
4 changed files with 17 additions and 31 deletions
|
@ -28,34 +28,26 @@ base::FilePath V8ValueToFilePath(v8::Handle<v8::Value> path) {
|
|||
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)
|
||||
|
|
|
@ -68,10 +68,8 @@ module.exports =
|
|||
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
|
||||
|
@ -82,7 +80,7 @@ module.exports =
|
|||
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)
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "ui/gfx/native_widget_types.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
enum MessageBoxType {
|
||||
|
@ -18,8 +16,7 @@ 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,
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
|
||||
namespace atom {
|
||||
|
||||
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,
|
||||
|
|
Loading…
Reference in a new issue