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

Unified Diff: chrome/browser/gtk/download_item_gtk.cc

Issue 1528032: Add download item tooltips on linux/win. (Closed)
Patch Set: fix compile Created 10 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/gtk/download_item_gtk.h ('k') | chrome/browser/views/download_item_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/download_item_gtk.cc
diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc
index b6b84f9ecdd9495f9c19e323bf26436f32e1d036..254561dae4eb1669501c7e34e89cdc8f7d653f89 100644
--- a/chrome/browser/gtk/download_item_gtk.cc
+++ b/chrome/browser/gtk/download_item_gtk.cc
@@ -49,6 +49,9 @@ const int kDangerousElementPadding = 3;
// it will be elided.
const int kTextWidth = 140;
+// We only cap the size of the tooltip so we don't crash.
+const int kTooltipMaxWidth = 1000;
+
// The minimum width we will ever draw the download item. Used as a lower bound
// during animation. This number comes from the width of the images used to
// make the download item.
@@ -153,6 +156,7 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf,
body_.Own(gtk_button_new());
gtk_widget_set_app_paintable(body_.get(), TRUE);
+ UpdateTooltip();
g_signal_connect(body_.get(), "expose-event",
G_CALLBACK(OnExpose), this);
@@ -332,6 +336,8 @@ void DownloadItemGtk::OnDownloadUpdated(DownloadItem* download) {
// downloads. When the download is confirmed, the file is renamed on
// another thread, so reload the icon if the download filename changes.
LoadIcon();
+
+ UpdateTooltip();
}
switch (download->state()) {
@@ -481,6 +487,13 @@ void DownloadItemGtk::LoadIcon() {
NewCallback(this, &DownloadItemGtk::OnLoadIconComplete));
}
+void DownloadItemGtk::UpdateTooltip() {
+ std::wstring elided_filename = gfx::ElideFilename(
+ get_download()->GetFileName(),
+ gfx::Font(), kTooltipMaxWidth);
+ gtk_widget_set_tooltip_text(body_.get(), WideToUTF8(elided_filename).c_str());
+}
+
void DownloadItemGtk::UpdateNameLabel() {
// TODO(estade): This is at best an educated guess, since we don't actually
// use gfx::Font() to draw the text. This is why we need to add so
« no previous file with comments | « chrome/browser/gtk/download_item_gtk.h ('k') | chrome/browser/views/download_item_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698