summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-26 18:50:51 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-26 18:50:51 +0000
commit5228d56c2b19231923504dfbcd306f0c93058fca (patch)
tree5aaca6e85c369a7c8ae75e6f3ec6bd3695ae9613 /chrome
parent1676374870966b50e20d7097881e49c084a7caf5 (diff)
downloadchromium_src-5228d56c2b19231923504dfbcd306f0c93058fca.zip
chromium_src-5228d56c2b19231923504dfbcd306f0c93058fca.tar.gz
chromium_src-5228d56c2b19231923504dfbcd306f0c93058fca.tar.bz2
Linux download shelf:
- Show status text. - Pack new items on the left. Review URL: http://codereview.chromium.org/53084 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12582 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/gtk/download_item_gtk.cc25
-rw-r--r--chrome/browser/gtk/download_item_gtk.h9
-rw-r--r--chrome/browser/gtk/download_shelf_gtk.cc6
-rw-r--r--chrome/browser/gtk/nine_box.cc2
4 files changed, 35 insertions, 7 deletions
diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc
index ded475c..941afd0 100644
--- a/chrome/browser/gtk/download_item_gtk.cc
+++ b/chrome/browser/gtk/download_item_gtk.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/gtk/download_item_gtk.h"
#include "base/basictypes.h"
+#include "base/string_util.h"
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/download/download_shelf.h"
@@ -129,9 +130,18 @@ DownloadItemGtk::DownloadItemGtk(BaseDownloadItemModel* download_model,
GTK_WIDGET_UNSET_FLAGS(body_, GTK_CAN_FOCUS);
// TODO(estade): gtk_label_new() expects UTF8, but FilePath may have a
// different encoding on linux.
- GtkWidget* label = gtk_label_new(
+ GtkWidget* name_label = gtk_label_new(
download_model->download()->GetFileName().value().c_str());
- gtk_container_add(GTK_CONTAINER(body_), label);
+ gtk_misc_set_alignment(GTK_MISC(name_label), 0, 0);
+ status_label_ =
+ gtk_label_new(WideToUTF8(download_model->GetStatusText()).c_str());
+ gtk_misc_set_alignment(GTK_MISC(status_label_), 0, 0);
+
+ // Stack the labels on top of one another.
+ GtkWidget* text_stack = gtk_vbox_new(FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(text_stack), name_label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(text_stack), status_label_, FALSE, FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(body_), text_stack);
menu_button_ = gtk_button_new();
gtk_widget_set_app_paintable(menu_button_, TRUE);
@@ -148,12 +158,23 @@ DownloadItemGtk::DownloadItemGtk(BaseDownloadItemModel* download_model,
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);
+ // Insert as the leftmost item.
+ gtk_box_reorder_child(GTK_BOX(parent_shelf), hbox_, 1);
gtk_widget_show_all(hbox_);
+
+ download_model_->download()->AddObserver(this);
}
DownloadItemGtk::~DownloadItemGtk() {
}
+void DownloadItemGtk::OnDownloadUpdated(DownloadItem* download) {
+ DCHECK_EQ(download, download_model_->download());
+
+ gtk_label_set_text(GTK_LABEL(status_label_),
+ WideToUTF8(download_model_->GetStatusText()).c_str());
+}
+
// static
void DownloadItemGtk::InitNineBoxes() {
if (body_nine_box_normal_)
diff --git a/chrome/browser/gtk/download_item_gtk.h b/chrome/browser/gtk/download_item_gtk.h
index 5044a25..f0f04c6 100644
--- a/chrome/browser/gtk/download_item_gtk.h
+++ b/chrome/browser/gtk/download_item_gtk.h
@@ -8,12 +8,13 @@
#include <gtk/gtk.h>
#include "base/scoped_ptr.h"
+#include "chrome/browser/download/download_manager.h"
class BaseDownloadItemModel;
class DownloadShelfContextMenuGtk;
class NineBox;
-class DownloadItemGtk {
+class DownloadItemGtk : DownloadItem::Observer {
public:
// DownloadItemGtk takes ownership of |download_item_model|.
DownloadItemGtk(BaseDownloadItemModel* download_item_model,
@@ -23,6 +24,9 @@ class DownloadItemGtk {
// destroying its children. Hence we do nothing in the destructor.
~DownloadItemGtk();
+ // DownloadItem::Observer implementation
+ virtual void OnDownloadUpdated(DownloadItem* download);
+
private:
static void InitNineBoxes();
@@ -50,6 +54,9 @@ class DownloadItemGtk {
// animation.
GtkWidget* body_;
+ // The GtkLabel that holds the status text.
+ GtkWidget* status_label_;
+
// The widget that creates a dropdown menu when pressed.
GtkWidget* menu_button_;
diff --git a/chrome/browser/gtk/download_shelf_gtk.cc b/chrome/browser/gtk/download_shelf_gtk.cc
index 6e3598a..3d30e89 100644
--- a/chrome/browser/gtk/download_shelf_gtk.cc
+++ b/chrome/browser/gtk/download_shelf_gtk.cc
@@ -16,9 +16,9 @@
namespace {
-// The height of the download items. Should be 28, as that is the height of
-// their bitmaps.
-const int kDownloadItemHeight = 28;
+// The height of the download items. Should be at least 28, as that is the
+// minimum height of their nineboxes.
+const int kDownloadItemHeight = 38;
// Padding between the download widgets.
const int kDownloadItemPadding = 10;
diff --git a/chrome/browser/gtk/nine_box.cc b/chrome/browser/gtk/nine_box.cc
index 1754536..3852314 100644
--- a/chrome/browser/gtk/nine_box.cc
+++ b/chrome/browser/gtk/nine_box.cc
@@ -108,7 +108,7 @@ void NineBox::TileImage(GdkPixbuf* src, GdkPixbuf* dst,
const int src_width = gdk_pixbuf_get_width(src);
const int src_height = gdk_pixbuf_get_height(src);
const int dst_width = gdk_pixbuf_get_width(dst);
- const int dst_height = gdk_pixbuf_get_width(dst);
+ const int dst_height = gdk_pixbuf_get_height(dst);
// We only tile along one axis (see above TODO about nuking all this code),
// dx or dy will be nonzero along that axis.