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

Side by Side Diff: ui/base/accelerators/accelerator.cc

Issue 232773008: More removal of GTK code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove base/ so I don't need another stamp. Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/serialized_structs.h ('k') | ui/base/clipboard/clipboard.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/base/accelerators/accelerator.h" 5 #include "ui/base/accelerators/accelerator.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #elif defined(TOOLKIT_GTK)
10 #include <gdk/gdk.h>
11 #endif 9 #endif
12 10
13 #include "base/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
14 #include "base/logging.h" 12 #include "base/logging.h"
15 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
16 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
17 #include "grit/ui_strings.h" 15 #include "grit/ui_strings.h"
18 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
19 17
20 #if !defined(OS_WIN) && (defined(USE_AURA) || defined(OS_MACOSX)) 18 #if !defined(OS_WIN) && (defined(USE_AURA) || defined(OS_MACOSX))
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 if (key_code_ >= '0' && key_code_ <= '9') 183 if (key_code_ >= '0' && key_code_ <= '9')
186 key = key_code_; 184 key = key_code_;
187 else 185 else
188 key = LOWORD(::MapVirtualKeyW(key_code_, MAPVK_VK_TO_CHAR)); 186 key = LOWORD(::MapVirtualKeyW(key_code_, MAPVK_VK_TO_CHAR));
189 shortcut += key; 187 shortcut += key;
190 #elif defined(USE_AURA) || defined(OS_MACOSX) 188 #elif defined(USE_AURA) || defined(OS_MACOSX)
191 const uint16 c = GetCharacterFromKeyCode(key_code_, false); 189 const uint16 c = GetCharacterFromKeyCode(key_code_, false);
192 if (c != 0) 190 if (c != 0)
193 shortcut += 191 shortcut +=
194 static_cast<base::string16::value_type>(base::ToUpperASCII(c)); 192 static_cast<base::string16::value_type>(base::ToUpperASCII(c));
195 #elif defined(TOOLKIT_GTK)
196 const gchar* name = NULL;
197 switch (key_code_) {
198 case ui::VKEY_OEM_2:
199 name = static_cast<const gchar*>("/");
200 break;
201 default:
202 name = gdk_keyval_name(gdk_keyval_to_lower(key_code_));
203 break;
204 }
205 if (name) {
206 if (name[0] != 0 && name[1] == 0)
207 shortcut +=
208 static_cast<base::string16::value_type>(g_ascii_toupper(name[0]));
209 else
210 shortcut += base::UTF8ToUTF16(name);
211 }
212 #endif 193 #endif
213 } else { 194 } else {
214 shortcut = l10n_util::GetStringUTF16(string_id); 195 shortcut = l10n_util::GetStringUTF16(string_id);
215 } 196 }
216 197
217 // Checking whether the character used for the accelerator is alphanumeric. 198 // Checking whether the character used for the accelerator is alphanumeric.
218 // If it is not, then we need to adjust the string later on if the locale is 199 // If it is not, then we need to adjust the string later on if the locale is
219 // right-to-left. See below for more information of why such adjustment is 200 // right-to-left. See below for more information of why such adjustment is
220 // required. 201 // required.
221 base::string16 shortcut_rtl; 202 base::string16 shortcut_rtl;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 248
268 // Subtracting the size of the shortcut key and 1 for the '+' sign. 249 // Subtracting the size of the shortcut key and 1 for the '+' sign.
269 shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1); 250 shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1);
270 shortcut.swap(shortcut_rtl); 251 shortcut.swap(shortcut_rtl);
271 } 252 }
272 253
273 return shortcut; 254 return shortcut;
274 } 255 }
275 256
276 } // namespace ui 257 } // namespace ui
OLDNEW
« no previous file with comments | « ppapi/proxy/serialized_structs.h ('k') | ui/base/clipboard/clipboard.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698