diff options
author | glen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-06 21:27:37 +0000 |
---|---|---|
committer | glen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-06 21:27:37 +0000 |
commit | 0528372f5fc79ee479957fcbf10cac1f3429642a (patch) | |
tree | 566316ddae4764b6666b586ee4421c9fe93386a0 /chrome/browser/views/download_tab_view.cc | |
parent | 3cb7115ddd010b44cb35ffe4491eca2362a3759a (diff) | |
download | chromium_src-0528372f5fc79ee479957fcbf10cac1f3429642a.zip chromium_src-0528372f5fc79ee479957fcbf10cac1f3429642a.tar.gz chromium_src-0528372f5fc79ee479957fcbf10cac1f3429642a.tar.bz2 |
Add a function for eliding filenames to a set pixel width while preserving the display of the extension. This touches a lot of files because it renames url_elider to text_elider (as it already contained a bunch of text ellision functions), and so requires header file reference changes. BUG=1208
Review URL: http://codereview.chromium.org/9613
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4912 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/download_tab_view.cc')
-rw-r--r-- | chrome/browser/views/download_tab_view.cc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/chrome/browser/views/download_tab_view.cc b/chrome/browser/views/download_tab_view.cc index 1098aa2..6736ff6 100644 --- a/chrome/browser/views/download_tab_view.cc +++ b/chrome/browser/views/download_tab_view.cc @@ -20,6 +20,7 @@ #include "chrome/browser/user_metrics.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/gfx/chrome_font.h" +#include "chrome/common/gfx/text_elider.h" #include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" #include "chrome/common/stl_util-inl.h" @@ -281,8 +282,13 @@ void DownloadItemTabView::LayoutComplete() { parent_->big_icon_size() + kInfoPadding; // File name and URL - file_name_->SetText(model_->GetFileName()); + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + ChromeFont font = rb.GetFont(ResourceBundle::WebFont); + file_name_->SetText( + gfx::ElideFilename(model_->GetFileName(), font, kFilenameSize)); + gfx::Size file_name_size = file_name_->GetPreferredSize(); + file_name_->SetBounds(dx, parent_->big_icon_offset(), std::min(kFilenameSize, static_cast<int>(file_name_size.width())), @@ -331,7 +337,11 @@ void DownloadItemTabView::LayoutCancelled() { parent_->big_icon_size() + kInfoPadding; // File name and URL, truncated to show cancelled status - file_name_->SetText(model_->GetFileName()); + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + ChromeFont font = rb.GetFont(ResourceBundle::WebFont); + file_name_->SetText(gfx::ElideFilename(model_->GetFileName(), + font, + kFilenameSize)); gfx::Size file_name_size = file_name_->GetPreferredSize(); file_name_->SetBounds(dx, parent_->big_icon_offset(), kFilenameSize - kProgressSize - kSpacer, @@ -418,7 +428,11 @@ void DownloadItemTabView::LayoutInProgress() { parent_->big_icon_size() + kInfoPadding; // File name and URL, truncated to show progress status - file_name_->SetText(model_->GetFileName()); + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + ChromeFont font = rb.GetFont(ResourceBundle::WebFont); + file_name_->SetText(gfx::ElideFilename(model_->GetFileName(), + font, + kFilenameSize)); gfx::Size file_name_size = file_name_->GetPreferredSize(); file_name_->SetBounds(dx, parent_->big_icon_offset(), kFilenameSize - kProgressSize - kSpacer, |