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

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

Issue 115740: Move download shelf from per-tab to per-window (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 6 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
« no previous file with comments | « chrome/browser/gtk/download_item_gtk.h ('k') | chrome/browser/gtk/download_shelf_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 : parent_shelf_(parent_shelf), 170 : parent_shelf_(parent_shelf),
171 menu_showing_(false), 171 menu_showing_(false),
172 progress_angle_(download_util::kStartAngleDegrees), 172 progress_angle_(download_util::kStartAngleDegrees),
173 download_model_(download_model), 173 download_model_(download_model),
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_.Own(gtk_button_new());
181 gtk_widget_set_app_paintable(body_, TRUE); 181 gtk_widget_set_app_paintable(body_.get(), TRUE);
182 g_signal_connect(body_, "expose-event", 182 g_signal_connect(body_.get(), "expose-event",
183 G_CALLBACK(OnExpose), this); 183 G_CALLBACK(OnExpose), this);
184 g_signal_connect(body_, "clicked", 184 g_signal_connect(body_.get(), "clicked",
185 G_CALLBACK(OnClick), this); 185 G_CALLBACK(OnClick), this);
186 GTK_WIDGET_UNSET_FLAGS(body_, GTK_CAN_FOCUS); 186 GTK_WIDGET_UNSET_FLAGS(body_.get(), GTK_CAN_FOCUS);
187 // Remove internal padding on the button. 187 // Remove internal padding on the button.
188 GtkRcStyle* no_padding_style = gtk_rc_style_new(); 188 GtkRcStyle* no_padding_style = gtk_rc_style_new();
189 no_padding_style->xthickness = 0; 189 no_padding_style->xthickness = 0;
190 no_padding_style->ythickness = 0; 190 no_padding_style->ythickness = 0;
191 gtk_widget_modify_style(body_, no_padding_style); 191 gtk_widget_modify_style(body_.get(), no_padding_style);
192 g_object_unref(no_padding_style); 192 g_object_unref(no_padding_style);
193 193
194 name_label_ = gtk_label_new(NULL); 194 name_label_ = gtk_label_new(NULL);
195 195
196 // TODO(estade): This is at best an educated guess, since we don't actually 196 // TODO(estade): This is at best an educated guess, since we don't actually
197 // use gfx::Font() to draw the text. This is why we need to add so 197 // use gfx::Font() to draw the text. This is why we need to add so
198 // much padding when we set the size request. We need to either use gfx::Font 198 // much padding when we set the size request. We need to either use gfx::Font
199 // or somehow extend TextElider. 199 // or somehow extend TextElider.
200 std::wstring elided_filename = gfx::ElideFilename( 200 std::wstring elided_filename = gfx::ElideFilename(
201 get_download()->GetFileName(), 201 get_download()->GetFileName(),
(...skipping 12 matching lines...) Expand all
214 gtk_util::ForceFontSizePixels(name_label_, 13.4); // 13.4px == 10pt @ 96dpi 214 gtk_util::ForceFontSizePixels(name_label_, 13.4); // 13.4px == 10pt @ 96dpi
215 gtk_util::ForceFontSizePixels(status_label_, 13.4); // 13.4px == 10pt @ 96dpi 215 gtk_util::ForceFontSizePixels(status_label_, 13.4); // 13.4px == 10pt @ 96dpi
216 216
217 // Stack the labels on top of one another. 217 // Stack the labels on top of one another.
218 GtkWidget* text_stack = gtk_vbox_new(FALSE, 0); 218 GtkWidget* text_stack = gtk_vbox_new(FALSE, 0);
219 gtk_box_pack_start(GTK_BOX(text_stack), name_label_, TRUE, TRUE, 0); 219 gtk_box_pack_start(GTK_BOX(text_stack), name_label_, TRUE, TRUE, 0);
220 gtk_box_pack_start(GTK_BOX(text_stack), status_label_, FALSE, FALSE, 0); 220 gtk_box_pack_start(GTK_BOX(text_stack), status_label_, FALSE, FALSE, 0);
221 221
222 // We use a GtkFixed because we don't want it to have its own window. 222 // We use a GtkFixed because we don't want it to have its own window.
223 // This choice of widget is not critically important though. 223 // This choice of widget is not critically important though.
224 progress_area_ = gtk_fixed_new(); 224 progress_area_.Own(gtk_fixed_new());
225 gtk_widget_set_size_request(progress_area_, 225 gtk_widget_set_size_request(progress_area_.get(),
226 download_util::kSmallProgressIconSize, 226 download_util::kSmallProgressIconSize,
227 download_util::kSmallProgressIconSize); 227 download_util::kSmallProgressIconSize);
228 gtk_widget_set_app_paintable(progress_area_, TRUE); 228 gtk_widget_set_app_paintable(progress_area_.get(), TRUE);
229 g_signal_connect(progress_area_, "expose-event", 229 g_signal_connect(progress_area_.get(), "expose-event",
230 G_CALLBACK(OnProgressAreaExpose), this); 230 G_CALLBACK(OnProgressAreaExpose), this);
231 231
232 // Put the download progress icon on the left of the labels. 232 // Put the download progress icon on the left of the labels.
233 GtkWidget* body_hbox = gtk_hbox_new(FALSE, 0); 233 GtkWidget* body_hbox = gtk_hbox_new(FALSE, 0);
234 gtk_container_add(GTK_CONTAINER(body_), body_hbox); 234 gtk_container_add(GTK_CONTAINER(body_.get()), body_hbox);
235 gtk_box_pack_start(GTK_BOX(body_hbox), progress_area_, FALSE, FALSE, 0); 235 gtk_box_pack_start(GTK_BOX(body_hbox), progress_area_.get(), FALSE, FALSE, 0);
236 gtk_box_pack_start(GTK_BOX(body_hbox), text_stack, TRUE, TRUE, 0); 236 gtk_box_pack_start(GTK_BOX(body_hbox), text_stack, TRUE, TRUE, 0);
237 237
238 menu_button_ = gtk_button_new(); 238 menu_button_ = gtk_button_new();
239 gtk_widget_set_app_paintable(menu_button_, TRUE); 239 gtk_widget_set_app_paintable(menu_button_, TRUE);
240 GTK_WIDGET_UNSET_FLAGS(menu_button_, GTK_CAN_FOCUS); 240 GTK_WIDGET_UNSET_FLAGS(menu_button_, GTK_CAN_FOCUS);
241 g_signal_connect(menu_button_, "expose-event", 241 g_signal_connect(menu_button_, "expose-event",
242 G_CALLBACK(OnExpose), this); 242 G_CALLBACK(OnExpose), this);
243 g_signal_connect(menu_button_, "button-press-event", 243 g_signal_connect(menu_button_, "button-press-event",
244 G_CALLBACK(OnMenuButtonPressEvent), this); 244 G_CALLBACK(OnMenuButtonPressEvent), this);
245 g_object_set_data(G_OBJECT(menu_button_), "left-align-popup", 245 g_object_set_data(G_OBJECT(menu_button_), "left-align-popup",
246 reinterpret_cast<void*>(true)); 246 reinterpret_cast<void*>(true));
247 gtk_widget_set_size_request(menu_button_, kMenuButtonWidth, 0); 247 gtk_widget_set_size_request(menu_button_, kMenuButtonWidth, 0);
248 248
249 GtkWidget* shelf_hbox = parent_shelf->GetHBox(); 249 GtkWidget* shelf_hbox = parent_shelf->GetHBox();
250 hbox_ = gtk_hbox_new(FALSE, 0); 250 hbox_.Own(gtk_hbox_new(FALSE, 0));
251 gtk_box_pack_start(GTK_BOX(hbox_), body_, FALSE, FALSE, 0); 251 gtk_box_pack_start(GTK_BOX(hbox_.get()), body_.get(), FALSE, FALSE, 0);
252 gtk_box_pack_start(GTK_BOX(hbox_), menu_button_, FALSE, FALSE, 0); 252 gtk_box_pack_start(GTK_BOX(hbox_.get()), menu_button_, FALSE, FALSE, 0);
253 gtk_box_pack_start(GTK_BOX(shelf_hbox), hbox_, FALSE, FALSE, 0); 253 gtk_box_pack_start(GTK_BOX(shelf_hbox), hbox_.get(), FALSE, FALSE, 0);
254 // Insert as the leftmost item. 254 // Insert as the leftmost item.
255 gtk_box_reorder_child(GTK_BOX(shelf_hbox), hbox_, 1); 255 gtk_box_reorder_child(GTK_BOX(shelf_hbox), hbox_.get(), 1);
256 256
257 resize_handler_id_ = g_signal_connect(G_OBJECT(shelf_hbox), "size-allocate", 257 resize_handler_id_ = g_signal_connect(G_OBJECT(shelf_hbox), "size-allocate",
258 G_CALLBACK(OnShelfResized), this); 258 G_CALLBACK(OnShelfResized), this);
259 259
260 get_download()->AddObserver(this); 260 get_download()->AddObserver(this);
261 261
262 new_item_animation_.reset(new SlideAnimation(this)); 262 new_item_animation_.reset(new SlideAnimation(this));
263 new_item_animation_->SetSlideDuration(kNewItemAnimationDurationMs); 263 new_item_animation_->SetSlideDuration(kNewItemAnimationDurationMs);
264 gtk_widget_show_all(hbox_); 264 gtk_widget_show_all(hbox_.get());
265 265
266 if (IsDangerous()) { 266 if (IsDangerous()) {
267 // Hide the download item components for now. 267 // Hide the download item components for now.
268 gtk_widget_hide(body_); 268 gtk_widget_hide(body_.get());
269 gtk_widget_hide(menu_button_); 269 gtk_widget_hide(menu_button_);
270 270
271 // Create an hbox to hold it all. 271 // Create an hbox to hold it all.
272 dangerous_hbox_ = gtk_hbox_new(FALSE, kDangerousElementPadding); 272 dangerous_hbox_ = gtk_hbox_new(FALSE, kDangerousElementPadding);
273 273
274 // Add padding at the beginning and end. The hbox will add padding between 274 // Add padding at the beginning and end. The hbox will add padding between
275 // the empty labels and the other elements. 275 // the empty labels and the other elements.
276 GtkWidget* empty_label_a = gtk_label_new(NULL); 276 GtkWidget* empty_label_a = gtk_label_new(NULL);
277 GtkWidget* empty_label_b = gtk_label_new(NULL); 277 GtkWidget* empty_label_b = gtk_label_new(NULL);
278 gtk_box_pack_start(GTK_BOX(dangerous_hbox_), empty_label_a, 278 gtk_box_pack_start(GTK_BOX(dangerous_hbox_), empty_label_a,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 g_signal_connect(dangerous_decline, "clicked", 320 g_signal_connect(dangerous_decline, "clicked",
321 G_CALLBACK(OnDangerousDecline), this); 321 G_CALLBACK(OnDangerousDecline), this);
322 gtk_util::CenterWidgetInHBox(dangerous_hbox_, dangerous_decline, false, 0); 322 gtk_util::CenterWidgetInHBox(dangerous_hbox_, dangerous_decline, false, 0);
323 323
324 // Put it in an alignment so that padding will be added on the left and 324 // Put it in an alignment so that padding will be added on the left and
325 // right. 325 // right.
326 dangerous_prompt_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); 326 dangerous_prompt_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
327 gtk_alignment_set_padding(GTK_ALIGNMENT(dangerous_prompt_), 327 gtk_alignment_set_padding(GTK_ALIGNMENT(dangerous_prompt_),
328 0, 0, kDangerousElementPadding, kDangerousElementPadding); 328 0, 0, kDangerousElementPadding, kDangerousElementPadding);
329 gtk_container_add(GTK_CONTAINER(dangerous_prompt_), dangerous_hbox_); 329 gtk_container_add(GTK_CONTAINER(dangerous_prompt_), dangerous_hbox_);
330 gtk_box_pack_start(GTK_BOX(hbox_), dangerous_prompt_, FALSE, FALSE, 0); 330 gtk_box_pack_start(GTK_BOX(hbox_.get()), dangerous_prompt_, FALSE, FALSE, 0) ;
331 gtk_widget_set_app_paintable(dangerous_prompt_, TRUE); 331 gtk_widget_set_app_paintable(dangerous_prompt_, TRUE);
332 g_signal_connect(dangerous_prompt_, "expose-event", 332 g_signal_connect(dangerous_prompt_, "expose-event",
333 G_CALLBACK(OnDangerousPromptExpose), this); 333 G_CALLBACK(OnDangerousPromptExpose), this);
334 gtk_widget_show_all(dangerous_prompt_); 334 gtk_widget_show_all(dangerous_prompt_);
335 335
336 // The width will depend on the text. 336 // The width will depend on the text.
337 GtkRequisition req; 337 GtkRequisition req;
338 gtk_widget_size_request(dangerous_hbox_, &req); 338 gtk_widget_size_request(dangerous_hbox_, &req);
339 dangerous_hbox_full_width_ = req.width; 339 dangerous_hbox_full_width_ = req.width;
340 gtk_widget_size_request(dangerous_label, &req); 340 gtk_widget_size_request(dangerous_label, &req);
341 dangerous_hbox_start_width_ = dangerous_hbox_full_width_ - req.width; 341 dangerous_hbox_start_width_ = dangerous_hbox_full_width_ - req.width;
342 } 342 }
343 343
344 new_item_animation_->Show(); 344 new_item_animation_->Show();
345 } 345 }
346 346
347 DownloadItemGtk::~DownloadItemGtk() { 347 DownloadItemGtk::~DownloadItemGtk() {
348 StopDownloadProgress(); 348 StopDownloadProgress();
349 g_signal_handler_disconnect(parent_shelf_->GetHBox(), resize_handler_id_); 349
350 gtk_widget_destroy(hbox_); 350 // If the top-level window was already destroyed, the signal handler was
351 // already disconnected. Disconnect if that's not the case.
352 if (g_signal_handler_find(parent_shelf_->GetHBox(),
353 G_SIGNAL_MATCH_ID,
354 resize_handler_id_,
355 0,
356 NULL,
357 NULL,
358 NULL) != 0) {
359 g_signal_handler_disconnect(parent_shelf_->GetHBox(), resize_handler_id_);
360 }
351 get_download()->RemoveObserver(this); 361 get_download()->RemoveObserver(this);
362
363 hbox_.Destroy();
364 progress_area_.Destroy();
365 body_.Destroy();
352 } 366 }
353 367
354 void DownloadItemGtk::OnDownloadUpdated(DownloadItem* download) { 368 void DownloadItemGtk::OnDownloadUpdated(DownloadItem* download) {
355 DCHECK_EQ(download, get_download()); 369 DCHECK_EQ(download, get_download());
356 370
357 if (dangerous_prompt_ != NULL && 371 if (dangerous_prompt_ != NULL &&
358 download->safety_state() == DownloadItem::DANGEROUS_BUT_VALIDATED) { 372 download->safety_state() == DownloadItem::DANGEROUS_BUT_VALIDATED) {
359 // We have been approved. 373 // We have been approved.
360 gtk_widget_show_all(hbox_); 374 gtk_widget_show_all(hbox_.get());
361 gtk_widget_destroy(dangerous_prompt_); 375 gtk_widget_destroy(dangerous_prompt_);
362 dangerous_prompt_ = NULL; 376 dangerous_prompt_ = NULL;
363 } 377 }
364 378
365 switch (download->state()) { 379 switch (download->state()) {
366 case DownloadItem::REMOVING: 380 case DownloadItem::REMOVING:
367 parent_shelf_->RemoveDownloadItem(this); // This will delete us! 381 parent_shelf_->RemoveDownloadItem(this); // This will delete us!
368 return; 382 return;
369 case DownloadItem::CANCELLED: 383 case DownloadItem::CANCELLED:
370 StopDownloadProgress(); 384 StopDownloadProgress();
(...skipping 29 matching lines...) Expand all
400 414
401 gchar* label_markup = 415 gchar* label_markup =
402 g_markup_printf_escaped(kLabelColorMarkup, kStatusColor, 416 g_markup_printf_escaped(kLabelColorMarkup, kStatusColor,
403 WideToUTF8(status_text).c_str()); 417 WideToUTF8(status_text).c_str());
404 gtk_label_set_markup(GTK_LABEL(status_label_), label_markup); 418 gtk_label_set_markup(GTK_LABEL(status_label_), label_markup);
405 g_free(label_markup); 419 g_free(label_markup);
406 } 420 }
407 421
408 void DownloadItemGtk::AnimationProgressed(const Animation* animation) { 422 void DownloadItemGtk::AnimationProgressed(const Animation* animation) {
409 if (animation == complete_animation_.get()) { 423 if (animation == complete_animation_.get()) {
410 gtk_widget_queue_draw(progress_area_); 424 gtk_widget_queue_draw(progress_area_.get());
411 } else { 425 } else {
412 if (IsDangerous()) { 426 if (IsDangerous()) {
413 int progress = (dangerous_hbox_full_width_ - 427 int progress = (dangerous_hbox_full_width_ -
414 dangerous_hbox_start_width_) * 428 dangerous_hbox_start_width_) *
415 new_item_animation_->GetCurrentValue(); 429 new_item_animation_->GetCurrentValue();
416 int showing_width = dangerous_hbox_start_width_ + progress; 430 int showing_width = dangerous_hbox_start_width_ + progress;
417 showing_width = std::max(kMinDangerousDownloadWidth, showing_width); 431 showing_width = std::max(kMinDangerousDownloadWidth, showing_width);
418 gtk_widget_set_size_request(dangerous_hbox_, showing_width, -1); 432 gtk_widget_set_size_request(dangerous_hbox_, showing_width, -1);
419 } else { 433 } else {
420 DCHECK(animation == new_item_animation_.get()); 434 DCHECK(animation == new_item_animation_.get());
421 // See above TODO for explanation of the extra 50. 435 // See above TODO for explanation of the extra 50.
422 int showing_width = std::max(kMinDownloadItemWidth, 436 int showing_width = std::max(kMinDownloadItemWidth,
423 static_cast<int>((kTextWidth + 50 + 437 static_cast<int>((kTextWidth + 50 +
424 download_util::kSmallProgressIconSize) * 438 download_util::kSmallProgressIconSize) *
425 new_item_animation_->GetCurrentValue())); 439 new_item_animation_->GetCurrentValue()));
426 showing_width = std::max(showing_width, kMinDownloadItemWidth); 440 showing_width = std::max(showing_width, kMinDownloadItemWidth);
427 gtk_widget_set_size_request(body_, showing_width, -1); 441 gtk_widget_set_size_request(body_.get(), showing_width, -1);
428 } 442 }
429 } 443 }
430 } 444 }
431 445
432 DownloadItem* DownloadItemGtk::get_download() { 446 DownloadItem* DownloadItemGtk::get_download() {
433 return download_model_->download(); 447 return download_model_->download();
434 } 448 }
435 449
436 bool DownloadItemGtk::IsDangerous() { 450 bool DownloadItemGtk::IsDangerous() {
437 return get_download()->safety_state() == DownloadItem::DANGEROUS; 451 return get_download()->safety_state() == DownloadItem::DANGEROUS;
438 } 452 }
439 453
440 // Download progress animation functions. 454 // Download progress animation functions.
441 455
442 void DownloadItemGtk::UpdateDownloadProgress() { 456 void DownloadItemGtk::UpdateDownloadProgress() {
443 progress_angle_ = (progress_angle_ + 457 progress_angle_ = (progress_angle_ +
444 download_util::kUnknownIncrementDegrees) % 458 download_util::kUnknownIncrementDegrees) %
445 download_util::kMaxDegrees; 459 download_util::kMaxDegrees;
446 gtk_widget_queue_draw(progress_area_); 460 gtk_widget_queue_draw(progress_area_.get());
447 } 461 }
448 462
449 void DownloadItemGtk::StartDownloadProgress() { 463 void DownloadItemGtk::StartDownloadProgress() {
450 if (progress_timer_.IsRunning()) 464 if (progress_timer_.IsRunning())
451 return; 465 return;
452 progress_timer_.Start( 466 progress_timer_.Start(
453 base::TimeDelta::FromMilliseconds(download_util::kProgressRateMs), this, 467 base::TimeDelta::FromMilliseconds(download_util::kProgressRateMs), this,
454 &DownloadItemGtk::UpdateDownloadProgress); 468 &DownloadItemGtk::UpdateDownloadProgress);
455 } 469 }
456 470
457 void DownloadItemGtk::StopDownloadProgress() { 471 void DownloadItemGtk::StopDownloadProgress() {
458 progress_timer_.Stop(); 472 progress_timer_.Stop();
459 } 473 }
460 474
461 // Icon loading functions. 475 // Icon loading functions.
462 476
463 void DownloadItemGtk::OnLoadIconComplete(IconManager::Handle handle, 477 void DownloadItemGtk::OnLoadIconComplete(IconManager::Handle handle,
464 SkBitmap* icon_bitmap) { 478 SkBitmap* icon_bitmap) {
465 icon_ = icon_bitmap; 479 icon_ = icon_bitmap;
466 gtk_widget_queue_draw(progress_area_); 480 gtk_widget_queue_draw(progress_area_.get());
467 } 481 }
468 482
469 void DownloadItemGtk::LoadIcon() { 483 void DownloadItemGtk::LoadIcon() {
470 IconManager* im = g_browser_process->icon_manager(); 484 IconManager* im = g_browser_process->icon_manager();
471 im->LoadIcon(get_download()->full_path(), 485 im->LoadIcon(get_download()->full_path(),
472 IconLoader::SMALL, &icon_consumer_, 486 IconLoader::SMALL, &icon_consumer_,
473 NewCallback(this, &DownloadItemGtk::OnLoadIconComplete)); 487 NewCallback(this, &DownloadItemGtk::OnLoadIconComplete));
474 } 488 }
475 489
476 // static 490 // static
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 IDR_DOWNLOAD_BUTTON_LEFT_BOTTOM, 550 IDR_DOWNLOAD_BUTTON_LEFT_BOTTOM,
537 IDR_DOWNLOAD_BUTTON_CENTER_BOTTOM, 551 IDR_DOWNLOAD_BUTTON_CENTER_BOTTOM,
538 IDR_DOWNLOAD_BUTTON_RIGHT_BOTTOM_NO_DD); 552 IDR_DOWNLOAD_BUTTON_RIGHT_BOTTOM_NO_DD);
539 } 553 }
540 554
541 // static 555 // static
542 gboolean DownloadItemGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, 556 gboolean DownloadItemGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e,
543 DownloadItemGtk* download_item) { 557 DownloadItemGtk* download_item) {
544 NineBox* nine_box = NULL; 558 NineBox* nine_box = NULL;
545 // If true, this widget is |body_|, otherwise it is |menu_button_|. 559 // If true, this widget is |body_|, otherwise it is |menu_button_|.
546 bool is_body = widget == download_item->body_; 560 bool is_body = widget == download_item->body_.get();
547 if (GTK_WIDGET_STATE(widget) == GTK_STATE_PRELIGHT) 561 if (GTK_WIDGET_STATE(widget) == GTK_STATE_PRELIGHT)
548 nine_box = is_body ? body_nine_box_prelight_ : menu_nine_box_prelight_; 562 nine_box = is_body ? body_nine_box_prelight_ : menu_nine_box_prelight_;
549 else if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) 563 else if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE)
550 nine_box = is_body ? body_nine_box_active_ : menu_nine_box_active_; 564 nine_box = is_body ? body_nine_box_active_ : menu_nine_box_active_;
551 else 565 else
552 nine_box = is_body ? body_nine_box_normal_ : menu_nine_box_normal_; 566 nine_box = is_body ? body_nine_box_normal_ : menu_nine_box_normal_;
553 567
554 // When the button is showing, we want to draw it as active. We have to do 568 // When the button is showing, we want to draw it as active. We have to do
555 // this explicitly because the button's state will be NORMAL while the menu 569 // this explicitly because the button's state will be NORMAL while the menu
556 // has focus. 570 // has focus.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 } 648 }
635 } 649 }
636 650
637 return FALSE; 651 return FALSE;
638 } 652 }
639 653
640 // static 654 // static
641 void DownloadItemGtk::OnShelfResized(GtkWidget *widget, 655 void DownloadItemGtk::OnShelfResized(GtkWidget *widget,
642 GtkAllocation *allocation, 656 GtkAllocation *allocation,
643 DownloadItemGtk* item) { 657 DownloadItemGtk* item) {
644 if (item->hbox_->allocation.x + item->hbox_->allocation.width > 658 if (item->hbox_.get()->allocation.x + item->hbox_.get()->allocation.width >
645 item->bounding_widget_->allocation.x) 659 item->bounding_widget_->allocation.x)
646 gtk_widget_hide(item->hbox_); 660 gtk_widget_hide(item->hbox_.get());
647 else 661 else
648 gtk_widget_show(item->hbox_); 662 gtk_widget_show(item->hbox_.get());
649 } 663 }
650 664
651 // static 665 // static
652 gboolean DownloadItemGtk::OnDangerousPromptExpose(GtkWidget* widget, 666 gboolean DownloadItemGtk::OnDangerousPromptExpose(GtkWidget* widget,
653 GdkEventExpose* event, DownloadItemGtk* item) { 667 GdkEventExpose* event, DownloadItemGtk* item) {
654 dangerous_nine_box_->RenderToWidget(widget); 668 dangerous_nine_box_->RenderToWidget(widget);
655 return FALSE; // Continue propagation. 669 return FALSE; // Continue propagation.
656 } 670 }
657 671
658 // static 672 // static
659 // TODO(estade): here and below, add clickjacking histogram code. 673 // TODO(estade): here and below, add clickjacking histogram code.
660 void DownloadItemGtk::OnDangerousAccept(GtkWidget* button, 674 void DownloadItemGtk::OnDangerousAccept(GtkWidget* button,
661 DownloadItemGtk* item) { 675 DownloadItemGtk* item) {
662 item->get_download()->manager()->DangerousDownloadValidated( 676 item->get_download()->manager()->DangerousDownloadValidated(
663 item->get_download()); 677 item->get_download());
664 } 678 }
665 679
666 // static 680 // static
667 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button, 681 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button,
668 DownloadItemGtk* item) { 682 DownloadItemGtk* item) {
669 if (item->get_download()->state() == DownloadItem::IN_PROGRESS) 683 if (item->get_download()->state() == DownloadItem::IN_PROGRESS)
670 item->get_download()->Cancel(true); 684 item->get_download()->Cancel(true);
671 item->get_download()->Remove(true); 685 item->get_download()->Remove(true);
672 } 686 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/download_item_gtk.h ('k') | chrome/browser/gtk/download_shelf_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698