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