Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: chrome/browser/ui/gtk/download/download_item_gtk.cc

Issue 7484035: Reapplies r91761. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/gtk/download/download_item_gtk.h" 5 #include "chrome/browser/ui/gtk/download/download_item_gtk.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 body_.Own(gtk_button_new()); 110 body_.Own(gtk_button_new());
111 gtk_widget_set_app_paintable(body_.get(), TRUE); 111 gtk_widget_set_app_paintable(body_.get(), TRUE);
112 UpdateTooltip(); 112 UpdateTooltip();
113 113
114 g_signal_connect(body_.get(), "expose-event", 114 g_signal_connect(body_.get(), "expose-event",
115 G_CALLBACK(OnExposeThunk), this); 115 G_CALLBACK(OnExposeThunk), this);
116 g_signal_connect(body_.get(), "clicked", 116 g_signal_connect(body_.get(), "clicked",
117 G_CALLBACK(OnClickThunk), this); 117 G_CALLBACK(OnClickThunk), this);
118 g_signal_connect(body_.get(), "button-press-event", 118 g_signal_connect(body_.get(), "button-press-event",
119 G_CALLBACK(OnButtonPressThunk), this); 119 G_CALLBACK(OnButtonPressThunk), this);
120 GTK_WIDGET_UNSET_FLAGS(body_.get(), GTK_CAN_FOCUS); 120 gtk_widget_set_can_focus(body_.get(), FALSE);
121 // Remove internal padding on the button. 121 // Remove internal padding on the button.
122 GtkRcStyle* no_padding_style = gtk_rc_style_new(); 122 GtkRcStyle* no_padding_style = gtk_rc_style_new();
123 no_padding_style->xthickness = 0; 123 no_padding_style->xthickness = 0;
124 no_padding_style->ythickness = 0; 124 no_padding_style->ythickness = 0;
125 gtk_widget_modify_style(body_.get(), no_padding_style); 125 gtk_widget_modify_style(body_.get(), no_padding_style);
126 g_object_unref(no_padding_style); 126 g_object_unref(no_padding_style);
127 127
128 name_label_ = gtk_label_new(NULL); 128 name_label_ = gtk_label_new(NULL);
129 // Left align and vertically center the labels. 129 // Left align and vertically center the labels.
130 gtk_misc_set_alignment(GTK_MISC(name_label_), 0, 0.5); 130 gtk_misc_set_alignment(GTK_MISC(name_label_), 0, 0.5);
(...skipping 21 matching lines...) Expand all
152 G_CALLBACK(OnProgressAreaExposeThunk), this); 152 G_CALLBACK(OnProgressAreaExposeThunk), this);
153 153
154 // Put the download progress icon on the left of the labels. 154 // Put the download progress icon on the left of the labels.
155 GtkWidget* body_hbox = gtk_hbox_new(FALSE, 0); 155 GtkWidget* body_hbox = gtk_hbox_new(FALSE, 0);
156 gtk_container_add(GTK_CONTAINER(body_.get()), body_hbox); 156 gtk_container_add(GTK_CONTAINER(body_.get()), body_hbox);
157 gtk_box_pack_start(GTK_BOX(body_hbox), progress_area_.get(), FALSE, FALSE, 0); 157 gtk_box_pack_start(GTK_BOX(body_hbox), progress_area_.get(), FALSE, FALSE, 0);
158 gtk_box_pack_start(GTK_BOX(body_hbox), text_stack_, TRUE, TRUE, 0); 158 gtk_box_pack_start(GTK_BOX(body_hbox), text_stack_, TRUE, TRUE, 0);
159 159
160 menu_button_ = gtk_button_new(); 160 menu_button_ = gtk_button_new();
161 gtk_widget_set_app_paintable(menu_button_, TRUE); 161 gtk_widget_set_app_paintable(menu_button_, TRUE);
162 GTK_WIDGET_UNSET_FLAGS(menu_button_, GTK_CAN_FOCUS); 162 gtk_widget_set_can_focus(menu_button_, FALSE);
163 g_signal_connect(menu_button_, "expose-event", 163 g_signal_connect(menu_button_, "expose-event",
164 G_CALLBACK(OnExposeThunk), this); 164 G_CALLBACK(OnExposeThunk), this);
165 g_signal_connect(menu_button_, "button-press-event", 165 g_signal_connect(menu_button_, "button-press-event",
166 G_CALLBACK(OnMenuButtonPressEventThunk), this); 166 G_CALLBACK(OnMenuButtonPressEventThunk), this);
167 g_object_set_data(G_OBJECT(menu_button_), "left-align-popup", 167 g_object_set_data(G_OBJECT(menu_button_), "left-align-popup",
168 reinterpret_cast<void*>(true)); 168 reinterpret_cast<void*>(true));
169 169
170 GtkWidget* shelf_hbox = parent_shelf->GetHBox(); 170 GtkWidget* shelf_hbox = parent_shelf->GetHBox();
171 hbox_.Own(gtk_hbox_new(FALSE, 0)); 171 hbox_.Own(gtk_hbox_new(FALSE, 0));
172 g_signal_connect(hbox_.get(), "expose-event", 172 g_signal_connect(hbox_.get(), "expose-event",
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 718
719 GtkAllocation right_allocation = menu_button_->allocation; 719 GtkAllocation right_allocation = menu_button_->allocation;
720 GdkRectangle right_clip = { 720 GdkRectangle right_clip = {
721 right_allocation.x, right_allocation.y, 721 right_allocation.x, right_allocation.y,
722 right_allocation.width, right_allocation.height 722 right_allocation.width, right_allocation.height
723 }; 723 };
724 724
725 GtkShadowType body_shadow = 725 GtkShadowType body_shadow =
726 GTK_BUTTON(body_.get())->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT; 726 GTK_BUTTON(body_.get())->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
727 gtk_paint_box(style, widget->window, 727 gtk_paint_box(style, widget->window,
728 static_cast<GtkStateType>(GTK_WIDGET_STATE(body_.get())), 728 gtk_widget_get_state(body_.get()),
729 body_shadow, 729 body_shadow,
730 &left_clip, widget, "button", 730 &left_clip, widget, "button",
731 x, y, width, height); 731 x, y, width, height);
732 732
733 GtkShadowType menu_shadow = 733 GtkShadowType menu_shadow =
734 GTK_BUTTON(menu_button_)->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT; 734 GTK_BUTTON(menu_button_)->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
735 gtk_paint_box(style, widget->window, 735 gtk_paint_box(style, widget->window,
736 static_cast<GtkStateType>(GTK_WIDGET_STATE(menu_button_)), 736 gtk_widget_get_state(menu_button_),
737 menu_shadow, 737 menu_shadow,
738 &right_clip, widget, "button", 738 &right_clip, widget, "button",
739 x, y, width, height); 739 x, y, width, height);
740 740
741 // Doing the math to reverse engineer where we should be drawing our line 741 // Doing the math to reverse engineer where we should be drawing our line
742 // is hard and relies on copying GTK internals, so instead steal the 742 // is hard and relies on copying GTK internals, so instead steal the
743 // allocation of the gtk arrow which is close enough (and will error on 743 // allocation of the gtk arrow which is close enough (and will error on
744 // the conservative side). 744 // the conservative side).
745 GtkAllocation arrow_allocation = arrow_->allocation; 745 GtkAllocation arrow_allocation = arrow_->allocation;
746 gtk_paint_vline(style, widget->window, 746 gtk_paint_vline(style, widget->window,
747 static_cast<GtkStateType>(GTK_WIDGET_STATE(widget)), 747 gtk_widget_get_state(widget),
748 &e->area, widget, "button", 748 &e->area, widget, "button",
749 arrow_allocation.y, 749 arrow_allocation.y,
750 arrow_allocation.y + arrow_allocation.height, 750 arrow_allocation.y + arrow_allocation.height,
751 left_allocation.x + left_allocation.width); 751 left_allocation.x + left_allocation.width);
752 } 752 }
753 } 753 }
754 return FALSE; 754 return FALSE;
755 } 755 }
756 756
757 gboolean DownloadItemGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e) { 757 gboolean DownloadItemGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e) {
758 if (!theme_service_->UsingNativeTheme()) { 758 if (!theme_service_->UsingNativeTheme()) {
759 bool is_body = widget == body_.get(); 759 bool is_body = widget == body_.get();
760 760
761 NineBox* nine_box = NULL; 761 NineBox* nine_box = NULL;
762 // If true, this widget is |body_|, otherwise it is |menu_button_|. 762 // If true, this widget is |body_|, otherwise it is |menu_button_|.
763 if (GTK_WIDGET_STATE(widget) == GTK_STATE_PRELIGHT) 763 if (gtk_widget_get_state(widget) == GTK_STATE_PRELIGHT)
764 nine_box = is_body ? body_nine_box_prelight_ : menu_nine_box_prelight_; 764 nine_box = is_body ? body_nine_box_prelight_ : menu_nine_box_prelight_;
765 else if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) 765 else if (gtk_widget_get_state(widget) == GTK_STATE_ACTIVE)
766 nine_box = is_body ? body_nine_box_active_ : menu_nine_box_active_; 766 nine_box = is_body ? body_nine_box_active_ : menu_nine_box_active_;
767 else 767 else
768 nine_box = is_body ? body_nine_box_normal_ : menu_nine_box_normal_; 768 nine_box = is_body ? body_nine_box_normal_ : menu_nine_box_normal_;
769 769
770 // When the button is showing, we want to draw it as active. We have to do 770 // When the button is showing, we want to draw it as active. We have to do
771 // this explicitly because the button's state will be NORMAL while the menu 771 // this explicitly because the button's state will be NORMAL while the menu
772 // has focus. 772 // has focus.
773 if (!is_body && menu_showing_) 773 if (!is_body && menu_showing_)
774 nine_box = menu_nine_box_active_; 774 nine_box = menu_nine_box_active_;
775 775
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 get_download()->DangerousDownloadValidated(); 872 get_download()->DangerousDownloadValidated();
873 } 873 }
874 874
875 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { 875 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) {
876 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", 876 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download",
877 base::Time::Now() - creation_time_); 877 base::Time::Now() - creation_time_);
878 if (get_download()->IsPartialDownload()) 878 if (get_download()->IsPartialDownload())
879 get_download()->Cancel(true); 879 get_download()->Cancel(true);
880 get_download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); 880 get_download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD);
881 } 881 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/custom_button.cc ('k') | chrome/browser/ui/gtk/extensions/extension_installed_bubble_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698