From: leethomas Date: Fri, 8 Jan 2016 05:23:15 +0000 (-0800) Subject: :penguin: add default button index for linux/gtk X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=22c455175aac98e8027ba4f2965c3e526ac84fe9;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git :penguin: add default button index for linux/gtk --- diff --git a/atom/browser/ui/message_box_gtk.cc b/atom/browser/ui/message_box_gtk.cc index de8d994..65f5579 100644 --- a/atom/browser/ui/message_box_gtk.cc +++ b/atom/browser/ui/message_box_gtk.cc @@ -29,6 +29,7 @@ class GtkMessageBox { GtkMessageBox(NativeWindow* parent_window, MessageBoxType type, const std::vector& buttons, + int default_button_index, int cancel_id, const std::string& title, const std::string& message, @@ -60,9 +61,16 @@ class GtkMessageBox { // Add buttons. for (size_t i = 0; i < buttons.size(); ++i) { - gtk_dialog_add_button(GTK_DIALOG(dialog_), + if (i == (size_t)default_button_index) { + GtkWidget* button = gtk_dialog_add_button(GTK_DIALOG(dialog_), + TranslateToStock(i, buttons[i]), + i); + gtk_widget_grab_focus(button); + } else { + gtk_dialog_add_button(GTK_DIALOG(dialog_), TranslateToStock(i, buttons[i]), i); + } } // Parent window. @@ -161,19 +169,21 @@ void GtkMessageBox::OnResponseDialog(GtkWidget* widget, int response) { int ShowMessageBox(NativeWindow* parent, MessageBoxType type, const std::vector& buttons, + int default_button_index, int cancel_id, int options, const std::string& title, const std::string& message, const std::string& detail, const gfx::ImageSkia& icon) { - return GtkMessageBox(parent, type, buttons, cancel_id, title, message, detail, + return GtkMessageBox(parent, type, buttons, default_button_index, cancel_id, title, message, detail, icon).RunSynchronous(); } void ShowMessageBox(NativeWindow* parent, MessageBoxType type, const std::vector& buttons, + int default_button_index, int cancel_id, int options, const std::string& title, @@ -181,13 +191,13 @@ void ShowMessageBox(NativeWindow* parent, const std::string& detail, const gfx::ImageSkia& icon, const MessageBoxCallback& callback) { - (new GtkMessageBox(parent, type, buttons, cancel_id, title, message, detail, + (new GtkMessageBox(parent, type, buttons, default_button_index, cancel_id, title, message, detail, icon))->RunAsynchronous(callback); } void ShowErrorBox(const base::string16& title, const base::string16& content) { if (Browser::Get()->is_ready()) { - GtkMessageBox(nullptr, MESSAGE_BOX_TYPE_ERROR, { "OK" }, 0, "Error", + GtkMessageBox(nullptr, MESSAGE_BOX_TYPE_ERROR, { "OK" }, -1, 0, "Error", base::UTF16ToUTF8(title).c_str(), base::UTF16ToUTF8(content).c_str(), gfx::ImageSkia()).RunSynchronous();