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