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_item_gtk.h" | 5 #include "chrome/browser/gtk/download_item_gtk.h" |
6 | 6 |
7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
8 #include "app/gfx/font.h" | 8 #include "app/gfx/font.h" |
9 #include "app/gfx/text_elider.h" | 9 #include "app/gfx/text_elider.h" |
10 #include "app/slide_animation.h" | 10 #include "app/slide_animation.h" |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/time.h" | 13 #include "base/time.h" |
14 #include "chrome/browser/download/download_item_model.h" | 14 #include "chrome/browser/download/download_item_model.h" |
15 #include "chrome/browser/download/download_manager.h" | 15 #include "chrome/browser/download/download_manager.h" |
16 #include "chrome/browser/download/download_shelf.h" | 16 #include "chrome/browser/download/download_shelf.h" |
17 #include "chrome/browser/download/download_util.h" | 17 #include "chrome/browser/download/download_util.h" |
18 #include "chrome/browser/gtk/download_shelf_gtk.h" | 18 #include "chrome/browser/gtk/download_shelf_gtk.h" |
19 #include "chrome/browser/gtk/menu_gtk.h" | 19 #include "chrome/browser/gtk/menu_gtk.h" |
20 #include "chrome/browser/gtk/nine_box.h" | 20 #include "chrome/browser/gtk/nine_box.h" |
| 21 #include "chrome/common/gtk_util.h" |
21 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
22 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 // The width of the |menu_button_| widget. It has to be at least as wide as the | 27 // The width of the |menu_button_| widget. It has to be at least as wide as the |
27 // bitmap that we use to draw it, i.e. 16, but can be more. | 28 // bitmap that we use to draw it, i.e. 16, but can be more. |
28 const int kMenuButtonWidth = 16; | 29 const int kMenuButtonWidth = 16; |
29 | 30 |
30 // Amount of space we allot to showing the filename. If the filename is too wide | 31 // Amount of space we allot to showing the filename. If the filename is too wide |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 gchar* label_markup = | 175 gchar* label_markup = |
175 g_markup_printf_escaped(kLabelColorMarkup, kFilenameColor, | 176 g_markup_printf_escaped(kLabelColorMarkup, kFilenameColor, |
176 WideToUTF8(elided_filename).c_str()); | 177 WideToUTF8(elided_filename).c_str()); |
177 gtk_label_set_markup(GTK_LABEL(name_label_), label_markup); | 178 gtk_label_set_markup(GTK_LABEL(name_label_), label_markup); |
178 g_free(label_markup); | 179 g_free(label_markup); |
179 | 180 |
180 status_label_ = gtk_label_new(NULL); | 181 status_label_ = gtk_label_new(NULL); |
181 // Left align and vertically center the labels. | 182 // Left align and vertically center the labels. |
182 gtk_misc_set_alignment(GTK_MISC(name_label_), 0, 0.5); | 183 gtk_misc_set_alignment(GTK_MISC(name_label_), 0, 0.5); |
183 gtk_misc_set_alignment(GTK_MISC(status_label_), 0, 0.5); | 184 gtk_misc_set_alignment(GTK_MISC(status_label_), 0, 0.5); |
| 185 // Until we switch to vector graphics, force the font size. |
| 186 gtk_util::ForceFontSizePixels(name_label_, 13.4); // 13.4px == 10pt @ 96dpi |
| 187 gtk_util::ForceFontSizePixels(status_label_, 13.4); // 13.4px == 10pt @ 96dpi |
184 | 188 |
185 // Stack the labels on top of one another. | 189 // Stack the labels on top of one another. |
186 GtkWidget* text_stack = gtk_vbox_new(FALSE, 0); | 190 GtkWidget* text_stack = gtk_vbox_new(FALSE, 0); |
187 gtk_box_pack_start(GTK_BOX(text_stack), name_label_, TRUE, TRUE, 0); | 191 gtk_box_pack_start(GTK_BOX(text_stack), name_label_, TRUE, TRUE, 0); |
188 gtk_box_pack_start(GTK_BOX(text_stack), status_label_, FALSE, FALSE, 0); | 192 gtk_box_pack_start(GTK_BOX(text_stack), status_label_, FALSE, FALSE, 0); |
189 | 193 |
190 // We use a GtkFixed because we don't want it to have its own window. | 194 // We use a GtkFixed because we don't want it to have its own window. |
191 // This choice of widget is not critically important though. | 195 // This choice of widget is not critically important though. |
192 progress_area_ = gtk_fixed_new(); | 196 progress_area_ = gtk_fixed_new(); |
193 gtk_widget_set_size_request(progress_area_, | 197 gtk_widget_set_size_request(progress_area_, |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 // static | 457 // static |
454 void DownloadItemGtk::OnShelfResized(GtkWidget *widget, | 458 void DownloadItemGtk::OnShelfResized(GtkWidget *widget, |
455 GtkAllocation *allocation, | 459 GtkAllocation *allocation, |
456 DownloadItemGtk* item) { | 460 DownloadItemGtk* item) { |
457 if (item->hbox_->allocation.x + item->hbox_->allocation.width > | 461 if (item->hbox_->allocation.x + item->hbox_->allocation.width > |
458 item->bounding_widget_->allocation.x) | 462 item->bounding_widget_->allocation.x) |
459 gtk_widget_hide(item->hbox_); | 463 gtk_widget_hide(item->hbox_); |
460 else | 464 else |
461 gtk_widget_show(item->hbox_); | 465 gtk_widget_show(item->hbox_); |
462 } | 466 } |
OLD | NEW |