OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #import "chrome/browser/cocoa/menu_controller.h" | 5 #import "chrome/browser/cocoa/menu_controller.h" |
6 | 6 |
7 #include "app/l10n_util_mac.h" | 7 #include "app/l10n_util_mac.h" |
8 #include "app/menus/simple_menu_model.h" | 8 #include "app/menus/simple_menu_model.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 115 |
116 NSInteger modelIndex = [item tag]; | 116 NSInteger modelIndex = [item tag]; |
117 menus::MenuModel* model = | 117 menus::MenuModel* model = |
118 static_cast<menus::MenuModel*>( | 118 static_cast<menus::MenuModel*>( |
119 [[(id)item representedObject] pointerValue]); | 119 [[(id)item representedObject] pointerValue]); |
120 DCHECK(model); | 120 DCHECK(model); |
121 if (model) { | 121 if (model) { |
122 BOOL checked = model->IsItemCheckedAt(modelIndex); | 122 BOOL checked = model->IsItemCheckedAt(modelIndex); |
123 DCHECK([(id)item isKindOfClass:[NSMenuItem class]]); | 123 DCHECK([(id)item isKindOfClass:[NSMenuItem class]]); |
124 [(id)item setState:(checked ? NSOnState : NSOffState)]; | 124 [(id)item setState:(checked ? NSOnState : NSOffState)]; |
| 125 if (model->IsLabelDynamicAt(modelIndex)) { |
| 126 NSString* label = |
| 127 l10n_util::FixUpWindowsStyleLabel(model->GetLabelAt(modelIndex)); |
| 128 [(id)item setTitle:label]; |
| 129 } |
125 return model->IsEnabledAt(modelIndex); | 130 return model->IsEnabledAt(modelIndex); |
126 } | 131 } |
127 return NO; | 132 return NO; |
128 } | 133 } |
129 | 134 |
130 // Called when the user chooses a particular menu item. |sender| is the menu | 135 // Called when the user chooses a particular menu item. |sender| is the menu |
131 // item chosen. | 136 // item chosen. |
132 - (void)itemSelected:(id)sender { | 137 - (void)itemSelected:(id)sender { |
133 NSInteger modelIndex = [sender tag]; | 138 NSInteger modelIndex = [sender tag]; |
134 menus::MenuModel* model = | 139 menus::MenuModel* model = |
135 static_cast<menus::MenuModel*>( | 140 static_cast<menus::MenuModel*>( |
136 [[sender representedObject] pointerValue]); | 141 [[sender representedObject] pointerValue]); |
137 DCHECK(model); | 142 DCHECK(model); |
138 if (model); | 143 if (model); |
139 model->ActivatedAt(modelIndex); | 144 model->ActivatedAt(modelIndex); |
140 } | 145 } |
141 | 146 |
142 - (NSMenu*)menu { | 147 - (NSMenu*)menu { |
143 return menu_.get(); | 148 return menu_.get(); |
144 } | 149 } |
145 | 150 |
146 @end | 151 @end |
OLD | NEW |