Make dialog.showSaveDialog accept no parent window.
This commit is contained in:
parent
e824b6c910
commit
30ca085fd8
2 changed files with 23 additions and 14 deletions
|
@ -189,20 +189,24 @@ v8::Handle<v8::Value> ShowOpenDialog(const v8::Arguments &args) {
|
||||||
v8::Handle<v8::Value> ShowSaveDialog(const v8::Arguments &args) {
|
v8::Handle<v8::Value> ShowSaveDialog(const v8::Arguments &args) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
|
|
||||||
if (!args[0]->IsObject() || // window
|
if (!args[0]->IsString() || // title
|
||||||
!args[1]->IsString() || // title
|
!args[1]->IsString()) // default_path
|
||||||
!args[2]->IsString()) // default_path
|
|
||||||
return node::ThrowTypeError("Bad argument");
|
return node::ThrowTypeError("Bad argument");
|
||||||
|
|
||||||
Window* window = Window::Unwrap<Window>(args[0]->ToObject());
|
NativeWindow* native_window = NULL;
|
||||||
if (!window || !window->window())
|
if (args[2]->IsObject()) {
|
||||||
return node::ThrowError("Invalid window");
|
Window* window = Window::Unwrap<Window>(args[2]->ToObject());
|
||||||
|
if (!window || !window->window())
|
||||||
|
return node::ThrowError("Invalid window");
|
||||||
|
|
||||||
std::string title(*v8::String::Utf8Value(args[1]));
|
native_window = window->window();
|
||||||
base::FilePath default_path(V8ValueToFilePath(args[2]));
|
}
|
||||||
|
|
||||||
|
std::string title(*v8::String::Utf8Value(args[0]));
|
||||||
|
base::FilePath default_path(V8ValueToFilePath(args[1]));
|
||||||
|
|
||||||
base::FilePath path;
|
base::FilePath path;
|
||||||
if (!file_dialog::ShowSaveDialog(window->window(),
|
if (!file_dialog::ShowSaveDialog(native_window,
|
||||||
title,
|
title,
|
||||||
default_path,
|
default_path,
|
||||||
&path))
|
&path))
|
||||||
|
|
|
@ -31,16 +31,21 @@ module.exports =
|
||||||
window,
|
window,
|
||||||
callback
|
callback
|
||||||
|
|
||||||
showSaveDialog: (window, options) ->
|
showSaveDialog: (window, options, callback) ->
|
||||||
throw new TypeError('Invalid window') unless window?.constructor is BrowserWindow
|
unless window?.constructor is BrowserWindow
|
||||||
|
# Shift.
|
||||||
|
callback = options
|
||||||
|
options = window
|
||||||
|
window = null
|
||||||
|
|
||||||
options ?= title: 'Save'
|
options ?= title: 'Save'
|
||||||
options.title ?= ''
|
options.title ?= ''
|
||||||
options.defaultPath ?= ''
|
options.defaultPath ?= ''
|
||||||
|
|
||||||
binding.showSaveDialog window,
|
binding.showSaveDialog String(options.title),
|
||||||
String(options.title),
|
String(options.defaultPath),
|
||||||
String(options.defaultPath)
|
window,
|
||||||
|
callback
|
||||||
|
|
||||||
showMessageBox: (window, options, callback) ->
|
showMessageBox: (window, options, callback) ->
|
||||||
unless window?.constructor is BrowserWindow
|
unless window?.constructor is BrowserWindow
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue