diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-19 18:15:59 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-19 18:15:59 +0000 |
commit | 0fbde57962200fc5fb7b7c3b7bb283dca0b8133f (patch) | |
tree | 3d01b9a373f7a21ded7beea42c6c4c1814460fd2 /chrome/browser | |
parent | 2a6b362c7563d36cf99e3954baa14bb7f6578f6c (diff) | |
download | chromium_src-0fbde57962200fc5fb7b7c3b7bb283dca0b8133f.zip chromium_src-0fbde57962200fc5fb7b7c3b7bb283dca0b8133f.tar.gz chromium_src-0fbde57962200fc5fb7b7c3b7bb283dca0b8133f.tar.bz2 |
Add "Show all downloads" link to download shelf.
BUG=14665
TEST=Download something, check that "show all downloads" text is on
shelf, click it, check that the downloads tab opens.
Review URL: http://codereview.chromium.org/132073
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18831 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/cocoa/download_shelf_controller.h | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/download_shelf_controller.mm | 32 |
2 files changed, 34 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/download_shelf_controller.h b/chrome/browser/cocoa/download_shelf_controller.h index 86c5535..58241c6 100644 --- a/chrome/browser/cocoa/download_shelf_controller.h +++ b/chrome/browser/cocoa/download_shelf_controller.h @@ -15,6 +15,8 @@ class DownloadShelf; @interface DownloadShelfController : NSViewController { @private + IBOutlet NSTextView* showAllDownloadsLink_; + // Currently these two are always the same, but they mean slightly // different things. contentAreaHasOffset_ is an implementation // detail of download shelf visibility. diff --git a/chrome/browser/cocoa/download_shelf_controller.mm b/chrome/browser/cocoa/download_shelf_controller.mm index b82f67f..e0b8cd0 100644 --- a/chrome/browser/cocoa/download_shelf_controller.mm +++ b/chrome/browser/cocoa/download_shelf_controller.mm @@ -4,11 +4,14 @@ #import "download_shelf_controller.h" +#include "app/l10n_util.h" #include "base/mac_util.h" +#include "base/sys_string_conversions.h" #import "chrome/browser/cocoa/browser_window_controller.h" #include "chrome/browser/cocoa/browser_window_cocoa.h" #include "chrome/browser/cocoa/download_shelf_mac.h" #import "chrome/browser/cocoa/download_shelf_view.h" +#include "grit/generated_resources.h" @interface DownloadShelfController(Private) @@ -36,6 +39,35 @@ return self; } +- (void)awakeFromNib { + // Initialize "Show all downloads" link. + + scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( + [[NSParagraphStyle defaultParagraphStyle] mutableCopy]); + // TODO(thakis): left-align for RTL languages? + [paragraphStyle.get() setAlignment:NSRightTextAlignment]; + + NSDictionary* linkAttributes = [NSDictionary dictionaryWithObjectsAndKeys: + self, NSLinkAttributeName, + [NSCursor pointingHandCursor], NSCursorAttributeName, + paragraphStyle.get(), NSParagraphStyleAttributeName, + nil]; + NSString* text = + base::SysWideToNSString(l10n_util::GetString(IDS_SHOW_ALL_DOWNLOADS)); + scoped_nsobject<NSAttributedString> linkText([[NSAttributedString alloc] + initWithString:text attributes:linkAttributes]); + + [[showAllDownloadsLink_ textStorage] setAttributedString:linkText.get()]; + [showAllDownloadsLink_ setDelegate:self]; +} + +- (BOOL)textView:(NSTextView *)aTextView + clickedOnLink:(id)link + atIndex:(NSUInteger)charIndex { + bridge_->ShowAllDownloads(); + return YES; +} + // Initializes the download shelf at the bottom edge of |contentArea_|. - (void)positionBar { // Set the bar's height to zero and position it at the bottom of the |