OLD | NEW |
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 #include "chrome/browser/gtk/download_shelf_gtk.h" | 5 #include "chrome/browser/gtk/download_shelf_gtk.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/gfx/gtk_util.h" | 9 #include "base/gfx/gtk_util.h" |
10 #include "chrome/browser/download/download_item_model.h" | 10 #include "chrome/browser/download/download_item_model.h" |
11 #include "chrome/browser/download/download_util.h" | 11 #include "chrome/browser/download/download_util.h" |
12 #include "chrome/browser/gtk/custom_button.h" | 12 #include "chrome/browser/gtk/custom_button.h" |
13 #include "chrome/browser/gtk/download_item_gtk.h" | 13 #include "chrome/browser/gtk/download_item_gtk.h" |
14 #include "chrome/browser/gtk/link_button_gtk.h" | 14 #include "chrome/browser/gtk/link_button_gtk.h" |
15 #include "chrome/browser/gtk/slide_animator_gtk.h" | 15 #include "chrome/browser/gtk/slide_animator_gtk.h" |
16 #include "chrome/browser/tab_contents/tab_contents.h" | 16 #include "chrome/browser/tab_contents/tab_contents.h" |
| 17 #include "chrome/common/gtk_util.h" |
17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
18 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 // The height of the download items. | 23 // The height of the download items. |
23 const int kDownloadItemHeight = download_util::kSmallProgressIconSize; | 24 const int kDownloadItemHeight = download_util::kSmallProgressIconSize; |
24 | 25 |
25 // Padding between the download widgets. | 26 // Padding between the download widgets. |
26 const int kDownloadItemPadding = 10; | 27 const int kDownloadItemPadding = 10; |
(...skipping 62 matching lines...) Loading... |
89 close_button_.reset(CustomDrawButton::AddBarCloseButton(hbox_, 0)); | 90 close_button_.reset(CustomDrawButton::AddBarCloseButton(hbox_, 0)); |
90 g_signal_connect(close_button_->widget(), "clicked", | 91 g_signal_connect(close_button_->widget(), "clicked", |
91 G_CALLBACK(OnButtonClick), this); | 92 G_CALLBACK(OnButtonClick), this); |
92 | 93 |
93 // Create the "Show all downloads..." link and connect to the click event. | 94 // Create the "Show all downloads..." link and connect to the click event. |
94 std::string link_text = | 95 std::string link_text = |
95 l10n_util::GetStringUTF8(IDS_SHOW_ALL_DOWNLOADS); | 96 l10n_util::GetStringUTF8(IDS_SHOW_ALL_DOWNLOADS); |
96 link_button_.reset(new LinkButtonGtk(link_text.c_str())); | 97 link_button_.reset(new LinkButtonGtk(link_text.c_str())); |
97 g_signal_connect(link_button_->widget(), "clicked", | 98 g_signal_connect(link_button_->widget(), "clicked", |
98 G_CALLBACK(OnButtonClick), this); | 99 G_CALLBACK(OnButtonClick), this); |
| 100 // Until we switch to vector graphics, force the font size. |
| 101 // 13.4px == 10pt @ 96dpi |
| 102 gtk_util::ForceFontSizePixels(link_button_->label(), 13.4); |
99 | 103 |
100 // Make the download arrow icon. | 104 // Make the download arrow icon. |
101 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 105 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
102 GdkPixbuf* download_pixbuf = rb.GetPixbufNamed(IDR_DOWNLOADS_FAVICON); | 106 GdkPixbuf* download_pixbuf = rb.GetPixbufNamed(IDR_DOWNLOADS_FAVICON); |
103 GtkWidget* download_image = gtk_image_new_from_pixbuf(download_pixbuf); | 107 GtkWidget* download_image = gtk_image_new_from_pixbuf(download_pixbuf); |
104 | 108 |
105 // Pack the link and the icon in an hbox. | 109 // Pack the link and the icon in an hbox. |
106 link_hbox_ = gtk_hbox_new(FALSE, 5); | 110 link_hbox_ = gtk_hbox_new(FALSE, 5); |
107 gtk_box_pack_start(GTK_BOX(link_hbox_), download_image, FALSE, FALSE, 0); | 111 gtk_box_pack_start(GTK_BOX(link_hbox_), download_image, FALSE, FALSE, 0); |
108 gtk_box_pack_start(GTK_BOX(link_hbox_), link_button_->widget(), | 112 gtk_box_pack_start(GTK_BOX(link_hbox_), link_button_->widget(), |
(...skipping 58 matching lines...) Loading... |
167 void DownloadShelfGtk::OnButtonClick(GtkWidget* button, | 171 void DownloadShelfGtk::OnButtonClick(GtkWidget* button, |
168 DownloadShelfGtk* shelf) { | 172 DownloadShelfGtk* shelf) { |
169 if (button == shelf->close_button_->widget()) { | 173 if (button == shelf->close_button_->widget()) { |
170 shelf->slide_widget_->Close(); | 174 shelf->slide_widget_->Close(); |
171 shelf->tab_contents_->SetDownloadShelfVisible(false); | 175 shelf->tab_contents_->SetDownloadShelfVisible(false); |
172 } else { | 176 } else { |
173 // The link button was clicked. | 177 // The link button was clicked. |
174 shelf->ShowAllDownloads(); | 178 shelf->ShowAllDownloads(); |
175 } | 179 } |
176 } | 180 } |
OLD | NEW |