summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/download_item_controller.mm
diff options
context:
space:
mode:
authorthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-25 20:52:49 +0000
committerthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-25 20:52:49 +0000
commit6342b6000d045862bbf1255c1fcafa9a1f24df48 (patch)
tree5cc55a7c5fbe44e40a316de727a75a59f2f8c7b5 /chrome/browser/cocoa/download_item_controller.mm
parent8aaba6608dfe2f1e9faf15a1c72547a20f7435f3 (diff)
downloadchromium_src-6342b6000d045862bbf1255c1fcafa9a1f24df48.zip
chromium_src-6342b6000d045862bbf1255c1fcafa9a1f24df48.tar.gz
chromium_src-6342b6000d045862bbf1255c1fcafa9a1f24df48.tar.bz2
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
Diffstat (limited to 'chrome/browser/cocoa/download_item_controller.mm')
-rw-r--r--chrome/browser/cocoa/download_item_controller.mm38
1 files changed, 38 insertions, 0 deletions
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();
}