From 6342b6000d045862bbf1255c1fcafa9a1f24df48 Mon Sep 17 00:00:00 2001 From: "thomasvl@chromium.org" Date: Fri, 25 Sep 2009 20:52:49 +0000 Subject: L10N pass through download item and download shelf. - l10n the menus - l10n the dangerous item buttons - make view auto size for the dangerous item buttons TEST=download shelf item buttons and menus are localized BUG=20529 BUG=20530 Review URL: http://codereview.chromium.org/245009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27242 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/cocoa/download_item_controller.mm | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'chrome/browser/cocoa/download_item_controller.mm') diff --git a/chrome/browser/cocoa/download_item_controller.mm b/chrome/browser/cocoa/download_item_controller.mm index a02426ca..17cfaec 100644 --- a/chrome/browser/cocoa/download_item_controller.mm +++ b/chrome/browser/cocoa/download_item_controller.mm @@ -15,9 +15,35 @@ #include "chrome/browser/download/download_shelf.h" #include "chrome/browser/download/download_util.h" #include "grit/generated_resources.h" +#include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" static const int kTextWidth = 140; // Pixels +namespace { + +// Helper to widen a view. +void WidenView(NSView* view, CGFloat widthChange) { + // If it is an NSBox, the autoresize of the contentView is the issue. + NSView* contentView = view; + if ([view isKindOfClass:[NSBox class]]) { + contentView = [(NSBox*)view contentView]; + } + BOOL autoresizesSubviews = [contentView autoresizesSubviews]; + if (autoresizesSubviews) { + [contentView setAutoresizesSubviews:NO]; + } + + NSRect frame = [view frame]; + frame.size.width += widthChange; + [view setFrame:frame]; + + if (autoresizesSubviews) { + [contentView setAutoresizesSubviews:YES]; + } +} + +} // namespace + // A class for the chromium-side part of the download shelf context menu. class DownloadShelfContextMenuMac : public DownloadShelfContextMenu { @@ -66,6 +92,18 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu { } - (void)awakeFromNib { + // Since the shelf keeps laying out views as more items are added, relying on + // the WidthBaseTweaker to resize the dangerous download part does not work. + DCHECK(buttonTweaker_ != nil); + CGFloat widthChange = [buttonTweaker_ changedWidth]; + // Grow the parent views + WidenView([self view], widthChange); + WidenView(dangerousDownloadView_, widthChange); + // Slide the two buttons over. + NSPoint frameOrigin = [buttonTweaker_ frame].origin; + frameOrigin.x += widthChange; + [buttonTweaker_ setFrameOrigin:frameOrigin]; + [self setStateFromDownload:bridge_->download_model()]; bridge_->LoadIcon(); } -- cgit v1.1