Enable taking window as parameter in dialog.showOpenDialog.
This commit is contained in:
parent
a4262bc39d
commit
76ac8f2719
2 changed files with 21 additions and 3 deletions
|
@ -119,12 +119,21 @@ v8::Handle<v8::Value> ShowOpenDialog(const v8::Arguments &args) {
|
||||||
!args[2]->IsNumber()) // properties
|
!args[2]->IsNumber()) // properties
|
||||||
return node::ThrowTypeError("Bad argument");
|
return node::ThrowTypeError("Bad argument");
|
||||||
|
|
||||||
|
NativeWindow* native_window = NULL;
|
||||||
|
if (args[3]->IsObject()) {
|
||||||
|
Window* window = Window::Unwrap<Window>(args[3]->ToObject());
|
||||||
|
if (!window || !window->window())
|
||||||
|
return node::ThrowError("Invalid window");
|
||||||
|
|
||||||
|
native_window = window->window();
|
||||||
|
}
|
||||||
|
|
||||||
std::string title(*v8::String::Utf8Value(args[0]));
|
std::string title(*v8::String::Utf8Value(args[0]));
|
||||||
base::FilePath default_path(V8ValueToFilePath(args[1]));
|
base::FilePath default_path(V8ValueToFilePath(args[1]));
|
||||||
int properties = args[2]->IntegerValue();
|
int properties = args[2]->IntegerValue();
|
||||||
|
|
||||||
std::vector<base::FilePath> paths;
|
std::vector<base::FilePath> paths;
|
||||||
if (!file_dialog::ShowOpenDialog(NULL,
|
if (!file_dialog::ShowOpenDialog(native_window,
|
||||||
title,
|
title,
|
||||||
default_path,
|
default_path,
|
||||||
properties,
|
properties,
|
||||||
|
|
|
@ -7,7 +7,13 @@ fileDialogProperties =
|
||||||
messageBoxTypes = ['none', 'info', 'warning']
|
messageBoxTypes = ['none', 'info', 'warning']
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
showOpenDialog: (options) ->
|
showOpenDialog: (window, options, callback) ->
|
||||||
|
if window? and window.constructor isnt BrowserWindow
|
||||||
|
# Shift.
|
||||||
|
callback = options
|
||||||
|
options = window
|
||||||
|
window = null
|
||||||
|
|
||||||
options = title: 'Open', properties: ['openFile'] unless options?
|
options = title: 'Open', properties: ['openFile'] unless options?
|
||||||
options.properties = options.properties ? ['openFile']
|
options.properties = options.properties ? ['openFile']
|
||||||
throw new TypeError('Properties need to be array') unless Array.isArray options.properties
|
throw new TypeError('Properties need to be array') unless Array.isArray options.properties
|
||||||
|
@ -19,7 +25,10 @@ module.exports =
|
||||||
options.title = options.title ? ''
|
options.title = options.title ? ''
|
||||||
options.defaultPath = options.defaultPath ? ''
|
options.defaultPath = options.defaultPath ? ''
|
||||||
|
|
||||||
binding.showOpenDialog options.title, options.defaultPath, properties
|
binding.showOpenDialog options.title,
|
||||||
|
options.defaultPath,
|
||||||
|
properties,
|
||||||
|
window
|
||||||
|
|
||||||
showSaveDialog: (window, options) ->
|
showSaveDialog: (window, options) ->
|
||||||
throw new TypeError('Invalid window') unless window?.constructor is BrowserWindow
|
throw new TypeError('Invalid window') unless window?.constructor is BrowserWindow
|
||||||
|
|
Loading…
Reference in a new issue