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

Side by Side Diff: chrome/browser/cocoa/menu_controller.mm

Issue 523147: Made MenuController handle dynamic labels. (Closed)
Patch Set: Addressed pinkerton's comments. Created 10 years, 11 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
« no previous file with comments | « chrome/browser/app_menu_model.cc ('k') | no next file » | 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) 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
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
OLDNEW
« no previous file with comments | « chrome/browser/app_menu_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698