OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #import "chrome/browser/cocoa/wrench_menu_controller.h" | 5 #import "chrome/browser/cocoa/wrench_menu_controller.h" |
6 | 6 |
7 #include "app/menus/menu_model.h" | 7 #include "app/menus/menu_model.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "chrome/app/chrome_dll_resource.h" | 9 #include "chrome/app/chrome_dll_resource.h" |
10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
(...skipping 56 matching lines...) Loading... |
67 if (![menu delegate]) { | 67 if (![menu delegate]) { |
68 [menu setDelegate:self]; | 68 [menu setDelegate:self]; |
69 } | 69 } |
70 return menu; | 70 return menu; |
71 } | 71 } |
72 | 72 |
73 - (void)menuWillOpen:(NSMenu*)menu { | 73 - (void)menuWillOpen:(NSMenu*)menu { |
74 NSString* title = base::SysUTF16ToNSString( | 74 NSString* title = base::SysUTF16ToNSString( |
75 [self wrenchMenuModel]->GetLabelForCommandId(IDC_ZOOM_PERCENT_DISPLAY)); | 75 [self wrenchMenuModel]->GetLabelForCommandId(IDC_ZOOM_PERCENT_DISPLAY)); |
76 [[zoomItem_ viewWithTag:IDC_ZOOM_PERCENT_DISPLAY] setTitle:title]; | 76 [[zoomItem_ viewWithTag:IDC_ZOOM_PERCENT_DISPLAY] setTitle:title]; |
| 77 bool plusEnabled = [self wrenchMenuModel]->IsCommandIdEnabled(IDC_ZOOM_PLUS); |
| 78 bool minusEnabled = [self wrenchMenuModel]->IsCommandIdEnabled( |
| 79 IDC_ZOOM_MINUS); |
| 80 |
| 81 [zoomPlus_ setEnabled:plusEnabled]; |
| 82 [zoomMinus_ setEnabled:minusEnabled]; |
77 | 83 |
78 NSImage* icon = [self wrenchMenuModel]->browser()->window()->IsFullscreen() ? | 84 NSImage* icon = [self wrenchMenuModel]->browser()->window()->IsFullscreen() ? |
79 [NSImage imageNamed:NSImageNameExitFullScreenTemplate] : | 85 [NSImage imageNamed:NSImageNameExitFullScreenTemplate] : |
80 [NSImage imageNamed:NSImageNameEnterFullScreenTemplate]; | 86 [NSImage imageNamed:NSImageNameEnterFullScreenTemplate]; |
81 [zoomFullScreen_ setImage:icon]; | 87 [zoomFullScreen_ setImage:icon]; |
82 } | 88 } |
83 | 89 |
84 // Used to dispatch commands from the Wrench menu. The custom items within the | 90 // Used to dispatch commands from the Wrench menu. The custom items within the |
85 // menu cannot be hooked up directly to First Responder because the window in | 91 // menu cannot be hooked up directly to First Responder because the window in |
86 // which the controls reside is not the BrowserWindowController, but a | 92 // which the controls reside is not the BrowserWindowController, but a |
(...skipping 49 matching lines...) Loading... |
136 // of the segmented control. | 142 // of the segmented control. |
137 itemFrame.size.width += resizeAmount; | 143 itemFrame.size.width += resizeAmount; |
138 [editItem_ setFrame:itemFrame]; | 144 [editItem_ setFrame:itemFrame]; |
139 | 145 |
140 // Keep the spacing between the right edges of the menu and the control. | 146 // Keep the spacing between the right edges of the menu and the control. |
141 controlFrame.origin.x = NSWidth(itemFrame) - edge - NSWidth(controlFrame); | 147 controlFrame.origin.x = NSWidth(itemFrame) - edge - NSWidth(controlFrame); |
142 [editControl_ setFrame:controlFrame]; | 148 [editControl_ setFrame:controlFrame]; |
143 } | 149 } |
144 | 150 |
145 @end // @implementation WrenchMenuController | 151 @end // @implementation WrenchMenuController |
OLD | NEW |