Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(527)

Side by Side Diff: chrome/browser/cocoa/download_shelf_controller.mm

Issue 132073: Add "Show all downloads" link to download shelf.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Address comments Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/cocoa/download_shelf_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "download_shelf_controller.h" 5 #import "download_shelf_controller.h"
6 6
7 #include "app/l10n_util.h"
7 #include "base/mac_util.h" 8 #include "base/mac_util.h"
9 #include "base/sys_string_conversions.h"
8 #import "chrome/browser/cocoa/browser_window_controller.h" 10 #import "chrome/browser/cocoa/browser_window_controller.h"
9 #include "chrome/browser/cocoa/browser_window_cocoa.h" 11 #include "chrome/browser/cocoa/browser_window_cocoa.h"
10 #include "chrome/browser/cocoa/download_shelf_mac.h" 12 #include "chrome/browser/cocoa/download_shelf_mac.h"
11 #import "chrome/browser/cocoa/download_shelf_view.h" 13 #import "chrome/browser/cocoa/download_shelf_view.h"
14 #include "grit/generated_resources.h"
12 15
13 16
14 @interface DownloadShelfController(Private) 17 @interface DownloadShelfController(Private)
15 - (void)applyContentAreaOffset:(BOOL)apply; 18 - (void)applyContentAreaOffset:(BOOL)apply;
16 - (void)positionBar; 19 - (void)positionBar;
17 - (void)showDownloadShelf:(BOOL)enable; 20 - (void)showDownloadShelf:(BOOL)enable;
18 @end 21 @end
19 22
20 23
21 @implementation DownloadShelfController 24 @implementation DownloadShelfController
22 25
23 - (id)initWithBrowser:(Browser*)browser 26 - (id)initWithBrowser:(Browser*)browser
24 contentArea:(NSView*)content { 27 contentArea:(NSView*)content {
25 if ((self = [super initWithNibName:@"DownloadShelf" 28 if ((self = [super initWithNibName:@"DownloadShelf"
26 bundle:mac_util::MainAppBundle()])) { 29 bundle:mac_util::MainAppBundle()])) {
27 contentArea_ = content; 30 contentArea_ = content;
28 shelfHeight_ = [[self view] bounds].size.height; 31 shelfHeight_ = [[self view] bounds].size.height;
29 32
30 [self positionBar]; 33 [self positionBar];
31 [[[contentArea_ window] contentView] addSubview:[self view]]; 34 [[[contentArea_ window] contentView] addSubview:[self view]];
32 35
33 // This calls show:, so it needs to be last. 36 // This calls show:, so it needs to be last.
34 bridge_.reset(new DownloadShelfMac(browser, self)); 37 bridge_.reset(new DownloadShelfMac(browser, self));
35 } 38 }
36 return self; 39 return self;
37 } 40 }
38 41
42 - (void)awakeFromNib {
43 // Initialize "Show all downloads" link.
44
45 scoped_nsobject<NSMutableParagraphStyle> paragraphStyle(
46 [[NSParagraphStyle defaultParagraphStyle] mutableCopy]);
47 // TODO(thakis): left-align for RTL languages?
48 [paragraphStyle.get() setAlignment:NSRightTextAlignment];
49
50 NSDictionary* linkAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
51 self, NSLinkAttributeName,
52 [NSCursor pointingHandCursor], NSCursorAttributeName,
53 paragraphStyle.get(), NSParagraphStyleAttributeName,
54 nil];
55 NSString* text =
56 base::SysWideToNSString(l10n_util::GetString(IDS_SHOW_ALL_DOWNLOADS));
57 scoped_nsobject<NSAttributedString> linkText([[NSAttributedString alloc]
58 initWithString:text attributes:linkAttributes]);
59
60 [[showAllDownloadsLink_ textStorage] setAttributedString:linkText.get()];
61 [showAllDownloadsLink_ setDelegate:self];
62 }
63
64 - (BOOL)textView:(NSTextView *)aTextView
65 clickedOnLink:(id)link
66 atIndex:(NSUInteger)charIndex {
67 bridge_->ShowAllDownloads();
68 return YES;
69 }
70
39 // Initializes the download shelf at the bottom edge of |contentArea_|. 71 // Initializes the download shelf at the bottom edge of |contentArea_|.
40 - (void)positionBar { 72 - (void)positionBar {
41 // Set the bar's height to zero and position it at the bottom of the 73 // Set the bar's height to zero and position it at the bottom of the
42 // content area, within the window's content view (as opposed to the 74 // content area, within the window's content view (as opposed to the
43 // tab strip, which is a sibling). We'll enlarge it and slide the 75 // tab strip, which is a sibling). We'll enlarge it and slide the
44 // content area up when we need to show this strip. 76 // content area up when we need to show this strip.
45 NSRect contentFrame = [contentArea_ frame]; 77 NSRect contentFrame = [contentArea_ frame];
46 NSRect barFrame = NSMakeRect(0, 0, 78 NSRect barFrame = NSMakeRect(0, 0,
47 contentFrame.size.width, shelfHeight_); 79 contentFrame.size.width, shelfHeight_);
48 [[self view] setFrame:barFrame]; 80 [[self view] setFrame:barFrame];
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 137
106 - (void)hide:(id)sender { 138 - (void)hide:(id)sender {
107 [self showDownloadShelf:NO]; 139 [self showDownloadShelf:NO];
108 } 140 }
109 141
110 - (void)addDownloadItem:(NSView*)view { 142 - (void)addDownloadItem:(NSView*)view {
111 [[self view] addSubview:view]; 143 [[self view] addSubview:view];
112 } 144 }
113 145
114 @end 146 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/download_shelf_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698