summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/bookmark_menu_bridge.mm
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 23:56:19 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 23:56:19 +0000
commitcb514b8024f425b974c680b06dcace135b32de39 (patch)
tree79a1530164118302eee0562b6bdf58f3a022f880 /chrome/browser/cocoa/bookmark_menu_bridge.mm
parentb1e8cb31f85869171dcb383c7ec5e8176833ec04 (diff)
downloadchromium_src-cb514b8024f425b974c680b06dcace135b32de39.zip
chromium_src-cb514b8024f425b974c680b06dcace135b32de39.tar.gz
chromium_src-cb514b8024f425b974c680b06dcace135b32de39.tar.bz2
Added menus for bookmark bar folders. This is NOT based on the Cole
prototype; it is an attempt to get something functional in the short term, and have a visual baseline before doing something new. Added folder icons for bookmark bar folder buttons. Added an "off the side" button/menu for bookmark buttons which don't fit on the bar. Updated "Add page..." item to allow creating bookmarks in the folders (if selected over a folder button). BUG=http://crbug.com/8381 TEST=Here we go: 1) Make sure bookmark bar folders have the "folder" icon. 2) Right click on a folder --> Add Page, and add a bookmark. Make sure bookmark is now in the folder, not at the top level. 3) (Oh, you just implicitly verified you can open bookmark folders!) 4) Add 5 bookmarks then shrink the window thinner so all bookmark buttons don't fit. Make sure "off the right" button gets enabled (on right side of bar) and shows bookmarks in a pop-up menu (when clicked) that don't completely fit on the bar. 5) Make it super-wide so the all fit and make sure "off the right" button is disabled. 6) Add a bunch of bookmarks to a folder; make sure they all work. 7) Add nested folders (by editing the bookmark pref file and restarting Chrome) and make sure bookmark folder buttons have nested/cascading menus. Review URL: http://codereview.chromium.org/159286 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21479 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_menu_bridge.mm')
-rw-r--r--chrome/browser/cocoa/bookmark_menu_bridge.mm26
1 files changed, 3 insertions, 23 deletions
diff --git a/chrome/browser/cocoa/bookmark_menu_bridge.mm b/chrome/browser/cocoa/bookmark_menu_bridge.mm
index f4d4c7d..d37ea02 100644
--- a/chrome/browser/cocoa/bookmark_menu_bridge.mm
+++ b/chrome/browser/cocoa/bookmark_menu_bridge.mm
@@ -170,31 +170,10 @@ void BookmarkMenuBridge::ClearBookmarkMenu(NSMenu* menu) {
}
}
-namespace {
-
-// Menus more than this many chars long will get trimmed
-const NSUInteger kMaximumMenuWidthInChars = 65;
-
-// When trimming, use this many chars from each side
-const NSUInteger kMenuTrimSizeInChars = 30;
-
-}
-
void BookmarkMenuBridge::AddNodeToMenu(const BookmarkNode* node, NSMenu* menu) {
for (int i = 0; i < node->GetChildCount(); i++) {
const BookmarkNode* child = node->GetChild(i);
- NSString* full_title = base::SysWideToNSString(child->GetTitle());
- NSString* title = full_title;
- if ([title length] > kMaximumMenuWidthInChars) {
- // TODO(jrg): add a better heuristic? I'd really like to trim this
- // by pixels, not by chars (font is not fixed width).
- // For Safari, it appears that menu names >60 chars get split up to
- // 30char + "..." + 30char.
- title = [NSString stringWithFormat:@"%@…%@",
- [title substringToIndex:kMenuTrimSizeInChars],
- [title substringFromIndex:([title length] -
- kMenuTrimSizeInChars)]];
- }
+ NSString* title = [BookmarkMenuCocoaController menuTitleForNode:child];
NSMenuItem* item = [[[NSMenuItem alloc] initWithTitle:title
action:nil
keyEquivalent:@""] autorelease];
@@ -209,7 +188,8 @@ void BookmarkMenuBridge::AddNodeToMenu(const BookmarkNode* node, NSMenu* menu) {
[item setTag:child->id()];
// Add a tooltip
std::string url_string = child->GetURL().possibly_invalid_spec();
- NSString* tooltip = [NSString stringWithFormat:@"%@\n%s", full_title,
+ NSString* tooltip = [NSString stringWithFormat:@"%@\n%s",
+ base::SysWideToNSString(child->GetTitle()),
url_string.c_str()];
[item setToolTip:tooltip];