summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-17 00:43:43 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-17 00:43:43 +0000
commit4118ab959e390b81735c81e84af7df2173826584 (patch)
treeda502a0e8625401866d50f5eb7f8cce8ceeb0dc0 /chrome/browser/gtk
parent816cb613e0210984e25fc997803acc8876e5adbe (diff)
downloadchromium_src-4118ab959e390b81735c81e84af7df2173826584.zip
chromium_src-4118ab959e390b81735c81e84af7df2173826584.tar.gz
chromium_src-4118ab959e390b81735c81e84af7df2173826584.tar.bz2
gtk: Make sure icon is right size in download item.
This results in kind of an ugly icon sometimes. When we get SVG support the number of ugly cases should go down. http://crbug.com/13791 Review URL: http://codereview.chromium.org/126245 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18575 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/download_item_gtk.cc23
1 files changed, 18 insertions, 5 deletions
diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc
index 744f8fc..6ed474f 100644
--- a/chrome/browser/gtk/download_item_gtk.cc
+++ b/chrome/browser/gtk/download_item_gtk.cc
@@ -603,9 +603,24 @@ gboolean DownloadItemGtk::OnProgressAreaExpose(GtkWidget* widget,
// TODO(estade): draw a default icon if |icon_| is null.
if (download_item->icon_) {
- canvas.DrawBitmapInt(*download_item->icon_,
- widget->allocation.x + download_util::kSmallProgressIconOffset,
- widget->allocation.y + download_util::kSmallProgressIconOffset);
+ int width = download_item->icon_->width();
+ int height = download_item->icon_->height();
+ // Sometimes we get back icons that are the wrong size. Draw the correct
+ // size. This code should hopefully be made obsolete after we support SVG
+ // icons (although it could still be hit if a theme doesn't provide SVG or
+ // 16x16).
+ const int sixteen = download_util::kSmallIconSize;
+ const int offset = download_util::kSmallProgressIconOffset;
+ if (sixteen != width || sixteen != height) {
+ // Draw the bitmap at a reduced scale.
+ download_item->icon_->buildMipMap(false);
+ canvas.DrawBitmapInt(*download_item->icon_, 0, 0, width, height,
+ widget->allocation.x + offset, widget->allocation.y + offset,
+ sixteen, sixteen, true);
+ } else {
+ canvas.DrawBitmapInt(*download_item->icon_,
+ widget->allocation.x + offset, widget->allocation.y + offset);
+ }
}
return TRUE;
@@ -621,8 +636,6 @@ gboolean DownloadItemGtk::OnMenuButtonPressEvent(GtkWidget* button,
item->complete_animation_->End();
}
- // TODO(port): this never puts the button into the "active" state,
- // so this may need to be changed. See note in BrowserToolbarGtk.
if (event->type == GDK_BUTTON_PRESS) {
GdkEventButton* event_button = reinterpret_cast<GdkEventButton*>(event);
if (event_button->button == 1) {