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 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_name_folder_controller.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_name_folder_controller.h" |
6 | 6 |
7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_cell_single_line.h" |
10 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa.h" | 11 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa.h" |
11 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
12 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
13 #include "ui/base/l10n/l10n_util_mac.h" | 14 #include "ui/base/l10n/l10n_util_mac.h" |
14 | 15 |
15 @implementation BookmarkNameFolderController | 16 @implementation BookmarkNameFolderController |
16 | 17 |
17 // Common initializer (private). | 18 // Common initializer (private). |
18 - (id)initWithParentWindow:(NSWindow*)window | 19 - (id)initWithParentWindow:(NSWindow*)window |
19 profile:(Profile*)profile | 20 profile:(Profile*)profile |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 DCHECK(parent); | 62 DCHECK(parent); |
62 return [self initWithParentWindow:window | 63 return [self initWithParentWindow:window |
63 profile:profile | 64 profile:profile |
64 node:nil | 65 node:nil |
65 parent:parent | 66 parent:parent |
66 newIndex:newIndex]; | 67 newIndex:newIndex]; |
67 } | 68 } |
68 | 69 |
69 - (void)awakeFromNib { | 70 - (void)awakeFromNib { |
70 [nameField_ setStringValue:initialName_.get()]; | 71 [nameField_ setStringValue:initialName_.get()]; |
| 72 |
| 73 // Check if NSTextFieldCell supports the method. This check is in place as |
| 74 // only 10.6 and greater support the setUsesSingleLineMode method. |
| 75 NSTextFieldCell* nameFieldCell_ = [nameField_ cell]; |
| 76 if ([nameFieldCell_ |
| 77 respondsToSelector:@selector(setUsesSingleLineMode:)]) { |
| 78 [nameFieldCell_ setUsesSingleLineMode:YES]; |
| 79 } |
71 } | 80 } |
72 | 81 |
73 - (void)runAsModalSheet { | 82 - (void)runAsModalSheet { |
74 // Ping me when things change out from under us. | 83 // Ping me when things change out from under us. |
75 observer_.reset(new BookmarkModelObserverForCocoa( | 84 observer_.reset(new BookmarkModelObserverForCocoa( |
76 node_, profile_->GetBookmarkModel(), | 85 node_, profile_->GetBookmarkModel(), |
77 self, | 86 self, |
78 @selector(cancel:))); | 87 @selector(cancel:))); |
79 [NSApp beginSheet:[self window] | 88 [NSApp beginSheet:[self window] |
80 modalForWindow:parentWindow_ | 89 modalForWindow:parentWindow_ |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 123 |
115 - (void)setFolderName:(NSString*)name { | 124 - (void)setFolderName:(NSString*)name { |
116 [nameField_ setStringValue:name]; | 125 [nameField_ setStringValue:name]; |
117 } | 126 } |
118 | 127 |
119 - (NSButton*)okButton { | 128 - (NSButton*)okButton { |
120 return okButton_; | 129 return okButton_; |
121 } | 130 } |
122 | 131 |
123 @end // BookmarkNameFolderController | 132 @end // BookmarkNameFolderController |
OLD | NEW |