fix: correct default text for button labels in gtk dialogs (#31798)

This commit is contained in:
Charles Kerr 2021-11-15 01:18:33 -06:00 committed by GitHub
parent c8ba3b4556
commit 22f863b37a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 17 deletions

View file

@ -17,10 +17,11 @@
#include "third_party/skia/include/core/SkUnPreMultiply.h" #include "third_party/skia/include/core/SkUnPreMultiply.h"
#include "ui/gtk/gtk_compat.h" // nogncheck #include "ui/gtk/gtk_compat.h" // nogncheck
namespace gtk_util {
// The following utilities are pulled from // The following utilities are pulled from
// https://source.chromium.org/chromium/chromium/src/+/main:ui/gtk/select_file_dialog_impl_gtk.cc;l=43-74 // https://source.chromium.org/chromium/chromium/src/+/main:ui/gtk/select_file_dialog_impl_gtk.cc;l=43-74
namespace gtk_util {
namespace {
const char* GettextPackage() { const char* GettextPackage() {
static base::NoDestructor<std::string> gettext_package( static base::NoDestructor<std::string> gettext_package(
@ -32,44 +33,34 @@ const char* GtkGettext(const char* str) {
return g_dgettext(GettextPackage(), str); return g_dgettext(GettextPackage(), str);
} }
} // namespace
const char* GetCancelLabel() { const char* GetCancelLabel() {
if (!gtk::GtkCheckVersion(4))
return "gtk-cancel"; // In GTK3, this is GTK_STOCK_CANCEL.
static const char* cancel = GtkGettext("_Cancel"); static const char* cancel = GtkGettext("_Cancel");
return cancel; return cancel;
} }
const char* GetOpenLabel() { const char* GetOpenLabel() {
if (!gtk::GtkCheckVersion(4))
return "gtk-open"; // In GTK3, this is GTK_STOCK_OPEN.
static const char* open = GtkGettext("_Open"); static const char* open = GtkGettext("_Open");
return open; return open;
} }
const char* GetSaveLabel() { const char* GetSaveLabel() {
if (!gtk::GtkCheckVersion(4))
return "gtk-save"; // In GTK3, this is GTK_STOCK_SAVE.
static const char* save = GtkGettext("_Save"); static const char* save = GtkGettext("_Save");
return save; return save;
} }
const char* GetOkLabel() { const char* GetOkLabel() {
if (!gtk::GtkCheckVersion(4))
return "gtk-ok"; // In GTK3, this is GTK_STOCK_OK.
static const char* ok = GtkGettext("_Ok"); static const char* ok = GtkGettext("_Ok");
return ok; return ok;
} }
const char* GetNoLabel() { const char* GetNoLabel() {
if (!gtk::GtkCheckVersion(4))
return "gtk-no"; // In GTK3, this is GTK_STOCK_NO.
static const char* no = GtkGettext("_No"); static const char* no = GtkGettext("_No");
return no; return no;
} }
const char* GetYesLabel() { const char* GetYesLabel() {
if (!gtk::GtkCheckVersion(4))
return "gtk-yes"; // In GTK3, this is GTK_STOCK_YES.
static const char* yes = GtkGettext("_Yes"); static const char* yes = GtkGettext("_Yes");
return yes; return yes;
} }

View file

@ -11,9 +11,6 @@ class SkBitmap;
namespace gtk_util { namespace gtk_util {
const char* GettextPackage();
const char* GtkGettext(const char* str);
const char* GetCancelLabel(); const char* GetCancelLabel();
const char* GetOpenLabel(); const char* GetOpenLabel();
const char* GetSaveLabel(); const char* GetSaveLabel();