Fix style issues of #4029
This commit is contained in:
parent
edcd34d4ce
commit
26bd97d6cf
4 changed files with 24 additions and 28 deletions
|
@ -61,16 +61,10 @@ 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_id) {
|
GtkWidget* button = gtk_dialog_add_button(
|
||||||
GtkWidget* button = gtk_dialog_add_button(GTK_DIALOG(dialog_),
|
GTK_DIALOG(dialog_), TranslateToStock(i, buttons[i]), i);
|
||||||
TranslateToStock(i, buttons[i]),
|
if (static_cast<int>(i) == default_id)
|
||||||
i);
|
|
||||||
gtk_widget_grab_focus(button);
|
gtk_widget_grab_focus(button);
|
||||||
} else {
|
|
||||||
gtk_dialog_add_button(GTK_DIALOG(dialog_),
|
|
||||||
TranslateToStock(i, buttons[i]),
|
|
||||||
i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parent window.
|
// Parent window.
|
||||||
|
|
|
@ -79,17 +79,17 @@ NSAlert* CreateNSAlert(NativeWindow* parent_window,
|
||||||
// An empty title causes crash on OS X.
|
// An empty title causes crash on OS X.
|
||||||
if (buttons[i].empty())
|
if (buttons[i].empty())
|
||||||
title = @"(empty)";
|
title = @"(empty)";
|
||||||
|
|
||||||
NSButton* button = [alert addButtonWithTitle:title];
|
NSButton* button = [alert addButtonWithTitle:title];
|
||||||
[button setTag:i];
|
[button setTag:i];
|
||||||
|
}
|
||||||
|
|
||||||
if (i == (size_t)default_id) {
|
NSArray* ns_buttons = [alert buttons];
|
||||||
|
if (default_id >= 0 && default_id < static_cast<int>([ns_buttons count])) {
|
||||||
// Focus the button at default_id 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:@""];
|
[[ns_buttons objectAtIndex:0] setKeyEquivalent:@""];
|
||||||
[button setKeyEquivalent:@"\r"];
|
[[ns_buttons objectAtIndex:default_id] setKeyEquivalent:@"\r"];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return alert;
|
return alert;
|
||||||
|
|
|
@ -88,7 +88,9 @@ int ShowMessageBoxUTF16(HWND parent,
|
||||||
config.hwndParent = parent;
|
config.hwndParent = parent;
|
||||||
config.hInstance = GetModuleHandle(NULL);
|
config.hInstance = GetModuleHandle(NULL);
|
||||||
config.dwFlags = flags;
|
config.dwFlags = flags;
|
||||||
config.nDefaultButton = default_id ? (kIDStart + default_id) : 0;
|
|
||||||
|
if (default_id > 0)
|
||||||
|
config.nDefaultButton = kIDStart + default_id;
|
||||||
|
|
||||||
// TaskDialogIndirect doesn't allow empty name, if we set empty title it
|
// TaskDialogIndirect doesn't allow empty name, if we set empty title it
|
||||||
// will show "electron.exe" in title.
|
// will show "electron.exe" in title.
|
||||||
|
@ -230,8 +232,8 @@ 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_id,
|
parent, type, buttons, default_id, cancel_id, options, title,
|
||||||
cancel_id, options, title, message, detail, icon, callback));
|
message, detail, icon, callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowErrorBox(const base::string16& title, const base::string16& content) {
|
void ShowErrorBox(const base::string16& title, const base::string16& content) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue