int properties = args[2]->IntegerValue();
std::vector<base::FilePath> paths;
- if (!file_dialog::ShowOpenDialog(title, default_path, properties, &paths))
+ if (!file_dialog::ShowOpenDialog(NULL,
+ title,
+ default_path,
+ properties,
+ &paths))
return v8::Undefined();
v8::Handle<v8::Array> result = v8::Array::New(paths.size());
FILE_DIALOG_CREATE_DIRECTORY = 8,
};
-bool ShowOpenDialog(const std::string& title,
+bool ShowOpenDialog(atom::NativeWindow* parent_window,
+ const std::string& title,
const base::FilePath& default_path,
int properties,
std::vector<base::FilePath>* paths);
-bool ShowSaveDialog(atom::NativeWindow* window,
+bool ShowSaveDialog(atom::NativeWindow* parent_window,
const std::string& title,
const base::FilePath& default_path,
base::FilePath* path);
} // namespace
-bool ShowOpenDialog(const std::string& title,
+bool ShowOpenDialog(atom::NativeWindow* parent_window,
+ const std::string& title,
const base::FilePath& default_path,
int properties,
std::vector<base::FilePath>* paths) {
if (properties & FILE_DIALOG_MULTI_SELECTIONS)
[dialog setAllowsMultipleSelection:YES];
- if ([dialog runModal] == NSFileHandlingPanelCancelButton)
+ __block int chosen = -1;
+
+ if (parent_window == NULL) {
+ chosen = [dialog runModal];
+ } else {
+ NSWindow* window = parent_window->GetNativeWindow();
+
+ [dialog beginSheetModalForWindow:window
+ completionHandler:^(NSInteger c) {
+ chosen = c;
+ [NSApp stopModal];
+ }];
+ [NSApp runModalForWindow:window];
+ }
+
+ if (chosen == NSFileHandlingPanelCancelButton)
return false;
NSArray* urls = [dialog URLs];