diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-04 03:30:22 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-04 03:30:22 +0000 |
commit | 59560e0ba999d5edc33453d4a0fbf44831025817 (patch) | |
tree | f365944f6f0eca593a28747a7fed4caf169578fb /chrome/browser/gtk | |
parent | 4d2868972ff25746d39ecea58e88480ae0463145 (diff) | |
download | chromium_src-59560e0ba999d5edc33453d4a0fbf44831025817.zip chromium_src-59560e0ba999d5edc33453d4a0fbf44831025817.tar.gz chromium_src-59560e0ba999d5edc33453d4a0fbf44831025817.tar.bz2 |
Move download shelf from per-tab to per-window. Also disable auto-hiding of
the shelf.
BUG=9025
TEST=Download file in one tab, open new tab, and check that download shelf is
still open. Also try the shelf's close button and the "show all downloads"
link. When saving a file, the download animation should not show up.
Review URL: http://codereview.chromium.org/115740
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17595 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 19 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.h | 6 | ||||
-rw-r--r-- | chrome/browser/gtk/download_item_gtk.cc | 76 | ||||
-rw-r--r-- | chrome/browser/gtk/download_item_gtk.h | 10 | ||||
-rw-r--r-- | chrome/browser/gtk/download_shelf_gtk.cc | 54 | ||||
-rw-r--r-- | chrome/browser/gtk/download_shelf_gtk.h | 11 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_renderer_gtk.cc | 27 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_renderer_gtk.h | 9 |
8 files changed, 116 insertions, 96 deletions
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 5c090d6..f4b86f2 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -18,10 +18,13 @@ #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" +#include "chrome/browser/download/download_item_model.h" +#include "chrome/browser/download/download_manager.h" #include "chrome/browser/gtk/about_chrome_dialog.h" #include "chrome/browser/gtk/bookmark_bar_gtk.h" #include "chrome/browser/gtk/browser_toolbar_gtk.h" #include "chrome/browser/gtk/clear_browsing_data_dialog_gtk.h" +#include "chrome/browser/gtk/download_shelf_gtk.h" #include "chrome/browser/gtk/go_button_gtk.h" #include "chrome/browser/gtk/import_dialog_gtk.h" #include "chrome/browser/gtk/infobar_container_gtk.h" @@ -566,6 +569,17 @@ void BrowserWindowGtk::ShowBookmarkBubble(const GURL& url, toolbar_->star()->ShowStarBubble(url, !already_bookmarked); } +bool BrowserWindowGtk::IsDownloadShelfVisible() const { + return download_shelf_.get() && download_shelf_->IsShowing(); +} + +DownloadShelf* BrowserWindowGtk::GetDownloadShelf() { + if (!download_shelf_.get()) + download_shelf_.reset(new DownloadShelfGtk(browser_.get(), + render_area_vbox_)); + return download_shelf_.get(); +} + void BrowserWindowGtk::ShowReportBugDialog() { NOTIMPLEMENTED(); } @@ -604,11 +618,12 @@ void BrowserWindowGtk::UserChangedTheme() { } int BrowserWindowGtk::GetExtraRenderViewHeight() const { - // The download shelf is controlled by its TabContents, so we don't have to - // worry about it here. int sum = infobar_container_->TotalHeightOfClosingBars(); if (bookmark_bar_->IsClosing()) sum += bookmark_bar_->GetHeight(); + if (download_shelf_.get() && download_shelf_->IsClosing()) { + sum += download_shelf_->GetHeight(); + } return sum; } diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h index 8e6dee5..4e5f067ad 100644 --- a/chrome/browser/gtk/browser_window_gtk.h +++ b/chrome/browser/gtk/browser_window_gtk.h @@ -19,6 +19,7 @@ class BookmarkBarGtk; class BrowserToolbarGtk; +class DownloadShelfGtk; class FindBarGtk; class InfoBarContainerGtk; class LocationBar; @@ -71,6 +72,8 @@ class BrowserWindowGtk : public BrowserWindow, virtual void ShowAboutChromeDialog(); virtual void ShowBookmarkManager(); virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked); + virtual bool IsDownloadShelfVisible() const; + virtual DownloadShelf* GetDownloadShelf(); virtual void ShowReportBugDialog(); virtual void ShowClearBrowsingDataDialog(); virtual void ShowImportDialog(); @@ -136,6 +139,9 @@ class BrowserWindowGtk : public BrowserWindow, scoped_ptr<Browser> browser_; + // The download shelf view (view at the bottom of the page). + scoped_ptr<DownloadShelfGtk> download_shelf_; + private: // Sets the default size for the window and the the way the user is allowed to // resize it. diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc index 55ef572..22f2b3a 100644 --- a/chrome/browser/gtk/download_item_gtk.cc +++ b/chrome/browser/gtk/download_item_gtk.cc @@ -177,18 +177,18 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, InitNineBoxes(); LoadIcon(); - body_ = gtk_button_new(); - gtk_widget_set_app_paintable(body_, TRUE); - g_signal_connect(body_, "expose-event", + body_.Own(gtk_button_new()); + gtk_widget_set_app_paintable(body_.get(), TRUE); + g_signal_connect(body_.get(), "expose-event", G_CALLBACK(OnExpose), this); - g_signal_connect(body_, "clicked", + g_signal_connect(body_.get(), "clicked", G_CALLBACK(OnClick), this); - GTK_WIDGET_UNSET_FLAGS(body_, GTK_CAN_FOCUS); + GTK_WIDGET_UNSET_FLAGS(body_.get(), GTK_CAN_FOCUS); // Remove internal padding on the button. GtkRcStyle* no_padding_style = gtk_rc_style_new(); no_padding_style->xthickness = 0; no_padding_style->ythickness = 0; - gtk_widget_modify_style(body_, no_padding_style); + gtk_widget_modify_style(body_.get(), no_padding_style); g_object_unref(no_padding_style); name_label_ = gtk_label_new(NULL); @@ -221,18 +221,18 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, // We use a GtkFixed because we don't want it to have its own window. // This choice of widget is not critically important though. - progress_area_ = gtk_fixed_new(); - gtk_widget_set_size_request(progress_area_, + progress_area_.Own(gtk_fixed_new()); + gtk_widget_set_size_request(progress_area_.get(), download_util::kSmallProgressIconSize, download_util::kSmallProgressIconSize); - gtk_widget_set_app_paintable(progress_area_, TRUE); - g_signal_connect(progress_area_, "expose-event", + gtk_widget_set_app_paintable(progress_area_.get(), TRUE); + g_signal_connect(progress_area_.get(), "expose-event", G_CALLBACK(OnProgressAreaExpose), this); // Put the download progress icon on the left of the labels. GtkWidget* body_hbox = gtk_hbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(body_), body_hbox); - gtk_box_pack_start(GTK_BOX(body_hbox), progress_area_, FALSE, FALSE, 0); + gtk_container_add(GTK_CONTAINER(body_.get()), body_hbox); + gtk_box_pack_start(GTK_BOX(body_hbox), progress_area_.get(), FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(body_hbox), text_stack, TRUE, TRUE, 0); menu_button_ = gtk_button_new(); @@ -247,12 +247,12 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, 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(shelf_hbox), hbox_, FALSE, FALSE, 0); + hbox_.Own(gtk_hbox_new(FALSE, 0)); + gtk_box_pack_start(GTK_BOX(hbox_.get()), body_.get(), FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox_.get()), menu_button_, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(shelf_hbox), hbox_.get(), FALSE, FALSE, 0); // Insert as the leftmost item. - gtk_box_reorder_child(GTK_BOX(shelf_hbox), hbox_, 1); + gtk_box_reorder_child(GTK_BOX(shelf_hbox), hbox_.get(), 1); resize_handler_id_ = g_signal_connect(G_OBJECT(shelf_hbox), "size-allocate", G_CALLBACK(OnShelfResized), this); @@ -261,11 +261,11 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, new_item_animation_.reset(new SlideAnimation(this)); new_item_animation_->SetSlideDuration(kNewItemAnimationDurationMs); - gtk_widget_show_all(hbox_); + gtk_widget_show_all(hbox_.get()); if (IsDangerous()) { // Hide the download item components for now. - gtk_widget_hide(body_); + gtk_widget_hide(body_.get()); gtk_widget_hide(menu_button_); // Create an hbox to hold it all. @@ -327,7 +327,7 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, gtk_alignment_set_padding(GTK_ALIGNMENT(dangerous_prompt_), 0, 0, kDangerousElementPadding, kDangerousElementPadding); gtk_container_add(GTK_CONTAINER(dangerous_prompt_), dangerous_hbox_); - gtk_box_pack_start(GTK_BOX(hbox_), dangerous_prompt_, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox_.get()), dangerous_prompt_, FALSE, FALSE, 0); gtk_widget_set_app_paintable(dangerous_prompt_, TRUE); g_signal_connect(dangerous_prompt_, "expose-event", G_CALLBACK(OnDangerousPromptExpose), this); @@ -346,9 +346,23 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, DownloadItemGtk::~DownloadItemGtk() { StopDownloadProgress(); - g_signal_handler_disconnect(parent_shelf_->GetHBox(), resize_handler_id_); - gtk_widget_destroy(hbox_); + + // If the top-level window was already destroyed, the signal handler was + // already disconnected. Disconnect if that's not the case. + if (g_signal_handler_find(parent_shelf_->GetHBox(), + G_SIGNAL_MATCH_ID, + resize_handler_id_, + 0, + NULL, + NULL, + NULL) != 0) { + g_signal_handler_disconnect(parent_shelf_->GetHBox(), resize_handler_id_); + } get_download()->RemoveObserver(this); + + hbox_.Destroy(); + progress_area_.Destroy(); + body_.Destroy(); } void DownloadItemGtk::OnDownloadUpdated(DownloadItem* download) { @@ -357,7 +371,7 @@ void DownloadItemGtk::OnDownloadUpdated(DownloadItem* download) { if (dangerous_prompt_ != NULL && download->safety_state() == DownloadItem::DANGEROUS_BUT_VALIDATED) { // We have been approved. - gtk_widget_show_all(hbox_); + gtk_widget_show_all(hbox_.get()); gtk_widget_destroy(dangerous_prompt_); dangerous_prompt_ = NULL; } @@ -407,7 +421,7 @@ void DownloadItemGtk::OnDownloadUpdated(DownloadItem* download) { void DownloadItemGtk::AnimationProgressed(const Animation* animation) { if (animation == complete_animation_.get()) { - gtk_widget_queue_draw(progress_area_); + gtk_widget_queue_draw(progress_area_.get()); } else { if (IsDangerous()) { int progress = (dangerous_hbox_full_width_ - @@ -424,7 +438,7 @@ void DownloadItemGtk::AnimationProgressed(const Animation* animation) { download_util::kSmallProgressIconSize) * new_item_animation_->GetCurrentValue())); showing_width = std::max(showing_width, kMinDownloadItemWidth); - gtk_widget_set_size_request(body_, showing_width, -1); + gtk_widget_set_size_request(body_.get(), showing_width, -1); } } } @@ -443,7 +457,7 @@ void DownloadItemGtk::UpdateDownloadProgress() { progress_angle_ = (progress_angle_ + download_util::kUnknownIncrementDegrees) % download_util::kMaxDegrees; - gtk_widget_queue_draw(progress_area_); + gtk_widget_queue_draw(progress_area_.get()); } void DownloadItemGtk::StartDownloadProgress() { @@ -463,7 +477,7 @@ void DownloadItemGtk::StopDownloadProgress() { void DownloadItemGtk::OnLoadIconComplete(IconManager::Handle handle, SkBitmap* icon_bitmap) { icon_ = icon_bitmap; - gtk_widget_queue_draw(progress_area_); + gtk_widget_queue_draw(progress_area_.get()); } void DownloadItemGtk::LoadIcon() { @@ -543,7 +557,7 @@ gboolean DownloadItemGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, DownloadItemGtk* download_item) { NineBox* nine_box = NULL; // If true, this widget is |body_|, otherwise it is |menu_button_|. - bool is_body = widget == download_item->body_; + bool is_body = widget == download_item->body_.get(); if (GTK_WIDGET_STATE(widget) == GTK_STATE_PRELIGHT) nine_box = is_body ? body_nine_box_prelight_ : menu_nine_box_prelight_; else if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) @@ -641,11 +655,11 @@ gboolean DownloadItemGtk::OnMenuButtonPressEvent(GtkWidget* button, void DownloadItemGtk::OnShelfResized(GtkWidget *widget, GtkAllocation *allocation, DownloadItemGtk* item) { - if (item->hbox_->allocation.x + item->hbox_->allocation.width > + if (item->hbox_.get()->allocation.x + item->hbox_.get()->allocation.width > item->bounding_widget_->allocation.x) - gtk_widget_hide(item->hbox_); + gtk_widget_hide(item->hbox_.get()); else - gtk_widget_show(item->hbox_); + gtk_widget_show(item->hbox_.get()); } // static diff --git a/chrome/browser/gtk/download_item_gtk.h b/chrome/browser/gtk/download_item_gtk.h index 13680cd..e2fbf10 100644 --- a/chrome/browser/gtk/download_item_gtk.h +++ b/chrome/browser/gtk/download_item_gtk.h @@ -11,6 +11,7 @@ #include "base/scoped_ptr.h" #include "chrome/browser/download/download_manager.h" #include "chrome/browser/icon_manager.h" +#include "chrome/common/owned_widget_gtk.h" class BaseDownloadItemModel; class DownloadShelfContextMenuGtk; @@ -26,8 +27,7 @@ class DownloadItemGtk : public DownloadItem::Observer, DownloadItemGtk(DownloadShelfGtk* parent_shelf, BaseDownloadItemModel* download_item_model); - // We put |hbox_| in |parent_shelf| and rely on |parent_shelf| recursively - // destroying its children. Hence we do nothing in the destructor. + // Destroys all widgets belonging to this DownloadItemGtk. ~DownloadItemGtk(); // DownloadItem::Observer implementation. @@ -109,11 +109,11 @@ class DownloadItemGtk : public DownloadItem::Observer, DownloadShelfGtk* parent_shelf_; // The widget that contains the body and menu dropdown. - GtkWidget* hbox_; + OwnedWidgetGtk hbox_; // The widget that contains the name of the download and the progress // animation. - GtkWidget* body_; + OwnedWidgetGtk body_; // The GtkLabel that holds the download title text. GtkWidget* name_label_; @@ -130,7 +130,7 @@ class DownloadItemGtk : public DownloadItem::Observer, // The widget that contains the animation progress and the file's icon // (as well as the complete animation). - GtkWidget* progress_area_; + OwnedWidgetGtk progress_area_; // In degrees. Only used for downloads with no known total size. int progress_angle_; diff --git a/chrome/browser/gtk/download_shelf_gtk.cc b/chrome/browser/gtk/download_shelf_gtk.cc index 005536e..ab5e4c3 100644 --- a/chrome/browser/gtk/download_shelf_gtk.cc +++ b/chrome/browser/gtk/download_shelf_gtk.cc @@ -7,8 +7,10 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/gfx/gtk_util.h" +#include "chrome/browser/browser.h" #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/download/download_util.h" +#include "chrome/browser/gtk/browser_window_gtk.h" #include "chrome/browser/gtk/custom_button.h" #include "chrome/browser/gtk/download_item_gtk.h" #include "chrome/browser/gtk/gtk_chrome_link_button.h" @@ -47,13 +49,8 @@ const int kShelfAnimationDurationMs = 120; } // namespace -// static -DownloadShelf* DownloadShelf::Create(TabContents* tab_contents) { - return new DownloadShelfGtk(tab_contents); -} - -DownloadShelfGtk::DownloadShelfGtk(TabContents* tab_contents) - : DownloadShelf(tab_contents), +DownloadShelfGtk::DownloadShelfGtk(Browser* browser, GtkWidget* parent) + : DownloadShelf(browser), is_showing_(false) { // Logically, the shelf is a vbox that contains two children: a one pixel // tall event box, which serves as the top border, and an hbox, which holds @@ -69,8 +66,8 @@ DownloadShelfGtk::DownloadShelfGtk(TabContents* tab_contents) gtk_widget_modify_bg(top_border, GTK_STATE_NORMAL, &kBorderColor); // Create |hbox_|. - hbox_ = gtk_hbox_new(FALSE, kDownloadItemPadding); - gtk_widget_set_size_request(hbox_, -1, kDownloadItemHeight); + hbox_.Own(gtk_hbox_new(FALSE, kDownloadItemPadding)); + gtk_widget_set_size_request(hbox_.get(), -1, kDownloadItemHeight); // Get the padding and background color for |hbox_| right. GtkWidget* padding = gtk_alignment_new(0, 0, 1, 1); @@ -79,7 +76,7 @@ DownloadShelfGtk::DownloadShelfGtk(TabContents* tab_contents) kTopBottomPadding - 1, kTopBottomPadding, kLeftPadding, kRightPadding); GtkWidget* padding_bg = gtk_event_box_new(); gtk_container_add(GTK_CONTAINER(padding_bg), padding); - gtk_container_add(GTK_CONTAINER(padding), hbox_); + gtk_container_add(GTK_CONTAINER(padding), hbox_.get()); gtk_widget_modify_bg(padding_bg, GTK_STATE_NORMAL, &kBackgroundColor); shelf_.Own(gtk_vbox_new(FALSE, 0)); @@ -88,7 +85,7 @@ DownloadShelfGtk::DownloadShelfGtk(TabContents* tab_contents) // Create and pack the close button. close_button_.reset(CustomDrawButton::CloseButton()); - gtk_util::CenterWidgetInHBox(hbox_, close_button_->widget(), true, 0); + gtk_util::CenterWidgetInHBox(hbox_.get(), close_button_->widget(), true, 0); g_signal_connect(close_button_->widget(), "clicked", G_CALLBACK(OnButtonClick), this); @@ -112,16 +109,16 @@ DownloadShelfGtk::DownloadShelfGtk(TabContents* tab_contents) link_hbox_ = gtk_hbox_new(FALSE, 5); gtk_util::CenterWidgetInHBox(link_hbox_, download_image, false, 0); gtk_util::CenterWidgetInHBox(link_hbox_, link_button, false, 0); - gtk_box_pack_end(GTK_BOX(hbox_), link_hbox_, FALSE, FALSE, 0); + gtk_box_pack_end(GTK_BOX(hbox_.get()), link_hbox_, FALSE, FALSE, 0); slide_widget_.reset(new SlideAnimatorGtk(shelf_.get(), SlideAnimatorGtk::UP, kShelfAnimationDurationMs, false, NULL)); gtk_widget_show_all(shelf_.get()); - // Stick ourselves at the bottom of the parent tab contents. - GtkWidget* parent_contents = tab_contents->GetNativeView(); - gtk_box_pack_end(GTK_BOX(parent_contents), slide_widget_->widget(), + + // Stick ourselves at the bottom of the parent browser. + gtk_box_pack_end(GTK_BOX(parent), slide_widget_->widget(), FALSE, FALSE, 0); slide_widget_->Open(); } @@ -133,11 +130,12 @@ DownloadShelfGtk::~DownloadShelfGtk() { } shelf_.Destroy(); + hbox_.Destroy(); } void DownloadShelfGtk::AddDownload(BaseDownloadItemModel* download_model_) { download_items_.push_back(new DownloadItemGtk(this, download_model_)); - slide_widget_->Open(); + Show(); } bool DownloadShelfGtk::IsShowing() const { @@ -148,6 +146,21 @@ bool DownloadShelfGtk::IsClosing() const { return slide_widget_->IsClosing(); } +void DownloadShelfGtk::Show() { + slide_widget_->Open(); +} + +void DownloadShelfGtk::Close() { + slide_widget_->Close(); + + // TODO(estade): Remove. The status bubble should query its window instead. + browser_->UpdateDownloadShelfVisibility(false); +} + +int DownloadShelfGtk::GetHeight() const { + return slide_widget_->widget()->allocation.height; +} + void DownloadShelfGtk::RemoveDownloadItem(DownloadItemGtk* download_item) { DCHECK(download_item); std::vector<DownloadItemGtk*>::iterator i = @@ -157,7 +170,9 @@ void DownloadShelfGtk::RemoveDownloadItem(DownloadItemGtk* download_item) { delete download_item; if (download_items_.empty()) { slide_widget_->CloseWithoutAnimation(); - tab_contents_->SetDownloadShelfVisible(false); + + // TODO(estade): Remove. The status bubble should query its window instead. + browser_->UpdateDownloadShelfVisibility(false); } } @@ -166,15 +181,14 @@ GtkWidget* DownloadShelfGtk::GetRightBoundingWidget() const { } GtkWidget* DownloadShelfGtk::GetHBox() const { - return hbox_; + return hbox_.get(); } // static void DownloadShelfGtk::OnButtonClick(GtkWidget* button, DownloadShelfGtk* shelf) { if (button == shelf->close_button_->widget()) { - shelf->slide_widget_->Close(); - shelf->tab_contents_->SetDownloadShelfVisible(false); + shelf->Close(); } else { // The link button was clicked. shelf->ShowAllDownloads(); diff --git a/chrome/browser/gtk/download_shelf_gtk.h b/chrome/browser/gtk/download_shelf_gtk.h index 4ed81b7..afafd27 100644 --- a/chrome/browser/gtk/download_shelf_gtk.h +++ b/chrome/browser/gtk/download_shelf_gtk.h @@ -9,18 +9,20 @@ #include <vector> +#include "base/gfx/native_widget_types.h" #include "base/scoped_ptr.h" #include "chrome/browser/download/download_shelf.h" #include "chrome/common/owned_widget_gtk.h" class BaseDownloadItemModel; +class Browser; class CustomDrawButton; class DownloadItemGtk; class SlideAnimatorGtk; class DownloadShelfGtk : public DownloadShelf { public: - explicit DownloadShelfGtk(TabContents* tab_contents); + explicit DownloadShelfGtk(Browser* browser, gfx::NativeView view); ~DownloadShelfGtk(); @@ -28,6 +30,11 @@ class DownloadShelfGtk : public DownloadShelf { virtual void AddDownload(BaseDownloadItemModel* download_model); virtual bool IsShowing() const; virtual bool IsClosing() const; + virtual void Show(); + virtual void Close(); + + // Returns the current height of the shelf. + int GetHeight() const; private: // Remove |download_item| from the download shelf and delete it. @@ -45,7 +52,7 @@ class DownloadShelfGtk : public DownloadShelf { scoped_ptr<SlideAnimatorGtk> slide_widget_; // |hbox_| holds the download items and buttons of the shelf. - GtkWidget* hbox_; + OwnedWidgetGtk hbox_; // |shelf_| is the second highest level widget. See the constructor // for an explanation of the widget layout. diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc index c2a3be6..87920c3 100644 --- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc @@ -91,9 +91,6 @@ TabRendererGtk::TabImage TabRendererGtk::tab_alpha = {0}; TabRendererGtk::TabImage TabRendererGtk::tab_hover_ = {0}; gfx::Font* TabRendererGtk::title_font_ = NULL; int TabRendererGtk::title_font_height_ = 0; -SkBitmap* TabRendererGtk::download_icon_ = NULL; -int TabRendererGtk::download_icon_width_ = 0; -int TabRendererGtk::download_icon_height_ = 0; int TabRendererGtk::close_button_width_ = 0; int TabRendererGtk::close_button_height_ = 0; @@ -173,7 +170,6 @@ class TabRendererGtk::FavIconCrashAnimation : public Animation, TabRendererGtk::TabRendererGtk() : showing_icon_(false), - showing_download_icon_(false), showing_close_button_(false), fav_icon_hiding_offset_(0), should_display_crashed_favicon_(false), @@ -200,7 +196,6 @@ void TabRendererGtk::UpdateData(TabContents* contents, bool loading_only) { if (!loading_only) { data_.title = UTF16ToWideHack(contents->GetTitle()); data_.off_the_record = contents->profile()->IsOffTheRecord(); - data_.show_download_icon = contents->IsDownloadShelfVisible(); data_.crashed = contents->is_crashed(); data_.favicon = contents->GetFavIcon(); } @@ -303,10 +298,6 @@ void TabRendererGtk::LoadTabImages() { close_button_width_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->width(); close_button_height_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->height(); - - download_icon_ = rb.GetBitmapNamed(IDR_DOWNLOAD_ICON); - download_icon_width_ = download_icon_->width(); - download_icon_height_ = download_icon_->height(); } void TabRendererGtk::SetBounds(const gfx::Rect& bounds) { @@ -378,10 +369,8 @@ void TabRendererGtk::Paint(gfx::Canvas* canvas) { // See if the model changes whether the icons should be painted. const bool show_icon = ShouldShowIcon(); - const bool show_download_icon = data_.show_download_icon; const bool show_close_button = ShouldShowCloseBox(); if (show_icon != showing_icon_ || - show_download_icon != showing_download_icon_ || show_close_button != showing_close_button_) Layout(); @@ -418,11 +407,6 @@ void TabRendererGtk::Paint(gfx::Canvas* canvas) { } } - if (show_download_icon) { - canvas->DrawBitmapInt(*download_icon_, - download_icon_bounds_.x(), download_icon_bounds_.y()); - } - // Paint the Title. std::wstring title = data_.title; if (title.empty()) { @@ -475,15 +459,6 @@ void TabRendererGtk::Layout() { favicon_bounds_.SetRect(local_bounds.x(), local_bounds.y(), 0, 0); } - // Size the download icon. - showing_download_icon_ = data_.show_download_icon; - if (showing_download_icon_) { - int icon_top = kTopPadding + (content_height - download_icon_height_) / 2; - download_icon_bounds_.SetRect(local_bounds.width() - download_icon_width_, - icon_top, download_icon_width_, - download_icon_height_); - } - // Size the Close button. showing_close_button_ = ShouldShowCloseBox(); if (showing_close_button_) { @@ -518,8 +493,6 @@ void TabRendererGtk::Layout() { } else { title_width = std::max(local_bounds.width() - title_left, 0); } - if (data_.show_download_icon) - title_width = std::max(title_width - download_icon_width_, 0); title_bounds_.SetRect(title_left, title_top, title_width, title_font_height_); // TODO(jhawkins): Handle RTL layout. diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.h b/chrome/browser/gtk/tabs/tab_renderer_gtk.h index 4f555a1..990081f 100644 --- a/chrome/browser/gtk/tabs/tab_renderer_gtk.h +++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.h @@ -161,7 +161,6 @@ class TabRendererGtk : public AnimationDelegate { bool crashed; bool off_the_record; bool show_icon; - bool show_download_icon; }; // TODO(jhawkins): Move into TabResources class. @@ -238,7 +237,6 @@ class TabRendererGtk : public AnimationDelegate { // The bounds of various sections of the display. gfx::Rect favicon_bounds_; - gfx::Rect download_icon_bounds_; gfx::Rect title_bounds_; gfx::Rect close_button_bounds_; @@ -252,10 +250,6 @@ class TabRendererGtk : public AnimationDelegate { static gfx::Font* title_font_; static int title_font_height_; - static SkBitmap* download_icon_; - static int download_icon_width_; - static int download_icon_height_; - static int close_button_width_; static int close_button_height_; @@ -266,9 +260,6 @@ class TabRendererGtk : public AnimationDelegate { // changes and layout appropriately. bool showing_icon_; - // Whether we are showing the download icon. Comes from the model. - bool showing_download_icon_; - // Whether we are showing the close button. It is cached so that we can // detect when it changes and layout appropriately. bool showing_close_button_; |