rename all references to default_button_index -> default_id to keep consistent with cancel_id
This commit is contained in:
Родитель
dfce803045
Коммит
ae5c6add11
|
@ -41,7 +41,7 @@ namespace {
|
||||||
|
|
||||||
void ShowMessageBox(int type,
|
void ShowMessageBox(int type,
|
||||||
const std::vector<std::string>& buttons,
|
const std::vector<std::string>& buttons,
|
||||||
int default_button_index,
|
int default_id,
|
||||||
int cancel_id,
|
int cancel_id,
|
||||||
int options,
|
int options,
|
||||||
const std::string& title,
|
const std::string& title,
|
||||||
|
@ -56,11 +56,11 @@ void ShowMessageBox(int type,
|
||||||
peek,
|
peek,
|
||||||
&callback)) {
|
&callback)) {
|
||||||
atom::ShowMessageBox(window, (atom::MessageBoxType)type, buttons,
|
atom::ShowMessageBox(window, (atom::MessageBoxType)type, buttons,
|
||||||
default_button_index, cancel_id, options, title,
|
default_id, cancel_id, options, title,
|
||||||
message, detail, icon, callback);
|
message, detail, icon, callback);
|
||||||
} else {
|
} else {
|
||||||
int chosen = atom::ShowMessageBox(window, (atom::MessageBoxType)type,
|
int chosen = atom::ShowMessageBox(window, (atom::MessageBoxType)type,
|
||||||
buttons, default_button_index, cancel_id,
|
buttons, default_id, cancel_id,
|
||||||
options, title, message, detail, icon);
|
options, title, message, detail, icon);
|
||||||
args->Return(chosen);
|
args->Return(chosen);
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ module.exports =
|
||||||
options.message ?= ''
|
options.message ?= ''
|
||||||
options.detail ?= ''
|
options.detail ?= ''
|
||||||
options.icon ?= null
|
options.icon ?= null
|
||||||
options.defaultButtonIndex ?= -1
|
options.defaultId ?= -1
|
||||||
|
|
||||||
# Choose a default button to get selected when dialog is cancelled.
|
# Choose a default button to get selected when dialog is cancelled.
|
||||||
unless options.cancelId?
|
unless options.cancelId?
|
||||||
|
@ -109,7 +109,7 @@ module.exports =
|
||||||
|
|
||||||
binding.showMessageBox messageBoxType,
|
binding.showMessageBox messageBoxType,
|
||||||
options.buttons,
|
options.buttons,
|
||||||
options.defaultButtonIndex,
|
options.defaultId,
|
||||||
options.cancelId,
|
options.cancelId,
|
||||||
flags,
|
flags,
|
||||||
options.title,
|
options.title,
|
||||||
|
|
|
@ -38,7 +38,7 @@ int ShowMessageBox(NativeWindow* parent_window,
|
||||||
MessageBoxType type,
|
MessageBoxType type,
|
||||||
const std::vector<std::string>& buttons,
|
const std::vector<std::string>& buttons,
|
||||||
int cancel_id,
|
int cancel_id,
|
||||||
int default_button_index,
|
int default_id,
|
||||||
int options,
|
int options,
|
||||||
const std::string& title,
|
const std::string& title,
|
||||||
const std::string& message,
|
const std::string& message,
|
||||||
|
@ -48,7 +48,7 @@ int ShowMessageBox(NativeWindow* parent_window,
|
||||||
void ShowMessageBox(NativeWindow* parent_window,
|
void ShowMessageBox(NativeWindow* parent_window,
|
||||||
MessageBoxType type,
|
MessageBoxType type,
|
||||||
const std::vector<std::string>& buttons,
|
const std::vector<std::string>& buttons,
|
||||||
int default_button_index,
|
int default_id,
|
||||||
int cancel_id,
|
int cancel_id,
|
||||||
int options,
|
int options,
|
||||||
const std::string& title,
|
const std::string& title,
|
||||||
|
|
|
@ -29,7 +29,7 @@ class GtkMessageBox {
|
||||||
GtkMessageBox(NativeWindow* parent_window,
|
GtkMessageBox(NativeWindow* parent_window,
|
||||||
MessageBoxType type,
|
MessageBoxType type,
|
||||||
const std::vector<std::string>& buttons,
|
const std::vector<std::string>& buttons,
|
||||||
int default_button_index,
|
int default_id,
|
||||||
int cancel_id,
|
int cancel_id,
|
||||||
const std::string& title,
|
const std::string& title,
|
||||||
const std::string& message,
|
const std::string& message,
|
||||||
|
@ -61,7 +61,7 @@ class GtkMessageBox {
|
||||||
|
|
||||||
// Add buttons.
|
// Add buttons.
|
||||||
for (size_t i = 0; i < buttons.size(); ++i) {
|
for (size_t i = 0; i < buttons.size(); ++i) {
|
||||||
if (i == (size_t)default_button_index) {
|
if (i == (size_t)default_id) {
|
||||||
GtkWidget* button = gtk_dialog_add_button(GTK_DIALOG(dialog_),
|
GtkWidget* button = gtk_dialog_add_button(GTK_DIALOG(dialog_),
|
||||||
TranslateToStock(i, buttons[i]),
|
TranslateToStock(i, buttons[i]),
|
||||||
i);
|
i);
|
||||||
|
@ -169,21 +169,21 @@ void GtkMessageBox::OnResponseDialog(GtkWidget* widget, int response) {
|
||||||
int ShowMessageBox(NativeWindow* parent,
|
int ShowMessageBox(NativeWindow* parent,
|
||||||
MessageBoxType type,
|
MessageBoxType type,
|
||||||
const std::vector<std::string>& buttons,
|
const std::vector<std::string>& buttons,
|
||||||
int default_button_index,
|
int default_id,
|
||||||
int cancel_id,
|
int cancel_id,
|
||||||
int options,
|
int options,
|
||||||
const std::string& title,
|
const std::string& title,
|
||||||
const std::string& message,
|
const std::string& message,
|
||||||
const std::string& detail,
|
const std::string& detail,
|
||||||
const gfx::ImageSkia& icon) {
|
const gfx::ImageSkia& icon) {
|
||||||
return GtkMessageBox(parent, type, buttons, default_button_index, cancel_id,
|
return GtkMessageBox(parent, type, buttons, default_id, cancel_id,
|
||||||
title, message, detail, icon).RunSynchronous();
|
title, message, detail, icon).RunSynchronous();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowMessageBox(NativeWindow* parent,
|
void ShowMessageBox(NativeWindow* parent,
|
||||||
MessageBoxType type,
|
MessageBoxType type,
|
||||||
const std::vector<std::string>& buttons,
|
const std::vector<std::string>& buttons,
|
||||||
int default_button_index,
|
int default_id,
|
||||||
int cancel_id,
|
int cancel_id,
|
||||||
int options,
|
int options,
|
||||||
const std::string& title,
|
const std::string& title,
|
||||||
|
@ -191,7 +191,7 @@ void ShowMessageBox(NativeWindow* parent,
|
||||||
const std::string& detail,
|
const std::string& detail,
|
||||||
const gfx::ImageSkia& icon,
|
const gfx::ImageSkia& icon,
|
||||||
const MessageBoxCallback& callback) {
|
const MessageBoxCallback& callback) {
|
||||||
(new GtkMessageBox(parent, type, buttons, default_button_index, cancel_id,
|
(new GtkMessageBox(parent, type, buttons, default_id, cancel_id,
|
||||||
title, message, detail, icon))->RunAsynchronous(callback);
|
title, message, detail, icon))->RunAsynchronous(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace {
|
||||||
NSAlert* CreateNSAlert(NativeWindow* parent_window,
|
NSAlert* CreateNSAlert(NativeWindow* parent_window,
|
||||||
MessageBoxType type,
|
MessageBoxType type,
|
||||||
const std::vector<std::string>& buttons,
|
const std::vector<std::string>& buttons,
|
||||||
int default_button_index,
|
int default_id,
|
||||||
const std::string& title,
|
const std::string& title,
|
||||||
const std::string& message,
|
const std::string& message,
|
||||||
const std::string& detail) {
|
const std::string& detail) {
|
||||||
|
@ -83,8 +83,8 @@ NSAlert* CreateNSAlert(NativeWindow* parent_window,
|
||||||
NSButton* button = [alert addButtonWithTitle:title];
|
NSButton* button = [alert addButtonWithTitle:title];
|
||||||
[button setTag:i];
|
[button setTag:i];
|
||||||
|
|
||||||
if (i == (size_t)default_button_index) {
|
if (i == (size_t)default_id) {
|
||||||
// focus the button at default_button_index if the user opted to do so.
|
// focus the button at default_id if the user opted to do so.
|
||||||
// The first button added gets set as the default selected.
|
// The first button added gets set as the default selected.
|
||||||
// So remove that default, and make the requested button the default
|
// So remove that default, and make the requested button the default
|
||||||
[[[alert buttons] objectAtIndex:0] setKeyEquivalent:@""];
|
[[[alert buttons] objectAtIndex:0] setKeyEquivalent:@""];
|
||||||
|
@ -104,7 +104,7 @@ void SetReturnCode(int* ret_code, int result) {
|
||||||
int ShowMessageBox(NativeWindow* parent_window,
|
int ShowMessageBox(NativeWindow* parent_window,
|
||||||
MessageBoxType type,
|
MessageBoxType type,
|
||||||
const std::vector<std::string>& buttons,
|
const std::vector<std::string>& buttons,
|
||||||
int default_button_index,
|
int default_id,
|
||||||
int cancel_id,
|
int cancel_id,
|
||||||
int options,
|
int options,
|
||||||
const std::string& title,
|
const std::string& title,
|
||||||
|
@ -112,7 +112,7 @@ int ShowMessageBox(NativeWindow* parent_window,
|
||||||
const std::string& detail,
|
const std::string& detail,
|
||||||
const gfx::ImageSkia& icon) {
|
const gfx::ImageSkia& icon) {
|
||||||
NSAlert* alert = CreateNSAlert(
|
NSAlert* alert = CreateNSAlert(
|
||||||
parent_window, type, buttons, default_button_index, title, message,
|
parent_window, type, buttons, default_id, title, message,
|
||||||
detail);
|
detail);
|
||||||
|
|
||||||
// Use runModal for synchronous alert without parent, since we don't have a
|
// Use runModal for synchronous alert without parent, since we don't have a
|
||||||
|
@ -139,7 +139,7 @@ int ShowMessageBox(NativeWindow* parent_window,
|
||||||
void ShowMessageBox(NativeWindow* parent_window,
|
void ShowMessageBox(NativeWindow* parent_window,
|
||||||
MessageBoxType type,
|
MessageBoxType type,
|
||||||
const std::vector<std::string>& buttons,
|
const std::vector<std::string>& buttons,
|
||||||
int default_button_index,
|
int default_id,
|
||||||
int cancel_id,
|
int cancel_id,
|
||||||
int options,
|
int options,
|
||||||
const std::string& title,
|
const std::string& title,
|
||||||
|
@ -148,7 +148,7 @@ void ShowMessageBox(NativeWindow* parent_window,
|
||||||
const gfx::ImageSkia& icon,
|
const gfx::ImageSkia& icon,
|
||||||
const MessageBoxCallback& callback) {
|
const MessageBoxCallback& callback) {
|
||||||
NSAlert* alert = CreateNSAlert(
|
NSAlert* alert = CreateNSAlert(
|
||||||
parent_window, type, buttons, default_button_index, title, message,
|
parent_window, type, buttons, default_id, title, message,
|
||||||
detail);
|
detail);
|
||||||
ModalDelegate* delegate = [[ModalDelegate alloc] initWithCallback:callback
|
ModalDelegate* delegate = [[ModalDelegate alloc] initWithCallback:callback
|
||||||
andAlert:alert
|
andAlert:alert
|
||||||
|
|
|
@ -72,7 +72,7 @@ void MapToCommonID(const std::vector<base::string16>& buttons,
|
||||||
int ShowMessageBoxUTF16(HWND parent,
|
int ShowMessageBoxUTF16(HWND parent,
|
||||||
MessageBoxType type,
|
MessageBoxType type,
|
||||||
const std::vector<base::string16>& buttons,
|
const std::vector<base::string16>& buttons,
|
||||||
int default_button_index,
|
int default_id,
|
||||||
int cancel_id,
|
int cancel_id,
|
||||||
int options,
|
int options,
|
||||||
const base::string16& title,
|
const base::string16& title,
|
||||||
|
@ -157,7 +157,7 @@ void RunMessageBoxInNewThread(base::Thread* thread,
|
||||||
NativeWindow* parent,
|
NativeWindow* parent,
|
||||||
MessageBoxType type,
|
MessageBoxType type,
|
||||||
const std::vector<std::string>& buttons,
|
const std::vector<std::string>& buttons,
|
||||||
int default_button_index,
|
int default_id,
|
||||||
int cancel_id,
|
int cancel_id,
|
||||||
int options,
|
int options,
|
||||||
const std::string& title,
|
const std::string& title,
|
||||||
|
@ -165,7 +165,7 @@ void RunMessageBoxInNewThread(base::Thread* thread,
|
||||||
const std::string& detail,
|
const std::string& detail,
|
||||||
const gfx::ImageSkia& icon,
|
const gfx::ImageSkia& icon,
|
||||||
const MessageBoxCallback& callback) {
|
const MessageBoxCallback& callback) {
|
||||||
int result = ShowMessageBox(parent, type, buttons, default_button_index,
|
int result = ShowMessageBox(parent, type, buttons, default_id,
|
||||||
cancel_id, options, title, message, detail, icon);
|
cancel_id, options, title, message, detail, icon);
|
||||||
content::BrowserThread::PostTask(
|
content::BrowserThread::PostTask(
|
||||||
content::BrowserThread::UI, FROM_HERE, base::Bind(callback, result));
|
content::BrowserThread::UI, FROM_HERE, base::Bind(callback, result));
|
||||||
|
@ -178,7 +178,7 @@ void RunMessageBoxInNewThread(base::Thread* thread,
|
||||||
int ShowMessageBox(NativeWindow* parent,
|
int ShowMessageBox(NativeWindow* parent,
|
||||||
MessageBoxType type,
|
MessageBoxType type,
|
||||||
const std::vector<std::string>& buttons,
|
const std::vector<std::string>& buttons,
|
||||||
int default_button_index,
|
int default_id,
|
||||||
int cancel_id,
|
int cancel_id,
|
||||||
int options,
|
int options,
|
||||||
const std::string& title,
|
const std::string& title,
|
||||||
|
@ -197,7 +197,7 @@ int ShowMessageBox(NativeWindow* parent,
|
||||||
return ShowMessageBoxUTF16(hwnd_parent,
|
return ShowMessageBoxUTF16(hwnd_parent,
|
||||||
type,
|
type,
|
||||||
utf16_buttons,
|
utf16_buttons,
|
||||||
default_button_index,
|
default_id,
|
||||||
cancel_id,
|
cancel_id,
|
||||||
options,
|
options,
|
||||||
base::UTF8ToUTF16(title),
|
base::UTF8ToUTF16(title),
|
||||||
|
@ -209,7 +209,7 @@ int ShowMessageBox(NativeWindow* parent,
|
||||||
void ShowMessageBox(NativeWindow* parent,
|
void ShowMessageBox(NativeWindow* parent,
|
||||||
MessageBoxType type,
|
MessageBoxType type,
|
||||||
const std::vector<std::string>& buttons,
|
const std::vector<std::string>& buttons,
|
||||||
int default_button_index,
|
int default_id,
|
||||||
int cancel_id,
|
int cancel_id,
|
||||||
int options,
|
int options,
|
||||||
const std::string& title,
|
const std::string& title,
|
||||||
|
@ -229,7 +229,7 @@ void ShowMessageBox(NativeWindow* parent,
|
||||||
unretained->message_loop()->PostTask(
|
unretained->message_loop()->PostTask(
|
||||||
FROM_HERE,
|
FROM_HERE,
|
||||||
base::Bind(&RunMessageBoxInNewThread, base::Unretained(unretained),
|
base::Bind(&RunMessageBoxInNewThread, base::Unretained(unretained),
|
||||||
parent, type, buttons, default_button_index,
|
parent, type, buttons, default_id,
|
||||||
cancel_id, options, title, message, detail, icon, callback));
|
cancel_id, options, title, message, detail, icon, callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ will be passed via `callback(filename)`
|
||||||
`"warning"`. On Windows, "question" displays the same icon as "info", unless
|
`"warning"`. On Windows, "question" displays the same icon as "info", unless
|
||||||
you set an icon using the "icon" option.
|
you set an icon using the "icon" option.
|
||||||
* `buttons` Array - Array of texts for buttons.
|
* `buttons` Array - Array of texts for buttons.
|
||||||
* `defaultButtonIndex` Integer - Index of the button in the buttons array which will be selected by default when the message box opens.
|
* `defaultId` Integer - Index of the button in the buttons array which will be selected by default when the message box opens.
|
||||||
* `title` String - Title of the message box, some platforms will not show it.
|
* `title` String - Title of the message box, some platforms will not show it.
|
||||||
* `message` String - Content of the message box.
|
* `message` String - Content of the message box.
|
||||||
* `detail` String - Extra information of the message.
|
* `detail` String - Extra information of the message.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче