diff --git a/atom/browser/ui/message_box_gtk.cc b/atom/browser/ui/message_box_gtk.cc new file mode 100644 index 00000000000..90a8d4a04ca --- /dev/null +++ b/atom/browser/ui/message_box_gtk.cc @@ -0,0 +1,63 @@ +// Copyright (c) 2015 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "atom/browser/ui/message_box.h" + +#include + +#include "atom/browser/browser.h" +#include "base/callback.h" +#include "base/strings/utf_string_conversions.h" + +#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 { + +int ShowMessageBox(NativeWindow* parent_window, + MessageBoxType type, + const std::vector& buttons, + const std::string& title, + const std::string& message, + const std::string& detail, + const gfx::ImageSkia& icon) { + return 0; +} + +void ShowMessageBox(NativeWindow* parent_window, + MessageBoxType type, + const std::vector& buttons, + const std::string& title, + const std::string& message, + const std::string& detail, + const gfx::ImageSkia& icon, + const MessageBoxCallback& callback) { + callback.Run(0); +} + +void ShowErrorBox(const base::string16& title, const base::string16& content) { + if (Browser::Get()->is_ready()) { + GtkWidget* dialog = gtk_message_dialog_new( + NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, + "%s", base::UTF16ToUTF8(title).c_str()); + gtk_message_dialog_format_secondary_text( + GTK_MESSAGE_DIALOG(dialog), + "%s", base::UTF16ToUTF8(content).c_str()); + gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); + } 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()); + } +} + +} // namespace atom diff --git a/atom/browser/ui/message_box_views.cc b/atom/browser/ui/message_box_win.cc similarity index 90% rename from atom/browser/ui/message_box_views.cc rename to atom/browser/ui/message_box_win.cc index 6e1cc9daa2b..508d6eb233d 100644 --- a/atom/browser/ui/message_box_views.cc +++ b/atom/browser/ui/message_box_win.cc @@ -4,10 +4,6 @@ #include "atom/browser/ui/message_box.h" -#if defined(USE_X11) -#include -#endif - #include "atom/browser/native_window.h" #include "base/callback.h" #include "base/message_loop/message_loop.h" @@ -26,21 +22,10 @@ #include "ui/views/widget/widget_delegate.h" #include "ui/wm/core/shadow_types.h" -#if defined(USE_X11) -#include "atom/browser/browser.h" -#include "ui/views/window/native_frame_view.h" -#endif - #if defined(OS_WIN) #include "ui/base/win/message_box_win.h" #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 { @@ -276,13 +261,8 @@ ui::ModalType MessageDialog::GetModalType() const { views::NonClientFrameView* MessageDialog::CreateNonClientFrameView( views::Widget* widget) { - if (!parent_) { -#if defined(USE_X11) - return new views::NativeFrameView(widget); -#else + if (!parent_) return NULL; -#endif - } // Create a bubble style frame like Chrome. views::BubbleFrameView* frame = new views::BubbleFrameView(gfx::Insets()); @@ -390,28 +370,7 @@ void ShowMessageBox(NativeWindow* parent_window, } void ShowErrorBox(const base::string16& title, const base::string16& content) { -#if defined(OS_WIN) ui::MessageBox(NULL, content, title, MB_OK | MB_ICONERROR | MB_TASKMODAL); -#elif defined(USE_X11) - if (Browser::Get()->is_ready()) { - GtkWidget* dialog = gtk_message_dialog_new( - NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - "%s", base::UTF16ToUTF8(title).c_str()); - gtk_message_dialog_format_secondary_text( - GTK_MESSAGE_DIALOG(dialog), - "%s", base::UTF16ToUTF8(content).c_str()); - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); - } 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 } } // namespace atom diff --git a/filenames.gypi b/filenames.gypi index 3f299c066a6..837dd3301cc 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -175,8 +175,9 @@ 'atom/browser/ui/file_dialog_mac.mm', 'atom/browser/ui/file_dialog_win.cc', 'atom/browser/ui/message_box.h', + 'atom/browser/ui/message_box_gtk.cc', 'atom/browser/ui/message_box_mac.mm', - 'atom/browser/ui/message_box_views.cc', + 'atom/browser/ui/message_box_win.cc', 'atom/browser/ui/tray_icon.cc', 'atom/browser/ui/tray_icon.h', 'atom/browser/ui/tray_icon_gtk.cc',