linux: Print error to console when GUI is not ready

This commit is contained in:
Cheng Zhao 2014-11-05 18:58:00 +08:00
parent c499dfbb22
commit b54caccb22

View file

@ -4,6 +4,10 @@
#include "atom/browser/ui/message_box.h" #include "atom/browser/ui/message_box.h"
#if defined(USE_X11)
#include <gtk/gtk.h>
#endif
#include "atom/browser/native_window.h" #include "atom/browser/native_window.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
@ -23,6 +27,7 @@
#include "ui/wm/core/shadow_types.h" #include "ui/wm/core/shadow_types.h"
#if defined(USE_X11) #if defined(USE_X11)
#include "atom/browser/browser.h"
#include "ui/views/window/native_frame_view.h" #include "ui/views/window/native_frame_view.h"
#endif #endif
@ -30,6 +35,12 @@
#include "ui/base/win/message_box_win.h" #include "ui/base/win/message_box_win.h"
#endif #endif
#define ANSI_FOREGROUND_RED "\x1b[31m"
#define ANSI_FOREGROUND_BLACK "\x1b[30m"
#define ANSI_TEXT_BOLD "\x1b[1m"
#define ANSI_BACKGROUND_GRAY "\x1b[47m"
#define ANSI_RESET "\x1b[0m"
namespace atom { namespace atom {
namespace { namespace {
@ -357,6 +368,17 @@ void ShowMessageBox(NativeWindow* parent_window,
void ShowErrorBox(const base::string16& title, const base::string16& content) { void ShowErrorBox(const base::string16& title, const base::string16& content) {
#if defined(OS_WIN) #if defined(OS_WIN)
ui::MessageBox(NULL, content, title, MB_OK | MB_ICONERROR | MB_TASKMODAL); ui::MessageBox(NULL, content, title, MB_OK | MB_ICONERROR | MB_TASKMODAL);
#elif defined(USE_X11)
if (Browser::Get()->is_ready()) {
} else {
fprintf(stderr,
ANSI_TEXT_BOLD ANSI_BACKGROUND_GRAY
ANSI_FOREGROUND_RED "%s\n"
ANSI_FOREGROUND_BLACK "%s"
ANSI_RESET "\n",
base::UTF16ToUTF8(title).c_str(),
base::UTF16ToUTF8(content).c_str());
}
#endif #endif
} }