OLD | NEW |
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_shelf_gtk.h" | 5 #include "chrome/browser/gtk/download_shelf_gtk.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/gfx/gtk_util.h" | 9 #include "base/gfx/gtk_util.h" |
10 #include "chrome/browser/download/download_item_model.h" | 10 #include "chrome/browser/download/download_item_model.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 // shelf. | 30 // shelf. |
31 const int kTopBottomPadding = 4; | 31 const int kTopBottomPadding = 4; |
32 | 32 |
33 // Padding between the left side of the shelf and the first download item. | 33 // Padding between the left side of the shelf and the first download item. |
34 const int kLeftPadding = 2; | 34 const int kLeftPadding = 2; |
35 | 35 |
36 // Padding between the right side of the shelf and the close button. | 36 // Padding between the right side of the shelf and the close button. |
37 const int kRightPadding = 10; | 37 const int kRightPadding = 10; |
38 | 38 |
39 // The background color of the shelf. | 39 // The background color of the shelf. |
40 static GdkColor kBackgroundColor = GDK_COLOR_RGB(230, 237, 244); | 40 const GdkColor kBackgroundColor = GDK_COLOR_RGB(230, 237, 244); |
41 | 41 |
42 // Border color (the top pixel of the shelf). | 42 // Border color (the top pixel of the shelf). |
43 static GdkColor kBorderColor = GDK_COLOR_RGB(214, 214, 214); | 43 const GdkColor kBorderColor = GDK_COLOR_RGB(214, 214, 214); |
44 | 44 |
45 // Speed of the shelf show/hide animation. | 45 // Speed of the shelf show/hide animation. |
46 static const int kShelfAnimationDurationMs = 120; | 46 const int kShelfAnimationDurationMs = 120; |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 // static | 50 // static |
51 DownloadShelf* DownloadShelf::Create(TabContents* tab_contents) { | 51 DownloadShelf* DownloadShelf::Create(TabContents* tab_contents) { |
52 return new DownloadShelfGtk(tab_contents); | 52 return new DownloadShelfGtk(tab_contents); |
53 } | 53 } |
54 | 54 |
55 DownloadShelfGtk::DownloadShelfGtk(TabContents* tab_contents) | 55 DownloadShelfGtk::DownloadShelfGtk(TabContents* tab_contents) |
56 : DownloadShelf(tab_contents), | 56 : DownloadShelf(tab_contents), |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 link_hbox_ = gtk_hbox_new(FALSE, 5); | 110 link_hbox_ = gtk_hbox_new(FALSE, 5); |
111 gtk_box_pack_start(GTK_BOX(link_hbox_), download_image, FALSE, FALSE, 0); | 111 gtk_box_pack_start(GTK_BOX(link_hbox_), download_image, FALSE, FALSE, 0); |
112 gtk_box_pack_start(GTK_BOX(link_hbox_), link_button_->widget(), | 112 gtk_box_pack_start(GTK_BOX(link_hbox_), link_button_->widget(), |
113 FALSE, FALSE, 0); | 113 FALSE, FALSE, 0); |
114 gtk_box_pack_end(GTK_BOX(hbox_), link_hbox_, FALSE, FALSE, 0); | 114 gtk_box_pack_end(GTK_BOX(hbox_), link_hbox_, FALSE, FALSE, 0); |
115 | 115 |
116 slide_widget_.reset(new SlideAnimatorGtk(shelf_.get(), | 116 slide_widget_.reset(new SlideAnimatorGtk(shelf_.get(), |
117 SlideAnimatorGtk::UP, | 117 SlideAnimatorGtk::UP, |
118 kShelfAnimationDurationMs, | 118 kShelfAnimationDurationMs, |
119 false, NULL)); | 119 false, NULL)); |
| 120 gtk_widget_show_all(shelf_.get()); |
120 // Stick ourselves at the bottom of the parent tab contents. | 121 // Stick ourselves at the bottom of the parent tab contents. |
121 GtkWidget* parent_contents = tab_contents->GetNativeView(); | 122 GtkWidget* parent_contents = tab_contents->GetNativeView(); |
122 gtk_box_pack_end(GTK_BOX(parent_contents), slide_widget_->widget(), | 123 gtk_box_pack_end(GTK_BOX(parent_contents), slide_widget_->widget(), |
123 FALSE, FALSE, 0); | 124 FALSE, FALSE, 0); |
124 slide_widget_->Open(); | 125 slide_widget_->Open(); |
125 } | 126 } |
126 | 127 |
127 DownloadShelfGtk::~DownloadShelfGtk() { | 128 DownloadShelfGtk::~DownloadShelfGtk() { |
128 for (std::vector<DownloadItemGtk*>::iterator iter = download_items_.begin(); | 129 for (std::vector<DownloadItemGtk*>::iterator iter = download_items_.begin(); |
129 iter != download_items_.end(); ++iter) { | 130 iter != download_items_.end(); ++iter) { |
130 delete *iter; | 131 delete *iter; |
131 } | 132 } |
132 | 133 |
133 shelf_.Destroy(); | 134 shelf_.Destroy(); |
134 } | 135 } |
135 | 136 |
136 void DownloadShelfGtk::AddDownload(BaseDownloadItemModel* download_model_) { | 137 void DownloadShelfGtk::AddDownload(BaseDownloadItemModel* download_model_) { |
137 download_items_.push_back(new DownloadItemGtk(this, download_model_)); | 138 download_items_.push_back(new DownloadItemGtk(this, download_model_)); |
138 slide_widget_->Open(); | 139 slide_widget_->Open(); |
139 } | 140 } |
140 | 141 |
(...skipping 30 matching lines...) Expand all Loading... |
171 void DownloadShelfGtk::OnButtonClick(GtkWidget* button, | 172 void DownloadShelfGtk::OnButtonClick(GtkWidget* button, |
172 DownloadShelfGtk* shelf) { | 173 DownloadShelfGtk* shelf) { |
173 if (button == shelf->close_button_->widget()) { | 174 if (button == shelf->close_button_->widget()) { |
174 shelf->slide_widget_->Close(); | 175 shelf->slide_widget_->Close(); |
175 shelf->tab_contents_->SetDownloadShelfVisible(false); | 176 shelf->tab_contents_->SetDownloadShelfVisible(false); |
176 } else { | 177 } else { |
177 // The link button was clicked. | 178 // The link button was clicked. |
178 shelf->ShowAllDownloads(); | 179 shelf->ShowAllDownloads(); |
179 } | 180 } |
180 } | 181 } |
OLD | NEW |