Add buttonLabel param to showOpen/showSave dialogs
This commit is contained in:
parent
88f3c34412
commit
40c531737d
10 changed files with 67 additions and 19 deletions
|
@ -45,11 +45,15 @@ void SetAllowedFileTypes(NSSavePanel* dialog, const Filters& filters) {
|
|||
|
||||
void SetupDialog(NSSavePanel* dialog,
|
||||
const std::string& title,
|
||||
const std::string& button_label,
|
||||
const base::FilePath& default_path,
|
||||
const Filters& filters) {
|
||||
if (!title.empty())
|
||||
[dialog setTitle:base::SysUTF8ToNSString(title)];
|
||||
|
||||
if (!button_label.empty())
|
||||
[dialog setPrompt:base::SysUTF8ToNSString(button_label)];
|
||||
|
||||
NSString* default_dir = nil;
|
||||
NSString* default_filename = nil;
|
||||
if (!default_path.empty()) {
|
||||
|
@ -114,6 +118,7 @@ void ReadDialogPaths(NSOpenPanel* dialog, std::vector<base::FilePath>* 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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue