remove icons from messageboxes on gtk

Icons are deprecated in GtkMessageBoxes as of GTK+ 3.12. The GNOME HIG no longer shows icons in example dialogs; see https://developer.gnome.org/hig/stable/dialogs.html.en and https://developer.gnome.org/gtk3/stable/GtkMessageDialog.html
This commit is contained in:
Charles Kerr 2018-02-09 17:53:02 -06:00
parent ffff400236
commit b107d3f440

View file

@ -39,8 +39,7 @@ class GtkMessageBox : public NativeWindowObserver {
const std::string& message, const std::string& message,
const std::string& detail, const std::string& detail,
const std::string& checkbox_label, const std::string& checkbox_label,
bool checkbox_checked, bool checkbox_checked)
const gfx::ImageSkia& icon)
: cancel_id_(cancel_id), : cancel_id_(cancel_id),
checkbox_checked_(false), checkbox_checked_(false),
parent_(static_cast<NativeWindow*>(parent_window)) { parent_(static_cast<NativeWindow*>(parent_window)) {
@ -57,22 +56,6 @@ class GtkMessageBox : public NativeWindowObserver {
if (!title.empty()) if (!title.empty())
gtk_window_set_title(GTK_WINDOW(dialog_), title.c_str()); gtk_window_set_title(GTK_WINDOW(dialog_), title.c_str());
// Set dialog's icon.
if (!icon.isNull()) {
GdkPixbuf* pixbuf = libgtkui::GdkPixbufFromSkBitmap(*icon.bitmap());
GtkIconSource* iconsource = gtk_icon_source_new();
GtkIconSet* iconset = gtk_icon_set_new();
gtk_icon_source_set_pixbuf(iconsource, pixbuf);
gtk_icon_set_add_source(iconset, iconsource);
GtkWidget* image = gtk_image_new_from_icon_set(iconset,
GTK_ICON_SIZE_DIALOG);
gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(dialog_), image);
gtk_widget_show(image);
gtk_icon_source_free(iconsource);
gtk_icon_set_unref(iconset);
g_object_unref(pixbuf);
}
if (!checkbox_label.empty()) { if (!checkbox_label.empty()) {
GtkWidget* message_area = GtkWidget* message_area =
gtk_message_dialog_get_message_area(GTK_MESSAGE_DIALOG(dialog_)); gtk_message_dialog_get_message_area(GTK_MESSAGE_DIALOG(dialog_));
@ -212,9 +195,9 @@ int ShowMessageBox(NativeWindow* parent,
const std::string& title, const std::string& title,
const std::string& message, const std::string& message,
const std::string& detail, const std::string& detail,
const gfx::ImageSkia& icon) { const gfx::ImageSkia& /*icon*/) {
return GtkMessageBox(parent, type, buttons, default_id, cancel_id, title, return GtkMessageBox(parent, type, buttons, default_id, cancel_id, title,
message, detail, "", false, icon) message, detail, "", false)
.RunSynchronous(); .RunSynchronous();
} }
@ -229,10 +212,10 @@ void ShowMessageBox(NativeWindow* parent,
const std::string& detail, const std::string& detail,
const std::string& checkbox_label, const std::string& checkbox_label,
bool checkbox_checked, bool checkbox_checked,
const gfx::ImageSkia& icon, const gfx::ImageSkia& /*icon*/,
const MessageBoxCallback& callback) { const MessageBoxCallback& callback) {
(new GtkMessageBox(parent, type, buttons, default_id, cancel_id, title, (new GtkMessageBox(parent, type, buttons, default_id, cancel_id, title,
message, detail, checkbox_label, checkbox_checked, icon)) message, detail, checkbox_label, checkbox_checked))
->RunAsynchronous(callback); ->RunAsynchronous(callback);
} }
@ -240,8 +223,7 @@ void ShowErrorBox(const base::string16& title, const base::string16& content) {
if (Browser::Get()->is_ready()) { if (Browser::Get()->is_ready()) {
GtkMessageBox(nullptr, MESSAGE_BOX_TYPE_ERROR, {"OK"}, -1, 0, "Error", GtkMessageBox(nullptr, MESSAGE_BOX_TYPE_ERROR, {"OK"}, -1, 0, "Error",
base::UTF16ToUTF8(title).c_str(), base::UTF16ToUTF8(title).c_str(),
base::UTF16ToUTF8(content).c_str(), "", false, base::UTF16ToUTF8(content).c_str(), "", false)
gfx::ImageSkia())
.RunSynchronous(); .RunSynchronous();
} else { } else {
fprintf(stderr, fprintf(stderr,