From 6f35e04b4903927e1df4915e6dc0201f66a0f73b Mon Sep 17 00:00:00 2001 From: "estade@chromium.org" Date: Thu, 5 Mar 2009 20:36:31 +0000 Subject: Several little style cleanups in GTK download shelf code. Review URL: http://codereview.chromium.org/40174 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11029 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/gtk/download_item_gtk.cc | 11 ++++++++--- chrome/browser/gtk/download_item_gtk.h | 4 ++++ chrome/browser/gtk/download_shelf_gtk.cc | 4 ++++ chrome/browser/gtk/download_shelf_gtk.h | 12 +++++++----- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc index c2e72d5..7e6c4f6 100644 --- a/chrome/browser/gtk/download_item_gtk.cc +++ b/chrome/browser/gtk/download_item_gtk.cc @@ -18,7 +18,7 @@ namespace { // bitmap that we use to draw it, i.e. 16, but can be more. const int kMenuButtonWidth = 16; -} +} // namespace NineBox* DownloadItemGtk::body_nine_box_normal_ = NULL; NineBox* DownloadItemGtk::body_nine_box_prelight_ = NULL; @@ -39,8 +39,10 @@ DownloadItemGtk::DownloadItemGtk(BaseDownloadItemModel* download_model, g_signal_connect(G_OBJECT(body_), "expose-event", G_CALLBACK(OnExpose), this); GTK_WIDGET_UNSET_FLAGS(body_, GTK_CAN_FOCUS); - GtkWidget* label = gtk_label_new(download_model->download()->GetFileName() - .value().c_str()); + // TODO(estade): gtk_label_new() expects UTF8, but FilePath may have a + // different encoding on linux. + GtkWidget* label = gtk_label_new( + download_model->download()->GetFileName().value().c_str()); gtk_container_add(GTK_CONTAINER(body_), label); menu_button_ = gtk_button_new(); @@ -57,6 +59,9 @@ DownloadItemGtk::DownloadItemGtk(BaseDownloadItemModel* download_model, gtk_widget_show_all(hbox_); } +DownloadItemGtk::~DownloadItemGtk() { +} + // 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 397e41c..d65f840 100644 --- a/chrome/browser/gtk/download_item_gtk.h +++ b/chrome/browser/gtk/download_item_gtk.h @@ -18,6 +18,10 @@ class DownloadItemGtk { DownloadItemGtk(BaseDownloadItemModel* download_item_model, GtkWidget* parent_shelf); + // We put |hbox_| in |parent_shelf| and rely on |parent_shelf| recursively + // destroying its children. Hence we do nothing in the destructor. + ~DownloadItemGtk(); + private: static void InitNineBoxes(); diff --git a/chrome/browser/gtk/download_shelf_gtk.cc b/chrome/browser/gtk/download_shelf_gtk.cc index 0111b21..a1bc260 100644 --- a/chrome/browser/gtk/download_shelf_gtk.cc +++ b/chrome/browser/gtk/download_shelf_gtk.cc @@ -6,6 +6,7 @@ #include "base/logging.h" #include "chrome/browser/download/download_item_model.h" +#include "chrome/browser/gtk/custom_button.h" #include "chrome/browser/gtk/download_item_gtk.h" #include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" @@ -67,6 +68,9 @@ DownloadShelfGtk::DownloadShelfGtk(TabContents* tab_contents) Show(); } +DownloadShelfGtk::~DownloadShelfGtk() { +} + void DownloadShelfGtk::AddDownload(BaseDownloadItemModel* download_model_) { // TODO(estade): we need to delete these at some point. There's no explicit // mass delete on windows, figure out where they do it. diff --git a/chrome/browser/gtk/download_shelf_gtk.h b/chrome/browser/gtk/download_shelf_gtk.h index 7a2b82e..f5c561f 100644 --- a/chrome/browser/gtk/download_shelf_gtk.h +++ b/chrome/browser/gtk/download_shelf_gtk.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_VIEWS_DOWNLOAD_SHELF_VIEW_H_ -#define CHROME_BROWSER_VIEWS_DOWNLOAD_SHELF_VIEW_H_ +#ifndef CHROME_BROWSER_GTK_DOWNLOAD_SHELF_GTK_H_ +#define CHROME_BROWSER_GTK_DOWNLOAD_SHELF_GTK_H_ #include @@ -11,15 +11,17 @@ #include "base/scoped_ptr.h" #include "chrome/browser/download/download_shelf.h" -#include "chrome/browser/gtk/custom_button.h" class BaseDownloadItemModel; +class CustomDrawButton; class DownloadItemGtk; class DownloadShelfGtk : public DownloadShelf { public: explicit DownloadShelfGtk(TabContents* tab_contents); + ~DownloadShelfGtk(); + // DownloadShelf implementation. virtual void AddDownload(BaseDownloadItemModel* download_model); virtual bool IsShowing() const; @@ -37,7 +39,7 @@ class DownloadShelfGtk : public DownloadShelf { // |hbox_| holds the download items and buttons of the shelf. GtkWidget* hbox_; - // |shelf_box_| is the highest level widget of the shelf. It has a single + // |shelf_| is the highest level widget of the shelf. It has a single // child, |hbox_|. It exists because we need to be able to set the background // color of the shelf, and GtkBoxes don't have a gdk window, which is a // requisite for changing the background color. @@ -53,4 +55,4 @@ class DownloadShelfGtk : public DownloadShelf { std::vector download_items_; }; -#endif // CHROME_BROWSER_VIEWS_DOWNLOAD_SHELF_VIEW_H_ +#endif // CHROME_BROWSER_GTK_DOWNLOAD_SHELF_GTK_H_ -- cgit v1.1