OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/l10n_util.h" |
5 #include "base/mac_util.h" | 6 #include "base/mac_util.h" |
6 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
7 #include "chrome/browser/profile.h" | 8 #include "chrome/browser/profile.h" |
8 #import "chrome/browser/cocoa/bookmark_name_folder_controller.h" | 9 #import "chrome/browser/cocoa/bookmark_name_folder_controller.h" |
| 10 #include "grit/generated_resources.h" |
9 | 11 |
10 @implementation BookmarkNameFolderController | 12 @implementation BookmarkNameFolderController |
11 | 13 |
12 - (id)initWithParentWindow:(NSWindow*)window | 14 - (id)initWithParentWindow:(NSWindow*)window |
13 profile:(Profile*)profile | 15 profile:(Profile*)profile |
14 node:(const BookmarkNode*)node { | 16 node:(const BookmarkNode*)node { |
15 NSString* nibpath = [mac_util::MainAppBundle() | 17 NSString* nibpath = [mac_util::MainAppBundle() |
16 pathForResource:@"BookmarkNameFolder" | 18 pathForResource:@"BookmarkNameFolder" |
17 ofType:@"nib"]; | 19 ofType:@"nib"]; |
18 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { | 20 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { |
19 parentWindow_ = window; | 21 parentWindow_ = window; |
20 profile_ = profile; | 22 profile_ = profile; |
21 node_ = node; | 23 node_ = node; |
22 if (node_) { | 24 std::wstring newFolderString = |
23 initialName_.reset([base::SysWideToNSString(node_->GetTitle()) retain]); | 25 l10n_util::GetString(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME); |
24 } else { | 26 initialName_.reset([base::SysWideToNSString(newFolderString) retain]); |
25 initialName_.reset([@"" retain]); | |
26 } | |
27 } | 27 } |
28 return self; | 28 return self; |
29 } | 29 } |
30 | 30 |
31 - (void)awakeFromNib { | 31 - (void)awakeFromNib { |
32 [nameField_ setStringValue:initialName_.get()]; | 32 [nameField_ setStringValue:initialName_.get()]; |
33 if (node_) { | |
34 // TODO(jrg)?: on Windows the dialog is named either New Folder or | |
35 // Edit Folder Name. However, since we're a sheet on the Mac, the | |
36 // title is never seen. If we switch from a sheet, correct the | |
37 // title right here. | |
38 } | |
39 [self controlTextDidChange:nil]; | 33 [self controlTextDidChange:nil]; |
40 } | 34 } |
41 | 35 |
42 // Called as a side-effect of being the delegate of the text field. Ensure the | 36 // Called as a side-effect of being the delegate of the text field. Ensure the |
43 // OK button is only enabled when there is a valid name. | 37 // OK button is only enabled when there is a valid name. |
44 - (void)controlTextDidChange:(NSNotification*)ignore { | 38 - (void)controlTextDidChange:(NSNotification*)ignore { |
45 [okButton_ setEnabled:[[nameField_ stringValue] length]]; | 39 [okButton_ setEnabled:[[nameField_ stringValue] length]]; |
46 } | 40 } |
47 | 41 |
48 // TODO(jrg): consider NSModalSession. | 42 // TODO(jrg): consider NSModalSession. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 - (void)setFolderName:(NSString*)name { | 82 - (void)setFolderName:(NSString*)name { |
89 [nameField_ setStringValue:name]; | 83 [nameField_ setStringValue:name]; |
90 [self controlTextDidChange:nil]; | 84 [self controlTextDidChange:nil]; |
91 } | 85 } |
92 | 86 |
93 - (NSButton*)okButton { | 87 - (NSButton*)okButton { |
94 return okButton_; | 88 return okButton_; |
95 } | 89 } |
96 | 90 |
97 @end // BookmarkNameFolderController | 91 @end // BookmarkNameFolderController |
OLD | NEW |