Skip to content

Commit

Permalink
fix: message box missing an "OK" button in GTK (#26917)
Browse files Browse the repository at this point in the history
Co-authored-by: Mimi <1119186082@qq.com>
  • Loading branch information
trop[bot] and stevenjoezhang committed Dec 10, 2020
1 parent 37d21bb commit fb35356
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions shell/browser/ui/message_box_gtk.cc
Expand Up @@ -87,9 +87,13 @@ class GtkMessageBox : public NativeWindowObserver {

// Add buttons.
GtkDialog* dialog = GTK_DIALOG(dialog_);
for (size_t i = 0; i < settings.buttons.size(); ++i) {
gtk_dialog_add_button(dialog, TranslateToStock(i, settings.buttons[i]),
i);
if (settings.buttons.size() == 0) {
gtk_dialog_add_button(dialog, TranslateToStock(0, "OK"), 0);
} else {
for (size_t i = 0; i < settings.buttons.size(); ++i) {
gtk_dialog_add_button(dialog, TranslateToStock(i, settings.buttons[i]),
i);
}
}
gtk_dialog_set_default_response(dialog, settings.default_id);

Expand Down Expand Up @@ -220,7 +224,7 @@ void ShowErrorBox(const base::string16& title, const base::string16& content) {
if (Browser::Get()->is_ready()) {
electron::MessageBoxSettings settings;
settings.type = electron::MessageBoxType::kError;
settings.buttons = {"OK"};
settings.buttons = {};
settings.title = "Error";
settings.message = base::UTF16ToUTF8(title);
settings.detail = base::UTF16ToUTF8(content);
Expand Down

0 comments on commit fb35356

Please sign in to comment.