From 40c531737d1d4a1d0244e0c6305b42847cacd59b Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Fri, 6 May 2016 11:10:31 -0700 Subject: [PATCH 1/5] Add buttonLabel param to showOpen/showSave dialogs --- atom/browser/api/atom_api_dialog.cc | 17 ++++++++++------- atom/browser/atom_download_manager_delegate.cc | 3 ++- atom/browser/common_web_contents_delegate.cc | 4 ++-- atom/browser/ui/file_dialog.h | 4 ++++ atom/browser/ui/file_dialog_gtk.cc | 4 ++++ atom/browser/ui/file_dialog_mac.mm | 16 ++++++++++++---- atom/browser/ui/file_dialog_win.cc | 17 ++++++++++++++--- atom/browser/web_dialog_helper.cc | 2 ++ docs/api/dialog.md | 1 + lib/browser/api/dialog.js | 18 ++++++++++++++++-- 10 files changed, 67 insertions(+), 19 deletions(-) diff --git a/atom/browser/api/atom_api_dialog.cc b/atom/browser/api/atom_api_dialog.cc index 0a544c56468c..5d853e2d5900 100644 --- a/atom/browser/api/atom_api_dialog.cc +++ b/atom/browser/api/atom_api_dialog.cc @@ -67,6 +67,7 @@ void ShowMessageBox(int type, } void ShowOpenDialog(const std::string& title, + const std::string& button_label, const base::FilePath& default_path, const file_dialog::Filters& filters, int properties, @@ -77,17 +78,18 @@ void ShowOpenDialog(const std::string& title, if (mate::Converter::FromV8(args->isolate(), peek, &callback)) { - file_dialog::ShowOpenDialog(window, title, default_path, filters, - properties, callback); + file_dialog::ShowOpenDialog(window, title, button_label, default_path, + filters, properties, callback); } else { std::vector paths; - if (file_dialog::ShowOpenDialog(window, title, default_path, filters, - properties, &paths)) + if (file_dialog::ShowOpenDialog(window, title, button_label, default_path, + filters, properties, &paths)) args->Return(paths); } } void ShowSaveDialog(const std::string& title, + const std::string& button_label, const base::FilePath& default_path, const file_dialog::Filters& filters, atom::NativeWindow* window, @@ -97,11 +99,12 @@ void ShowSaveDialog(const std::string& title, if (mate::Converter::FromV8(args->isolate(), peek, &callback)) { - file_dialog::ShowSaveDialog(window, title, default_path, filters, callback); + file_dialog::ShowSaveDialog(window, title, button_label, default_path, + filters, callback); } else { base::FilePath path; - if (file_dialog::ShowSaveDialog(window, title, default_path, filters, - &path)) + if (file_dialog::ShowSaveDialog(window, title, button_label, default_path, + filters, &path)) args->Return(path); } } diff --git a/atom/browser/atom_download_manager_delegate.cc b/atom/browser/atom_download_manager_delegate.cc index bf09a4059504..05e68993013a 100644 --- a/atom/browser/atom_download_manager_delegate.cc +++ b/atom/browser/atom_download_manager_delegate.cc @@ -77,7 +77,8 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated( window = relay->window.get(); base::FilePath path; - if (file_dialog::ShowSaveDialog(window, item->GetURL().spec(), default_path, + if (file_dialog::ShowSaveDialog(window, item->GetURL().spec(), + "Save", default_path, file_dialog::Filters(), &path)) { // Remember the last selected download directory. AtomBrowserContext* browser_context = static_cast( diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index da3647bc907e..b36566383bd7 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -389,7 +389,7 @@ void CommonWebContentsDelegate::DevToolsSaveToFile( } else { file_dialog::Filters filters; base::FilePath default_path(base::FilePath::FromUTF8Unsafe(url)); - if (!file_dialog::ShowSaveDialog(owner_window(), url, default_path, + if (!file_dialog::ShowSaveDialog(owner_window(), url, "Save", default_path, filters, &path)) { base::StringValue url_value(url); web_contents_->CallClientFunction( @@ -455,7 +455,7 @@ void CommonWebContentsDelegate::DevToolsAddFileSystem( base::FilePath default_path; std::vector paths; int flag = file_dialog::FILE_DIALOG_OPEN_DIRECTORY; - if (!file_dialog::ShowOpenDialog(owner_window(), "", default_path, + if (!file_dialog::ShowOpenDialog(owner_window(), "", "Open", default_path, filters, flag, &paths)) return; diff --git a/atom/browser/ui/file_dialog.h b/atom/browser/ui/file_dialog.h index 51d7f5ee9d32..b857648161b5 100644 --- a/atom/browser/ui/file_dialog.h +++ b/atom/browser/ui/file_dialog.h @@ -37,6 +37,7 @@ typedef base::Callback* paths) { bool ShowOpenDialog(atom::NativeWindow* parent_window, const std::string& title, + const std::string& button_label, const base::FilePath& default_path, const Filters& filters, int properties, @@ -121,7 +126,7 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window, DCHECK(paths); NSOpenPanel* dialog = [NSOpenPanel openPanel]; - SetupDialog(dialog, title, default_path, filters); + SetupDialog(dialog, title, button_label, default_path, filters); SetupDialogForProperties(dialog, properties); int chosen = RunModalDialog(dialog, parent_window); @@ -134,13 +139,14 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window, void ShowOpenDialog(atom::NativeWindow* parent_window, const std::string& title, + const std::string& button_label, const base::FilePath& default_path, const Filters& filters, int properties, const OpenDialogCallback& c) { NSOpenPanel* dialog = [NSOpenPanel openPanel]; - SetupDialog(dialog, title, default_path, filters); + SetupDialog(dialog, title, button_label, default_path, filters); SetupDialogForProperties(dialog, properties); // Duplicate the callback object here since c is a reference and gcd would @@ -162,13 +168,14 @@ void ShowOpenDialog(atom::NativeWindow* parent_window, bool ShowSaveDialog(atom::NativeWindow* parent_window, const std::string& title, + const std::string& button_label, const base::FilePath& default_path, const Filters& filters, base::FilePath* path) { DCHECK(path); NSSavePanel* dialog = [NSSavePanel savePanel]; - SetupDialog(dialog, title, default_path, filters); + SetupDialog(dialog, title, button_label, default_path, filters); int chosen = RunModalDialog(dialog, parent_window); if (chosen == NSFileHandlingPanelCancelButton || ![[dialog URL] isFileURL]) @@ -180,12 +187,13 @@ bool ShowSaveDialog(atom::NativeWindow* parent_window, void ShowSaveDialog(atom::NativeWindow* parent_window, const std::string& title, + const std::string& button_label, const base::FilePath& default_path, const Filters& filters, const SaveDialogCallback& c) { NSSavePanel* dialog = [NSSavePanel savePanel]; - SetupDialog(dialog, title, default_path, filters); + SetupDialog(dialog, title, button_label, default_path, filters); __block SaveDialogCallback callback = c; diff --git a/atom/browser/ui/file_dialog_win.cc b/atom/browser/ui/file_dialog_win.cc index 6577e4c08404..c5d81c33100b 100644 --- a/atom/browser/ui/file_dialog_win.cc +++ b/atom/browser/ui/file_dialog_win.cc @@ -63,7 +63,9 @@ void ConvertFilters(const Filters& filters, template class FileDialog { public: - FileDialog(const base::FilePath& default_path, const std::string& title, + FileDialog(const base::FilePath& default_path, + const std::string& title, + const std::string& button_label, const Filters& filters, int options) { std::wstring file_part; if (!IsDirectory(default_path)) @@ -79,6 +81,9 @@ class FileDialog { if (!title.empty()) GetPtr()->SetTitle(base::UTF8ToUTF16(title).c_str()); + if (!button_label.empty()) + GetPtr()->SetOkButtonLabel(base::UTF8ToUTF16(button_label).c_str()); + // By default, *.* will be added to the file name if file type is "*.*". In // Electron, we disable it to make a better experience. // @@ -154,13 +159,14 @@ bool CreateDialogThread(RunState* run_state) { void RunOpenDialogInNewThread(const RunState& run_state, atom::NativeWindow* parent, const std::string& title, + const std::string& button_label, const base::FilePath& default_path, const Filters& filters, int properties, const OpenDialogCallback& callback) { std::vector paths; - bool result = ShowOpenDialog(parent, title, default_path, filters, properties, - &paths); + bool result = ShowOpenDialog(parent, title, button_label, default_path, + filters, properties, &paths); run_state.ui_message_loop->PostTask(FROM_HERE, base::Bind(callback, result, paths)); run_state.ui_message_loop->DeleteSoon(FROM_HERE, run_state.dialog_thread); @@ -169,6 +175,7 @@ void RunOpenDialogInNewThread(const RunState& run_state, void RunSaveDialogInNewThread(const RunState& run_state, atom::NativeWindow* parent, const std::string& title, + const std::string& button_label, const base::FilePath& default_path, const Filters& filters, const SaveDialogCallback& callback) { @@ -183,6 +190,7 @@ void RunSaveDialogInNewThread(const RunState& run_state, bool ShowOpenDialog(atom::NativeWindow* parent_window, const std::string& title, + const std::string& button_label, const base::FilePath& default_path, const Filters& filters, int properties, @@ -230,6 +238,7 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window, void ShowOpenDialog(atom::NativeWindow* parent, const std::string& title, + const std::string& button_label, const base::FilePath& default_path, const Filters& filters, int properties, @@ -248,6 +257,7 @@ void ShowOpenDialog(atom::NativeWindow* parent, bool ShowSaveDialog(atom::NativeWindow* parent_window, const std::string& title, + const std::string& button_label, const base::FilePath& default_path, const Filters& filters, base::FilePath* path) { @@ -268,6 +278,7 @@ bool ShowSaveDialog(atom::NativeWindow* parent_window, void ShowSaveDialog(atom::NativeWindow* parent, const std::string& title, + const std::string& button_label, const base::FilePath& default_path, const Filters& filters, const SaveDialogCallback& callback) { diff --git a/atom/browser/web_dialog_helper.cc b/atom/browser/web_dialog_helper.cc index a082c3814c72..be43584a5bc3 100644 --- a/atom/browser/web_dialog_helper.cc +++ b/atom/browser/web_dialog_helper.cc @@ -84,6 +84,7 @@ void WebDialogHelper::RunFileChooser(content::WebContents* web_contents, base::FilePath path; if (file_dialog::ShowSaveDialog(window_, base::UTF16ToUTF8(params.title), + "Save", params.default_file_name, filters, &path)) { @@ -114,6 +115,7 @@ void WebDialogHelper::RunFileChooser(content::WebContents* web_contents, prefs::kSelectFileLastDirectory).Append(params.default_file_name); if (file_dialog::ShowOpenDialog(window_, base::UTF16ToUTF8(params.title), + "Open", default_file_path, filters, flags, diff --git a/docs/api/dialog.md b/docs/api/dialog.md index 1444b5960e81..bb76056d1372 100644 --- a/docs/api/dialog.md +++ b/docs/api/dialog.md @@ -28,6 +28,7 @@ The `dialog` module has the following methods: * `options` Object * `title` String * `defaultPath` String + * `buttonLabel` String * `filters` Array * `properties` Array - Contains which features the dialog should use, can contain `openFile`, `openDirectory`, `multiSelections` and diff --git a/lib/browser/api/dialog.js b/lib/browser/api/dialog.js index a41d1fa46e0c..55c8935b2ac6 100644 --- a/lib/browser/api/dialog.js +++ b/lib/browser/api/dialog.js @@ -75,6 +75,15 @@ module.exports = { } else if (typeof options.title !== 'string') { throw new TypeError('Title must be a string') } + if (options.buttonLabel == null) { + if (options.properties.indexOf('openDirectory') !== -1) { + options.buttonLabel = 'Choose' + } else { + options.buttonLabel = 'Open' + } + } else if (typeof options.buttonLabel !== 'string') { + throw new TypeError('buttonLabel must be a string') + } if (options.defaultPath == null) { options.defaultPath = '' } else if (typeof options.defaultPath !== 'string') { @@ -86,7 +95,7 @@ module.exports = { wrappedCallback = typeof callback === 'function' ? function (success, result) { return callback(success ? result : void 0) } : null - return binding.showOpenDialog(String(options.title), String(options.defaultPath), options.filters, properties, window, wrappedCallback) + return binding.showOpenDialog(String(options.title), String(options.buttonLabel), String(options.defaultPath), options.filters, properties, window, wrappedCallback) }, showSaveDialog: function (...args) { @@ -103,6 +112,11 @@ module.exports = { } else if (typeof options.title !== 'string') { throw new TypeError('Title must be a string') } + if (options.buttonLabel == null) { + options.buttonLabel = 'Save' + } else if (typeof options.buttonLabel !== 'string') { + throw new TypeError('buttonLabel must be a string') + } if (options.defaultPath == null) { options.defaultPath = '' } else if (typeof options.defaultPath !== 'string') { @@ -114,7 +128,7 @@ module.exports = { wrappedCallback = typeof callback === 'function' ? function (success, result) { return callback(success ? result : void 0) } : null - return binding.showSaveDialog(String(options.title), String(options.defaultPath), options.filters, window, wrappedCallback) + return binding.showSaveDialog(String(options.title), String(options.buttonLabel), String(options.defaultPath), options.filters, window, wrappedCallback) }, showMessageBox: function (...args) { From 84cce6c2c1af84f83d417e8d2926a8ad3c2d73dd Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Sun, 15 May 2016 01:01:52 -0500 Subject: [PATCH 2/5] Don't default to "Open", "Save", just let OS decide --- atom/browser/atom_download_manager_delegate.cc | 2 +- atom/browser/common_web_contents_delegate.cc | 4 ++-- atom/browser/web_dialog_helper.cc | 4 ++-- lib/browser/api/dialog.js | 12 ++++-------- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/atom/browser/atom_download_manager_delegate.cc b/atom/browser/atom_download_manager_delegate.cc index 05e68993013a..6d7e3c7172d8 100644 --- a/atom/browser/atom_download_manager_delegate.cc +++ b/atom/browser/atom_download_manager_delegate.cc @@ -78,7 +78,7 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated( base::FilePath path; if (file_dialog::ShowSaveDialog(window, item->GetURL().spec(), - "Save", default_path, + "", default_path, file_dialog::Filters(), &path)) { // Remember the last selected download directory. AtomBrowserContext* browser_context = static_cast( diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index b36566383bd7..2093b8f48994 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -389,7 +389,7 @@ void CommonWebContentsDelegate::DevToolsSaveToFile( } else { file_dialog::Filters filters; base::FilePath default_path(base::FilePath::FromUTF8Unsafe(url)); - if (!file_dialog::ShowSaveDialog(owner_window(), url, "Save", default_path, + if (!file_dialog::ShowSaveDialog(owner_window(), url, "", default_path, filters, &path)) { base::StringValue url_value(url); web_contents_->CallClientFunction( @@ -455,7 +455,7 @@ void CommonWebContentsDelegate::DevToolsAddFileSystem( base::FilePath default_path; std::vector paths; int flag = file_dialog::FILE_DIALOG_OPEN_DIRECTORY; - if (!file_dialog::ShowOpenDialog(owner_window(), "", "Open", default_path, + if (!file_dialog::ShowOpenDialog(owner_window(), "", "", default_path, filters, flag, &paths)) return; diff --git a/atom/browser/web_dialog_helper.cc b/atom/browser/web_dialog_helper.cc index be43584a5bc3..2d2a9e5db80d 100644 --- a/atom/browser/web_dialog_helper.cc +++ b/atom/browser/web_dialog_helper.cc @@ -84,7 +84,7 @@ void WebDialogHelper::RunFileChooser(content::WebContents* web_contents, base::FilePath path; if (file_dialog::ShowSaveDialog(window_, base::UTF16ToUTF8(params.title), - "Save", + "", params.default_file_name, filters, &path)) { @@ -115,7 +115,7 @@ void WebDialogHelper::RunFileChooser(content::WebContents* web_contents, prefs::kSelectFileLastDirectory).Append(params.default_file_name); if (file_dialog::ShowOpenDialog(window_, base::UTF16ToUTF8(params.title), - "Open", + "", default_file_path, filters, flags, diff --git a/lib/browser/api/dialog.js b/lib/browser/api/dialog.js index 55c8935b2ac6..73f53655706c 100644 --- a/lib/browser/api/dialog.js +++ b/lib/browser/api/dialog.js @@ -76,11 +76,7 @@ module.exports = { throw new TypeError('Title must be a string') } if (options.buttonLabel == null) { - if (options.properties.indexOf('openDirectory') !== -1) { - options.buttonLabel = 'Choose' - } else { - options.buttonLabel = 'Open' - } + options.buttonLabel = '' } else if (typeof options.buttonLabel !== 'string') { throw new TypeError('buttonLabel must be a string') } @@ -95,7 +91,7 @@ module.exports = { wrappedCallback = typeof callback === 'function' ? function (success, result) { return callback(success ? result : void 0) } : null - return binding.showOpenDialog(String(options.title), String(options.buttonLabel), String(options.defaultPath), options.filters, properties, window, wrappedCallback) + return binding.showOpenDialog(options.title, options.buttonLabel, options.defaultPath, options.filters, properties, window, wrappedCallback) }, showSaveDialog: function (...args) { @@ -113,7 +109,7 @@ module.exports = { throw new TypeError('Title must be a string') } if (options.buttonLabel == null) { - options.buttonLabel = 'Save' + options.buttonLabel = '' } else if (typeof options.buttonLabel !== 'string') { throw new TypeError('buttonLabel must be a string') } @@ -128,7 +124,7 @@ module.exports = { wrappedCallback = typeof callback === 'function' ? function (success, result) { return callback(success ? result : void 0) } : null - return binding.showSaveDialog(String(options.title), String(options.buttonLabel), String(options.defaultPath), options.filters, window, wrappedCallback) + return binding.showSaveDialog(options.title, options.buttonLabel, options.defaultPath, options.filters, window, wrappedCallback) }, showMessageBox: function (...args) { From 6217d497edfe9f691888db8b4fcc296882218800 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Sun, 15 May 2016 01:02:27 -0500 Subject: [PATCH 3/5] Fix build issues --- atom/browser/ui/file_dialog_gtk.cc | 18 +++++++++++------- atom/browser/ui/file_dialog_win.cc | 3 ++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/atom/browser/ui/file_dialog_gtk.cc b/atom/browser/ui/file_dialog_gtk.cc index d58d5b5025c4..713b7b3ddb72 100644 --- a/atom/browser/ui/file_dialog_gtk.cc +++ b/atom/browser/ui/file_dialog_gtk.cc @@ -37,12 +37,16 @@ class FileChooserDialog { FileChooserDialog(GtkFileChooserAction action, atom::NativeWindow* parent_window, const std::string& title, + const std::string& button_label, const base::FilePath& default_path, const Filters& filters) : dialog_scope_(parent_window), filters_(filters) { const char* confirm_text = GTK_STOCK_OK; - if (action == GTK_FILE_CHOOSER_ACTION_SAVE) + + if (button_label != NULL) + confirm_text = button_label.c_str(); + else if (action == GTK_FILE_CHOOSER_ACTION_SAVE) confirm_text = GTK_STOCK_SAVE; else if (action == GTK_FILE_CHOOSER_ACTION_OPEN) confirm_text = GTK_STOCK_OPEN; @@ -224,8 +228,8 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window, GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN; if (properties & FILE_DIALOG_OPEN_DIRECTORY) action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; - FileChooserDialog open_dialog(action, parent_window, title, default_path, - filters); + FileChooserDialog open_dialog(action, parent_window, title, button_label, + default_path, filters); if (properties & FILE_DIALOG_MULTI_SELECTIONS) gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(open_dialog.dialog()), TRUE); @@ -251,7 +255,7 @@ void ShowOpenDialog(atom::NativeWindow* parent_window, if (properties & FILE_DIALOG_OPEN_DIRECTORY) action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; FileChooserDialog* open_dialog = new FileChooserDialog( - action, parent_window, title, default_path, filters); + action, parent_window, title, button_label, default_path, filters); if (properties & FILE_DIALOG_MULTI_SELECTIONS) gtk_file_chooser_set_select_multiple( GTK_FILE_CHOOSER(open_dialog->dialog()), TRUE); @@ -266,7 +270,7 @@ bool ShowSaveDialog(atom::NativeWindow* parent_window, const Filters& filters, base::FilePath* path) { FileChooserDialog save_dialog(GTK_FILE_CHOOSER_ACTION_SAVE, parent_window, - title, default_path, filters); + title, button_label, default_path, filters); gtk_widget_show_all(save_dialog.dialog()); int response = gtk_dialog_run(GTK_DIALOG(save_dialog.dialog())); if (response == GTK_RESPONSE_ACCEPT) { @@ -284,8 +288,8 @@ void ShowSaveDialog(atom::NativeWindow* parent_window, const Filters& filters, const SaveDialogCallback& callback) { FileChooserDialog* save_dialog = new FileChooserDialog( - GTK_FILE_CHOOSER_ACTION_SAVE, parent_window, title, default_path, - filters); + GTK_FILE_CHOOSER_ACTION_SAVE, parent_window, title, button_label, + default_path, filters); save_dialog->RunSaveAsynchronous(callback); } diff --git a/atom/browser/ui/file_dialog_win.cc b/atom/browser/ui/file_dialog_win.cc index c5d81c33100b..e99dcee35c50 100644 --- a/atom/browser/ui/file_dialog_win.cc +++ b/atom/browser/ui/file_dialog_win.cc @@ -180,7 +180,8 @@ void RunSaveDialogInNewThread(const RunState& run_state, const Filters& filters, const SaveDialogCallback& callback) { base::FilePath path; - bool result = ShowSaveDialog(parent, title, default_path, filters, &path); + bool result = ShowSaveDialog(parent, title, button_label, default_path, + filters, &path); run_state.ui_message_loop->PostTask(FROM_HERE, base::Bind(callback, result, path)); run_state.ui_message_loop->DeleteSoon(FROM_HERE, run_state.dialog_thread); From 54c654530e17062454d7d660e91e5a9f5c954c4d Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Sun, 15 May 2016 01:29:13 -0500 Subject: [PATCH 4/5] Fix linux support --- atom/browser/ui/file_dialog_gtk.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/ui/file_dialog_gtk.cc b/atom/browser/ui/file_dialog_gtk.cc index 713b7b3ddb72..2c8b785544a2 100644 --- a/atom/browser/ui/file_dialog_gtk.cc +++ b/atom/browser/ui/file_dialog_gtk.cc @@ -44,7 +44,7 @@ class FileChooserDialog { filters_(filters) { const char* confirm_text = GTK_STOCK_OK; - if (button_label != NULL) + if (!button_label.empty()) confirm_text = button_label.c_str(); else if (action == GTK_FILE_CHOOSER_ACTION_SAVE) confirm_text = GTK_STOCK_SAVE; From e53bfad01842429acf37439a935bf4d7622f6417 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 16 May 2016 10:09:41 +0900 Subject: [PATCH 5/5] Fix building on Windows --- atom/browser/ui/file_dialog_win.cc | 8 ++++---- docs/api/dialog.md | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/atom/browser/ui/file_dialog_win.cc b/atom/browser/ui/file_dialog_win.cc index e99dcee35c50..af699a103937 100644 --- a/atom/browser/ui/file_dialog_win.cc +++ b/atom/browser/ui/file_dialog_win.cc @@ -203,7 +203,7 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window, options |= FOS_ALLOWMULTISELECT; FileDialog open_dialog( - default_path, title, filters, options); + default_path, title, button_label, filters, options); if (!open_dialog.Show(parent_window)) return false; @@ -253,7 +253,7 @@ void ShowOpenDialog(atom::NativeWindow* parent, run_state.dialog_thread->message_loop()->PostTask( FROM_HERE, base::Bind(&RunOpenDialogInNewThread, run_state, parent, title, - default_path, filters, properties, callback)); + button_label, default_path, filters, properties, callback)); } bool ShowSaveDialog(atom::NativeWindow* parent_window, @@ -263,7 +263,7 @@ bool ShowSaveDialog(atom::NativeWindow* parent_window, const Filters& filters, base::FilePath* path) { FileDialog save_dialog( - default_path, title, filters, + default_path, title, button_label, filters, FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_OVERWRITEPROMPT); if (!save_dialog.Show(parent_window)) return false; @@ -292,7 +292,7 @@ void ShowSaveDialog(atom::NativeWindow* parent, run_state.dialog_thread->message_loop()->PostTask( FROM_HERE, base::Bind(&RunSaveDialogInNewThread, run_state, parent, title, - default_path, filters, callback)); + button_label, default_path, filters, callback)); } } // namespace file_dialog diff --git a/docs/api/dialog.md b/docs/api/dialog.md index bb76056d1372..3681a66d7bf6 100644 --- a/docs/api/dialog.md +++ b/docs/api/dialog.md @@ -28,7 +28,8 @@ The `dialog` module has the following methods: * `options` Object * `title` String * `defaultPath` String - * `buttonLabel` String + * `buttonLabel` String - Custom label for the confirmation button, when + left empty the default label will be used. * `filters` Array * `properties` Array - Contains which features the dialog should use, can contain `openFile`, `openDirectory`, `multiSelections` and @@ -70,6 +71,8 @@ shown. * `options` Object * `title` String * `defaultPath` String + * `buttonLabel` String - Custom label for the confirmation button, when + left empty the default label will be used. * `filters` Array * `callback` Function (optional)