summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/download_item_gtk.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-05 20:50:44 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-05 20:50:44 +0000
commitb2cc43523f7bb309cecd6071de51a1677e5d15cf (patch)
treef35c93b5d7cdd95877f86f30cca96738856b7236 /chrome/browser/gtk/download_item_gtk.cc
parentbef76ead355bfb64d93336a548b8b16602a853c1 (diff)
downloadchromium_src-b2cc43523f7bb309cecd6071de51a1677e5d15cf.zip
chromium_src-b2cc43523f7bb309cecd6071de51a1677e5d15cf.tar.gz
chromium_src-b2cc43523f7bb309cecd6071de51a1677e5d15cf.tar.bz2
Linux download shelf: remove download items when the associated download is removed.
BUG=11381 TEST=in opt mode: download something, go to downloads tab, clear all, go back to tab with downloaded item. The shelf should be gone. Review URL: http://codereview.chromium.org/100366 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15335 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/download_item_gtk.cc')
-rw-r--r--chrome/browser/gtk/download_item_gtk.cc41
1 files changed, 31 insertions, 10 deletions
diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc
index b3f4238..5697e50c 100644
--- a/chrome/browser/gtk/download_item_gtk.cc
+++ b/chrome/browser/gtk/download_item_gtk.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/download/download_shelf.h"
+#include "chrome/browser/gtk/download_shelf_gtk.h"
#include "chrome/browser/gtk/menu_gtk.h"
#include "chrome/browser/gtk/nine_box.h"
#include "chrome/common/gfx/chrome_font.h"
@@ -135,12 +136,11 @@ NineBox* DownloadItemGtk::menu_nine_box_normal_ = NULL;
NineBox* DownloadItemGtk::menu_nine_box_prelight_ = NULL;
NineBox* DownloadItemGtk::menu_nine_box_active_ = NULL;
-DownloadItemGtk::DownloadItemGtk(BaseDownloadItemModel* download_model,
- GtkWidget* parent_shelf,
- GtkWidget* bounding_widget)
- : download_model_(download_model),
- parent_shelf_(parent_shelf),
- bounding_widget_(bounding_widget) {
+DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf,
+ BaseDownloadItemModel* download_model)
+ : parent_shelf_(parent_shelf),
+ download_model_(download_model),
+ bounding_widget_(parent_shelf->GetRightBoundingWidget()) {
InitNineBoxes();
body_ = gtk_button_new();
@@ -185,15 +185,16 @@ DownloadItemGtk::DownloadItemGtk(BaseDownloadItemModel* download_model,
reinterpret_cast<void*>(true));
gtk_widget_set_size_request(menu_button_, kMenuButtonWidth, 0);
+ GtkWidget* shelf_hbox = parent_shelf->GetHBox();
hbox_ = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox_), body_, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox_), menu_button_, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(parent_shelf), hbox_, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(shelf_hbox), hbox_, FALSE, FALSE, 0);
// Insert as the leftmost item.
- gtk_box_reorder_child(GTK_BOX(parent_shelf), hbox_, 1);
+ gtk_box_reorder_child(GTK_BOX(shelf_hbox), hbox_, 1);
- g_signal_connect(G_OBJECT(parent_shelf_), "size-allocate",
- G_CALLBACK(OnShelfResized), this);
+ resize_handler_id_ = g_signal_connect(G_OBJECT(shelf_hbox), "size-allocate",
+ G_CALLBACK(OnShelfResized), this);
download_model_->download()->AddObserver(this);
@@ -204,11 +205,31 @@ DownloadItemGtk::DownloadItemGtk(BaseDownloadItemModel* download_model,
}
DownloadItemGtk::~DownloadItemGtk() {
+ g_signal_handler_disconnect(parent_shelf_->GetHBox(), resize_handler_id_);
+ gtk_widget_destroy(hbox_);
download_model_->download()->RemoveObserver(this);
}
void DownloadItemGtk::OnDownloadUpdated(DownloadItem* download) {
DCHECK_EQ(download, download_model_->download());
+
+ switch (download->state()) {
+ case DownloadItem::REMOVING:
+ parent_shelf_->RemoveDownloadItem(this); // This will delete us!
+ return;
+ case DownloadItem::CANCELLED:
+ case DownloadItem::COMPLETE:
+ case DownloadItem::IN_PROGRESS:
+ // TODO(estade): adjust download progress animation appropriately, once
+ // we have download progress animations.
+ NOTIMPLEMENTED();
+ break;
+ default:
+ NOTREACHED();
+ }
+
+ // Now update the status label. We may have already removed it; if so, we
+ // do nothing.
if (!status_label_) {
return;
}