!args[2]->IsNumber()) // properties
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]));
base::FilePath default_path(V8ValueToFilePath(args[1]));
int properties = args[2]->IntegerValue();
std::vector<base::FilePath> paths;
- if (!file_dialog::ShowOpenDialog(NULL,
+ if (!file_dialog::ShowOpenDialog(native_window,
title,
default_path,
properties,
messageBoxTypes = ['none', 'info', 'warning']
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.properties = options.properties ? ['openFile']
throw new TypeError('Properties need to be array') unless Array.isArray options.properties
options.title = options.title ? ''
options.defaultPath = options.defaultPath ? ''
- binding.showOpenDialog options.title, options.defaultPath, properties
+ binding.showOpenDialog options.title,
+ options.defaultPath,
+ properties,
+ window
showSaveDialog: (window, options) ->
throw new TypeError('Invalid window') unless window?.constructor is BrowserWindow