diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-13 23:44:00 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-13 23:44:00 +0000 |
commit | 07da008e75f1b6d6c69947aae6e2810617766246 (patch) | |
tree | 8282723dd6310632fb434184066d3df61e1ec275 /chrome/browser/gtk | |
parent | 0bfff0758445c1b0abdb0deff3dfb8aa5b2229e3 (diff) | |
download | chromium_src-07da008e75f1b6d6c69947aae6e2810617766246.zip chromium_src-07da008e75f1b6d6c69947aae6e2810617766246.tar.gz chromium_src-07da008e75f1b6d6c69947aae6e2810617766246.tar.bz2 |
GTK: Force a size on download items and elide the dangerous download filename.
This is a temporary hack that might not work in all locales and definitely won't work if we ever let users change font sizes. GtkLabels are just plain broken. Pango is also broken because you can get height-for-width for a layout but not width-for-height.
Thus we should switch to using skia to draw download items fonts, but this solution will work for now.
BUG=16389
TEST=download the Dansk version of open office for windows
Review URL: http://codereview.chromium.org/155395
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20572 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/download_item_gtk.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc index d779b74..7e246b6 100644 --- a/chrome/browser/gtk/download_item_gtk.cc +++ b/chrome/browser/gtk/download_item_gtk.cc @@ -43,6 +43,9 @@ const int kDangerousElementPadding = 3; // it will be elided. const int kTextWidth = 140; +// Display width of the dangerous file warning, in pixels. +const int kDangerousTextWidth = 350; + // 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. @@ -283,11 +286,12 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, gtk_box_pack_start(GTK_BOX(dangerous_hbox_), dangerous_image, FALSE, FALSE, 0); - // Create the warning text. - // TODO(estade): the encoding might not be UTF8. + std::wstring elided_filename = gfx::ElideFilename( + get_download()->original_name(), + gfx::Font(), kTextWidth); std::string dangerous_warning = l10n_util::GetStringFUTF8(IDS_PROMPT_DANGEROUS_DOWNLOAD, - UTF8ToUTF16(get_download()->original_name().value())); + WideToUTF16(elided_filename)); gchar* label_markup = g_markup_printf_escaped(kLabelColorMarkup, kFilenameColor, dangerous_warning.c_str()); @@ -301,6 +305,7 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, // request when the animation is going on. gtk_box_pack_start(GTK_BOX(dangerous_hbox_), dangerous_label, TRUE, TRUE, 0); + gtk_widget_set_size_request(dangerous_label, kDangerousTextWidth, -1); g_free(label_markup); // Create the ok button. |