]> khamidou — GitHub mirrors - electron.git/commitdiff
gtk: Make synchronous message box work.
authorCheng Zhao <zcbenz@gmail.com>
Wed, 12 Mar 2014 13:17:13 +0000 (21:17 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 12 Mar 2014 13:17:13 +0000 (21:17 +0800)
browser/ui/message_box_gtk.cc

index f2988f6d5c183b7e319165f2fe8a753e5748319c..0fbb156f7dd95afd256373de3a94208cf22a839b 100644 (file)
@@ -78,6 +78,7 @@ class MessageBox {
   CHROMEGTK_CALLBACK_1(MessageBox, void, OnResponseDialog, int);
 
   GtkWidget* dialog() const { return dialog_; }
+  int cancel_id() const { return cancel_id_; }
 
  private:
   GtkWidget* dialog_;
@@ -107,7 +108,13 @@ int ShowMessageBox(NativeWindow* parent_window,
                    const std::string& title,
                    const std::string& message,
                    const std::string& detail) {
-  return 0;
+  MessageBox message_box(parent_window, type, buttons, title, message, detail);
+  gtk_widget_show_all(message_box.dialog());
+  int response = gtk_dialog_run(GTK_DIALOG(message_box.dialog()));
+  if (response < 0)
+    return message_box.cancel_id();
+  else
+    return response;
 }
 
 void ShowMessageBox(NativeWindow* parent_window,