OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/glue/webmenurunner_mac.h" | 5 #include "webkit/glue/webmenurunner_mac.h" |
6 | 6 |
7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
8 | 8 |
9 #if !defined(MAC_OS_X_VERSION_10_6) || \ | 9 #if !defined(MAC_OS_X_VERSION_10_6) || \ |
10 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 | 10 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 - (void)addItem:(const WebMenuItem&)item { | 59 - (void)addItem:(const WebMenuItem&)item { |
60 if (item.type == WebMenuItem::SEPARATOR) { | 60 if (item.type == WebMenuItem::SEPARATOR) { |
61 [menu_ addItem:[NSMenuItem separatorItem]]; | 61 [menu_ addItem:[NSMenuItem separatorItem]]; |
62 return; | 62 return; |
63 } | 63 } |
64 | 64 |
65 NSString* title = base::SysUTF16ToNSString(item.label); | 65 NSString* title = base::SysUTF16ToNSString(item.label); |
66 NSMenuItem* menuItem = [menu_ addItemWithTitle:title | 66 NSMenuItem* menuItem = [menu_ addItemWithTitle:title |
67 action:@selector(menuItemSelected:) | 67 action:@selector(menuItemSelected:) |
68 keyEquivalent:@""]; | 68 keyEquivalent:@""]; |
69 NSString* toolTip = base::SysUTF16ToNSString(item.toolTip); | |
70 [menuItem setToolTip:toolTip]; | |
Nico
2011/05/25 17:12:58
Do you only want to do this if the toolTip isn't t
honten.org
2011/05/25 17:25:49
You are right.
We don't have to set the string, i
| |
69 [menuItem setEnabled:(item.enabled && item.type != WebMenuItem::GROUP)]; | 71 [menuItem setEnabled:(item.enabled && item.type != WebMenuItem::GROUP)]; |
70 [menuItem setTarget:self]; | 72 [menuItem setTarget:self]; |
71 | 73 |
72 // Set various alignment/language attributes. Note that many (if not most) of | 74 // Set various alignment/language attributes. Note that many (if not most) of |
73 // these attributes are functional only on 10.6 and above. | 75 // these attributes are functional only on 10.6 and above. |
74 scoped_nsobject<NSMutableDictionary> attrs( | 76 scoped_nsobject<NSMutableDictionary> attrs( |
75 [[NSMutableDictionary alloc] initWithCapacity:3]); | 77 [[NSMutableDictionary alloc] initWithCapacity:3]); |
76 scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( | 78 scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( |
77 [[NSMutableParagraphStyle alloc] init]); | 79 [[NSMutableParagraphStyle alloc] init]); |
78 [paragraphStyle setAlignment:rightAligned_ ? NSRightTextAlignment | 80 [paragraphStyle setAlignment:rightAligned_ ? NSRightTextAlignment |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 characters:@"" | 208 characters:@"" |
207 charactersIgnoringModifiers:escape_str | 209 charactersIgnoringModifiers:escape_str |
208 isARepeat:NO | 210 isARepeat:NO |
209 keyCode:0x1B]; | 211 keyCode:0x1B]; |
210 } | 212 } |
211 | 213 |
212 return event; | 214 return event; |
213 } | 215 } |
214 | 216 |
215 } // namespace webkit_glue | 217 } // namespace webkit_glue |
OLD | NEW |