run clang-format on changed sources
This commit is contained in:
parent
d30310a2f2
commit
5e7a5ce3a9
3 changed files with 50 additions and 62 deletions
|
@ -25,9 +25,8 @@ gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info,
|
|||
// Makes .* file extension matches all file types.
|
||||
if (*file_extension == ".*")
|
||||
return true;
|
||||
return base::EndsWith(
|
||||
file_info->filename,
|
||||
*file_extension, base::CompareCase::INSENSITIVE_ASCII);
|
||||
return base::EndsWith(file_info->filename, *file_extension,
|
||||
base::CompareCase::INSENSITIVE_ASCII);
|
||||
}
|
||||
|
||||
// Deletes |data| when gtk_file_filter_add_custom() is done with it.
|
||||
|
@ -37,8 +36,7 @@ void OnFileFilterDataDestroyed(std::string* file_extension) {
|
|||
|
||||
class FileChooserDialog {
|
||||
public:
|
||||
FileChooserDialog(GtkFileChooserAction action,
|
||||
const DialogSettings& settings)
|
||||
FileChooserDialog(GtkFileChooserAction action, const DialogSettings& settings)
|
||||
: parent_(static_cast<atom::NativeWindowViews*>(settings.parent_window)),
|
||||
filters_(settings.filters) {
|
||||
const char* confirm_text = _("_OK");
|
||||
|
@ -51,12 +49,8 @@ class FileChooserDialog {
|
|||
confirm_text = _("_Open");
|
||||
|
||||
dialog_ = gtk_file_chooser_dialog_new(
|
||||
settings.title.c_str(),
|
||||
NULL,
|
||||
action,
|
||||
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||
confirm_text, GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
settings.title.c_str(), NULL, action, _("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||
confirm_text, GTK_RESPONSE_ACCEPT, NULL);
|
||||
if (parent_) {
|
||||
parent_->SetEnabled(false);
|
||||
libgtkui::SetGtkTransientForAura(dialog_, parent_->GetNativeWindow());
|
||||
|
@ -71,8 +65,8 @@ class FileChooserDialog {
|
|||
|
||||
if (!settings.default_path.empty()) {
|
||||
if (base::DirectoryExists(settings.default_path)) {
|
||||
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog_),
|
||||
settings.default_path.value().c_str());
|
||||
gtk_file_chooser_set_current_folder(
|
||||
GTK_FILE_CHOOSER(dialog_), settings.default_path.value().c_str());
|
||||
} else {
|
||||
if (settings.default_path.IsAbsolute()) {
|
||||
gtk_file_chooser_set_current_folder(
|
||||
|
@ -80,7 +74,8 @@ class FileChooserDialog {
|
|||
settings.default_path.DirName().value().c_str());
|
||||
}
|
||||
|
||||
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog_),
|
||||
gtk_file_chooser_set_current_name(
|
||||
GTK_FILE_CHOOSER(dialog_),
|
||||
settings.default_path.BaseName().value().c_str());
|
||||
}
|
||||
}
|
||||
|
@ -105,8 +100,8 @@ class FileChooserDialog {
|
|||
void RunAsynchronous() {
|
||||
g_signal_connect(dialog_, "delete-event",
|
||||
G_CALLBACK(gtk_widget_hide_on_delete), NULL);
|
||||
g_signal_connect(dialog_, "response",
|
||||
G_CALLBACK(OnFileDialogResponseThunk), this);
|
||||
g_signal_connect(dialog_, "response", G_CALLBACK(OnFileDialogResponseThunk),
|
||||
this);
|
||||
gtk_widget_show_all(dialog_);
|
||||
|
||||
// We need to call gtk_window_present after making the widgets visible to
|
||||
|
@ -134,11 +129,11 @@ class FileChooserDialog {
|
|||
|
||||
std::vector<base::FilePath> GetFileNames() const {
|
||||
std::vector<base::FilePath> paths;
|
||||
GSList* filenames = gtk_file_chooser_get_filenames(
|
||||
GTK_FILE_CHOOSER(dialog_));
|
||||
GSList* filenames =
|
||||
gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog_));
|
||||
for (GSList* iter = filenames; iter != NULL; iter = g_slist_next(iter)) {
|
||||
base::FilePath path = AddExtensionForFilename(
|
||||
static_cast<char*>(iter->data));
|
||||
base::FilePath path =
|
||||
AddExtensionForFilename(static_cast<char*>(iter->data));
|
||||
g_free(iter->data);
|
||||
paths.push_back(path);
|
||||
}
|
||||
|
@ -192,8 +187,7 @@ void FileChooserDialog::AddFilters(const Filters& filters) {
|
|||
std::unique_ptr<std::string> file_extension(
|
||||
new std::string("." + filter.second[j]));
|
||||
gtk_file_filter_add_custom(
|
||||
gtk_filter,
|
||||
GTK_FILE_FILTER_FILENAME,
|
||||
gtk_filter, GTK_FILE_FILTER_FILENAME,
|
||||
reinterpret_cast<GtkFileFilterFunc>(FileFilterCaseInsensitive),
|
||||
file_extension.release(),
|
||||
reinterpret_cast<GDestroyNotify>(OnFileFilterDataDestroyed));
|
||||
|
@ -229,7 +223,6 @@ base::FilePath FileChooserDialog::AddExtensionForFilename(
|
|||
return path.ReplaceExtension(extensions[0]);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
bool ShowOpenDialog(const DialogSettings& settings,
|
||||
|
@ -260,8 +253,7 @@ void ShowOpenDialog(const DialogSettings& settings,
|
|||
open_dialog->RunOpenAsynchronous(callback);
|
||||
}
|
||||
|
||||
bool ShowSaveDialog(const DialogSettings& settings,
|
||||
base::FilePath* path) {
|
||||
bool ShowSaveDialog(const DialogSettings& settings, base::FilePath* path) {
|
||||
FileChooserDialog save_dialog(GTK_FILE_CHOOSER_ACTION_SAVE, settings);
|
||||
gtk_widget_show_all(save_dialog.dialog());
|
||||
int response = gtk_dialog_run(GTK_DIALOG(save_dialog.dialog()));
|
||||
|
@ -275,8 +267,8 @@ bool ShowSaveDialog(const DialogSettings& settings,
|
|||
|
||||
void ShowSaveDialog(const DialogSettings& settings,
|
||||
const SaveDialogCallback& callback) {
|
||||
FileChooserDialog* save_dialog = new FileChooserDialog(
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE, settings);
|
||||
FileChooserDialog* save_dialog =
|
||||
new FileChooserDialog(GTK_FILE_CHOOSER_ACTION_SAVE, settings);
|
||||
save_dialog->RunSaveAsynchronous(callback);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
#include "chrome/browser/ui/libgtkui/skia_utils_gtk.h"
|
||||
#include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
|
||||
|
||||
#define ANSI_FOREGROUND_RED "\x1b[31m"
|
||||
#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"
|
||||
#define ANSI_TEXT_BOLD "\x1b[1m"
|
||||
#define ANSI_BACKGROUND_GRAY "\x1b[47m"
|
||||
#define ANSI_RESET "\x1b[0m"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -44,15 +44,15 @@ class GtkMessageBox : public NativeWindowObserver {
|
|||
checkbox_checked_(false),
|
||||
parent_(static_cast<NativeWindow*>(parent_window)) {
|
||||
// Create dialog.
|
||||
dialog_ = gtk_message_dialog_new(
|
||||
nullptr, // parent
|
||||
static_cast<GtkDialogFlags>(0), // no flags
|
||||
GetMessageType(type), // type
|
||||
GTK_BUTTONS_NONE, // no buttons
|
||||
"%s", message.c_str());
|
||||
dialog_ =
|
||||
gtk_message_dialog_new(nullptr, // parent
|
||||
static_cast<GtkDialogFlags>(0), // no flags
|
||||
GetMessageType(type), // type
|
||||
GTK_BUTTONS_NONE, // no buttons
|
||||
"%s", message.c_str());
|
||||
if (!detail.empty())
|
||||
gtk_message_dialog_format_secondary_text(
|
||||
GTK_MESSAGE_DIALOG(dialog_), "%s", detail.c_str());
|
||||
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog_),
|
||||
"%s", detail.c_str());
|
||||
if (!title.empty())
|
||||
gtk_window_set_title(GTK_WINDOW(dialog_), title.c_str());
|
||||
|
||||
|
@ -142,8 +142,8 @@ class GtkMessageBox : public NativeWindowObserver {
|
|||
callback_ = callback;
|
||||
g_signal_connect(dialog_, "delete-event",
|
||||
G_CALLBACK(gtk_widget_hide_on_delete), nullptr);
|
||||
g_signal_connect(dialog_, "response",
|
||||
G_CALLBACK(OnResponseDialogThunk), this);
|
||||
g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseDialogThunk),
|
||||
this);
|
||||
Show();
|
||||
}
|
||||
|
||||
|
@ -226,11 +226,8 @@ void ShowErrorBox(const base::string16& title, const base::string16& content) {
|
|||
base::UTF16ToUTF8(content).c_str(), "", false)
|
||||
.RunSynchronous();
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
ANSI_TEXT_BOLD ANSI_BACKGROUND_GRAY
|
||||
ANSI_FOREGROUND_RED "%s\n"
|
||||
ANSI_FOREGROUND_BLACK "%s"
|
||||
ANSI_RESET "\n",
|
||||
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());
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ namespace {
|
|||
#if defined(USE_X11)
|
||||
|
||||
SkColor GdkRgbaToSkColor(const GdkRGBA& rgba) {
|
||||
return SkColorSetARGB(rgba.alpha*255, rgba.red*255,
|
||||
rgba.green*255, rgba.blue*255);
|
||||
return SkColorSetARGB(rgba.alpha * 255, rgba.red * 255, rgba.green * 255,
|
||||
rgba.blue * 255);
|
||||
}
|
||||
|
||||
SkColor GetStyleContextFgColor(GtkStyleContext* style_context,
|
||||
|
@ -45,14 +45,17 @@ SkColor GetStyleContextBgColor(GtkStyleContext* style_context,
|
|||
return GdkRgbaToSkColor(rgba);
|
||||
}
|
||||
|
||||
void GetMenuBarColor(SkColor* enabled, SkColor* disabled, SkColor* highlight,
|
||||
SkColor* hover, SkColor* background) {
|
||||
void GetMenuBarColor(SkColor* enabled,
|
||||
SkColor* disabled,
|
||||
SkColor* highlight,
|
||||
SkColor* hover,
|
||||
SkColor* background) {
|
||||
GtkWidget* menu_bar = gtk_menu_bar_new();
|
||||
GtkStyleContext* sc = gtk_widget_get_style_context(menu_bar);
|
||||
*enabled = GetStyleContextFgColor(sc, GTK_STATE_FLAG_NORMAL);
|
||||
*disabled = GetStyleContextFgColor(sc, GTK_STATE_FLAG_INSENSITIVE);
|
||||
*highlight = GetStyleContextFgColor(sc, GTK_STATE_FLAG_SELECTED);
|
||||
*hover = GetStyleContextFgColor(sc, GTK_STATE_FLAG_PRELIGHT);
|
||||
*enabled = GetStyleContextFgColor(sc, GTK_STATE_FLAG_NORMAL);
|
||||
*disabled = GetStyleContextFgColor(sc, GTK_STATE_FLAG_INSENSITIVE);
|
||||
*highlight = GetStyleContextFgColor(sc, GTK_STATE_FLAG_SELECTED);
|
||||
*hover = GetStyleContextFgColor(sc, GTK_STATE_FLAG_PRELIGHT);
|
||||
*background = GetStyleContextBgColor(sc, GTK_STATE_FLAG_NORMAL);
|
||||
g_object_unref(G_OBJECT(menu_bar));
|
||||
}
|
||||
|
@ -67,24 +70,20 @@ const SkColor kDefaultColor = SkColorSetARGB(255, 233, 233, 233);
|
|||
} // namespace
|
||||
|
||||
MenuBar::MenuBar(NativeWindow* window)
|
||||
: background_color_(kDefaultColor),
|
||||
menu_model_(NULL),
|
||||
window_(window) {
|
||||
: background_color_(kDefaultColor), menu_model_(NULL), window_(window) {
|
||||
UpdateMenuBarColor();
|
||||
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal));
|
||||
}
|
||||
|
||||
MenuBar::~MenuBar() {
|
||||
}
|
||||
MenuBar::~MenuBar() {}
|
||||
|
||||
void MenuBar::SetMenu(AtomMenuModel* model) {
|
||||
menu_model_ = model;
|
||||
RemoveAllChildViews(true);
|
||||
|
||||
for (int i = 0; i < model->GetItemCount(); ++i) {
|
||||
SubmenuButton* button = new SubmenuButton(model->GetLabelAt(i),
|
||||
this,
|
||||
background_color_);
|
||||
SubmenuButton* button =
|
||||
new SubmenuButton(model->GetLabelAt(i), this, background_color_);
|
||||
button->set_tag(i);
|
||||
|
||||
#if defined(USE_X11)
|
||||
|
|
Loading…
Reference in a new issue