From: Cheng Zhao Date: Wed, 12 Mar 2014 12:17:22 +0000 (+0800) Subject: gtk: Initial implementation of message box. X-Git-Tag: v0.11.0~9^2~6 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=6b9148127e19bbd583f0cc756cdfd45f6dcff2f6;p=electron.git gtk: Initial implementation of message box. --- diff --git a/browser/ui/message_box_gtk.cc b/browser/ui/message_box_gtk.cc index f5fc72ee..a7eed861 100644 --- a/browser/ui/message_box_gtk.cc +++ b/browser/ui/message_box_gtk.cc @@ -4,7 +4,10 @@ #include "browser/ui/message_box.h" +#include + #include "base/callback.h" +#include "browser/native_window.h" namespace atom { @@ -24,6 +27,24 @@ void ShowMessageBox(NativeWindow* parent_window, const std::string& message, const std::string& detail, const MessageBoxCallback& callback) { + GtkWindow* window = parent_window ? parent_window->GetNativeWindow() : NULL; + GtkWidget* dialog = gtk_dialog_new_with_buttons( + title.c_str(), + window, + static_cast(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), + NULL); + + for (size_t i = 0; i < buttons.size(); ++i) + gtk_dialog_add_button(GTK_DIALOG(dialog), buttons[i].c_str(), i); + + GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); + GtkWidget* message_label = gtk_label_new(message.c_str()); + gtk_box_pack_start(GTK_BOX(content_area), message_label, FALSE, FALSE, 0); + GtkWidget* detail_label = gtk_label_new(detail.c_str()); + gtk_box_pack_start(GTK_BOX(content_area), detail_label, FALSE, FALSE, 0); + + gtk_widget_show_all(dialog); + callback.Run(0); }