Add "icon" option for message box

This commit is contained in:
Cheng Zhao 2015-01-05 15:08:42 -08:00
parent 513052de87
commit 8457090b18
5 changed files with 64 additions and 29 deletions

View file

@ -11,6 +11,7 @@
#include "atom/browser/ui/file_dialog.h"
#include "atom/browser/ui/message_box.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/native_mate_converters/image_converter.h"
#include "native_mate/callback.h"
#include "native_mate/dictionary.h"
@ -40,21 +41,27 @@ namespace {
void ShowMessageBox(int type,
const std::vector<std::string>& buttons,
const std::string& title,
const std::string& message,
const std::string& detail,
const std::vector<std::string>& texts,
const gfx::ImageSkia& icon,
atom::NativeWindow* window,
mate::Arguments* args) {
// FIXME We are exceeding the parameters limit of base::Bind here, so we have
// to pass some parameters in an array. We should remove this once we have
// variadic template support in base::Bind.
const std::string& title = texts[0];
const std::string& message = texts[1];
const std::string& detail = texts[2];
v8::Handle<v8::Value> peek = args->PeekNext();
atom::MessageBoxCallback callback;
if (mate::Converter<atom::MessageBoxCallback>::FromV8(args->isolate(),
peek,
&callback)) {
atom::ShowMessageBox(window, (atom::MessageBoxType)type, buttons, title,
message, detail, callback);
message, detail, icon, callback);
} else {
int chosen = atom::ShowMessageBox(window, (atom::MessageBoxType)type,
buttons, title, message, detail);
buttons, title, message, detail, icon);
args->Return(chosen);
}
}
@ -62,6 +69,7 @@ void ShowMessageBox(int type,
void ShowOpenDialog(const std::string& title,
const base::FilePath& default_path,
const file_dialog::Filters& filters,
const gfx::ImageSkia& icon,
int properties,
atom::NativeWindow* window,
mate::Arguments* args) {
@ -83,6 +91,7 @@ void ShowOpenDialog(const std::string& title,
void ShowSaveDialog(const std::string& title,
const base::FilePath& default_path,
const file_dialog::Filters& filters,
const gfx::ImageSkia& icon,
atom::NativeWindow* window,
mate::Arguments* args) {
v8::Handle<v8::Value> peek = args->PeekNext();