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/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/gfx/canvas.h" | 8 #include "app/gfx/canvas.h" |
9 #include "app/gfx/font.h" | 9 #include "app/gfx/font.h" |
10 #include "app/gfx/text_elider.h" | 10 #include "app/gfx/text_elider.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 bounding_widget_(parent_shelf->GetRightBoundingWidget()), | 174 bounding_widget_(parent_shelf->GetRightBoundingWidget()), |
175 dangerous_prompt_(NULL), | 175 dangerous_prompt_(NULL), |
176 icon_(NULL) { | 176 icon_(NULL) { |
177 InitNineBoxes(); | 177 InitNineBoxes(); |
178 LoadIcon(); | 178 LoadIcon(); |
179 | 179 |
180 body_ = gtk_button_new(); | 180 body_ = gtk_button_new(); |
181 gtk_widget_set_app_paintable(body_, TRUE); | 181 gtk_widget_set_app_paintable(body_, TRUE); |
182 g_signal_connect(body_, "expose-event", | 182 g_signal_connect(body_, "expose-event", |
183 G_CALLBACK(OnExpose), this); | 183 G_CALLBACK(OnExpose), this); |
| 184 g_signal_connect(body_, "clicked", |
| 185 G_CALLBACK(OnClick), this); |
184 GTK_WIDGET_UNSET_FLAGS(body_, GTK_CAN_FOCUS); | 186 GTK_WIDGET_UNSET_FLAGS(body_, GTK_CAN_FOCUS); |
185 // Remove internal padding on the button. | 187 // Remove internal padding on the button. |
186 GtkRcStyle* no_padding_style = gtk_rc_style_new(); | 188 GtkRcStyle* no_padding_style = gtk_rc_style_new(); |
187 no_padding_style->xthickness = 0; | 189 no_padding_style->xthickness = 0; |
188 no_padding_style->ythickness = 0; | 190 no_padding_style->ythickness = 0; |
189 gtk_widget_modify_style(body_, no_padding_style); | 191 gtk_widget_modify_style(body_, no_padding_style); |
190 g_object_unref(no_padding_style); | 192 g_object_unref(no_padding_style); |
191 | 193 |
192 name_label_ = gtk_label_new(NULL); | 194 name_label_ = gtk_label_new(NULL); |
193 | 195 |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 nine_box->RenderToWidget(widget); | 560 nine_box->RenderToWidget(widget); |
559 | 561 |
560 GtkWidget* child = gtk_bin_get_child(GTK_BIN(widget)); | 562 GtkWidget* child = gtk_bin_get_child(GTK_BIN(widget)); |
561 if (child) | 563 if (child) |
562 gtk_container_propagate_expose(GTK_CONTAINER(widget), child, e); | 564 gtk_container_propagate_expose(GTK_CONTAINER(widget), child, e); |
563 | 565 |
564 return TRUE; | 566 return TRUE; |
565 } | 567 } |
566 | 568 |
567 // static | 569 // static |
| 570 void DownloadItemGtk::OnClick(GtkWidget* widget, DownloadItemGtk* item) { |
| 571 DownloadItem* download = item->get_download(); |
| 572 |
| 573 // TODO(estade): add clickjacking histogram stuff. |
| 574 if (download->state() == DownloadItem::IN_PROGRESS) { |
| 575 download->set_open_when_complete( |
| 576 !download->open_when_complete()); |
| 577 } else if (download->state() == DownloadItem::COMPLETE) { |
| 578 download_util::OpenDownload(download); |
| 579 } |
| 580 } |
| 581 |
| 582 // static |
568 gboolean DownloadItemGtk::OnProgressAreaExpose(GtkWidget* widget, | 583 gboolean DownloadItemGtk::OnProgressAreaExpose(GtkWidget* widget, |
569 GdkEventExpose* event, DownloadItemGtk* download_item) { | 584 GdkEventExpose* event, DownloadItemGtk* download_item) { |
570 // Create a transparent canvas. | 585 // Create a transparent canvas. |
571 gfx::CanvasPaint canvas(event, false); | 586 gfx::CanvasPaint canvas(event, false); |
572 if (download_item->complete_animation_.get()) { | 587 if (download_item->complete_animation_.get()) { |
573 if (download_item->complete_animation_->IsAnimating()) { | 588 if (download_item->complete_animation_->IsAnimating()) { |
574 download_util::PaintDownloadComplete(&canvas, | 589 download_util::PaintDownloadComplete(&canvas, |
575 widget->allocation.x, widget->allocation.y, | 590 widget->allocation.x, widget->allocation.y, |
576 download_item->complete_animation_->GetCurrentValue(), | 591 download_item->complete_animation_->GetCurrentValue(), |
577 download_util::SMALL); | 592 download_util::SMALL); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 item->get_download()); | 663 item->get_download()); |
649 } | 664 } |
650 | 665 |
651 // static | 666 // static |
652 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button, | 667 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button, |
653 DownloadItemGtk* item) { | 668 DownloadItemGtk* item) { |
654 if (item->get_download()->state() == DownloadItem::IN_PROGRESS) | 669 if (item->get_download()->state() == DownloadItem::IN_PROGRESS) |
655 item->get_download()->Cancel(true); | 670 item->get_download()->Cancel(true); |
656 item->get_download()->Remove(true); | 671 item->get_download()->Remove(true); |
657 } | 672 } |
OLD | NEW |