Final cleanup

This commit is contained in:
Cheng Zhao 2015-07-08 16:23:43 +08:00
parent aab78db8b8
commit 001b4a3179
2 changed files with 20 additions and 13 deletions

View file

@ -113,4 +113,5 @@ module.exports =
binding.showErrorBox args... binding.showErrorBox args...
# Mark standard asynchronous functions. # Mark standard asynchronous functions.
v8Util.setHiddenValue f, 'asynchronous', true for k, f of module.exports for api in ['showMessageBox', 'showOpenDialog', 'showSaveDialog']
v8Util.setHiddenValue module.exports[api], 'asynchronous', true

View file

@ -4,12 +4,12 @@
#include "atom/browser/ui/message_box.h" #include "atom/browser/ui/message_box.h"
#include <map>
#include <vector>
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <map>
#include <vector>
#include "atom/browser/native_window_views.h" #include "atom/browser/native_window_views.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
@ -76,8 +76,7 @@ int ShowMessageBoxUTF16(HWND parent,
const base::string16& message, const base::string16& message,
const base::string16& detail, const base::string16& detail,
const gfx::ImageSkia& icon) { const gfx::ImageSkia& icon) {
TASKDIALOG_FLAGS flags = TDF_SIZE_TO_CONTENT | // show all content. TASKDIALOG_FLAGS flags = TDF_SIZE_TO_CONTENT; // show all content.
TDF_USE_COMMAND_LINKS; // custom buttons as links.
if (cancel_id != 0) if (cancel_id != 0)
flags |= TDF_ALLOW_DIALOG_CANCELLATION; // allow dialog to be cancelled. flags |= TDF_ALLOW_DIALOG_CANCELLATION; // allow dialog to be cancelled.
@ -86,6 +85,8 @@ int ShowMessageBoxUTF16(HWND parent,
config.hwndParent = parent; config.hwndParent = parent;
config.hInstance = GetModuleHandle(NULL); config.hInstance = GetModuleHandle(NULL);
config.dwFlags = flags; config.dwFlags = flags;
if (!title.empty())
config.pszWindowTitle = title.c_str(); config.pszWindowTitle = title.c_str();
base::win::ScopedHICON hicon; base::win::ScopedHICON hicon;
@ -121,8 +122,11 @@ int ShowMessageBoxUTF16(HWND parent,
std::map<int, int> id_map; std::map<int, int> id_map;
std::vector<TASKDIALOG_BUTTON> dialog_buttons; std::vector<TASKDIALOG_BUTTON> dialog_buttons;
MapToCommonID(buttons, &id_map, &config.dwCommonButtons, &dialog_buttons); MapToCommonID(buttons, &id_map, &config.dwCommonButtons, &dialog_buttons);
if (dialog_buttons.size() > 0) {
config.pButtons = &dialog_buttons.front(); config.pButtons = &dialog_buttons.front();
config.cButtons = dialog_buttons.size(); config.cButtons = dialog_buttons.size();
config.dwFlags |= TDF_USE_COMMAND_LINKS; // custom buttons as links.
}
int id = 0; int id = 0;
TaskDialogIndirect(&config, &id, NULL, NULL); TaskDialogIndirect(&config, &id, NULL, NULL);
@ -207,6 +211,8 @@ void ShowMessageBox(NativeWindow* parent,
} }
void ShowErrorBox(const base::string16& title, const base::string16& content) { void ShowErrorBox(const base::string16& title, const base::string16& content) {
ShowMessageBoxUTF16(NULL, MESSAGE_BOX_TYPE_ERROR, {}, 0, L"Error", title,
content, gfx::ImageSkia());
} }
} // namespace atom } // namespace atom