Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(800)

Unified Diff: views/accelerator.cc

Issue 2742003: Adds support for showing accelerators in bookmark menus. (Closed)
Patch Set: Added GetAcceleratorText Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/accelerator.h ('k') | views/controls/menu/menu_config.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/accelerator.cc
diff --git a/views/accelerator.cc b/views/accelerator.cc
index 0dbb75931978ee4b5623dc2def6825cdd6ff938b..730191d4427b77b0827c631eabfe56bdc992b902 100644
--- a/views/accelerator.cc
+++ b/views/accelerator.cc
@@ -6,12 +6,15 @@
#if defined(OS_WIN)
#include <windows.h>
+#elif defined(OS_LINUX)
+#include <gdk/gdk.h>
#endif
#include "app/l10n_util.h"
#include "base/i18n/rtl.h"
#include "base/logging.h"
#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
#include "grit/app_strings.h"
namespace views {
@@ -81,7 +84,13 @@ std::wstring Accelerator::GetShortcutText() const {
key = LOWORD(::MapVirtualKeyW(key_code_, MAPVK_VK_TO_CHAR));
shortcut += key;
#elif defined(OS_LINUX)
- NOTIMPLEMENTED();
+ gchar* name = gdk_keyval_name(gdk_keyval_to_lower(key_code_));
+ if (name) {
+ if (name[0] != 0 && name[1] == 0)
+ shortcut += static_cast<wchar_t>(g_ascii_toupper(name[0]));
+ else
+ shortcut += UTF8ToWide(name);
+ }
#endif
} else {
shortcut = l10n_util::GetString(string_id);
« no previous file with comments | « views/accelerator.h ('k') | views/controls/menu/menu_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698