Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: chrome/browser/gtk/download_shelf_gtk.cc

Issue 155365: GTK Themes: Set bg/text colors for the download manager. (Closed)
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/gtk/download_shelf_gtk.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/browser.h" 10 #include "chrome/browser/browser.h"
11 #include "chrome/browser/download/download_item_model.h" 11 #include "chrome/browser/download/download_item_model.h"
12 #include "chrome/browser/download/download_util.h" 12 #include "chrome/browser/download/download_util.h"
13 #include "chrome/browser/gtk/browser_window_gtk.h" 13 #include "chrome/browser/gtk/browser_window_gtk.h"
14 #include "chrome/browser/gtk/custom_button.h" 14 #include "chrome/browser/gtk/custom_button.h"
15 #include "chrome/browser/gtk/download_item_gtk.h" 15 #include "chrome/browser/gtk/download_item_gtk.h"
16 #include "chrome/browser/gtk/gtk_chrome_link_button.h" 16 #include "chrome/browser/gtk/gtk_chrome_link_button.h"
17 #include "chrome/browser/gtk/gtk_theme_provider.h"
17 #include "chrome/browser/gtk/slide_animator_gtk.h" 18 #include "chrome/browser/gtk/slide_animator_gtk.h"
18 #include "chrome/browser/tab_contents/tab_contents.h" 19 #include "chrome/browser/tab_contents/tab_contents.h"
19 #include "chrome/common/gtk_util.h" 20 #include "chrome/common/gtk_util.h"
20 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
21 #include "grit/theme_resources.h" 22 #include "grit/theme_resources.h"
22 23
23 namespace { 24 namespace {
24 25
25 // The height of the download items. 26 // The height of the download items.
26 const int kDownloadItemHeight = download_util::kSmallProgressIconSize; 27 const int kDownloadItemHeight = download_util::kSmallProgressIconSize;
27 28
28 // Padding between the download widgets. 29 // Padding between the download widgets.
29 const int kDownloadItemPadding = 10; 30 const int kDownloadItemPadding = 10;
30 31
31 // Padding between the top/bottom of the download widgets and the edge of the 32 // Padding between the top/bottom of the download widgets and the edge of the
32 // shelf. 33 // shelf.
33 const int kTopBottomPadding = 4; 34 const int kTopBottomPadding = 4;
34 35
35 // Padding between the left side of the shelf and the first download item. 36 // Padding between the left side of the shelf and the first download item.
36 const int kLeftPadding = 2; 37 const int kLeftPadding = 2;
37 38
38 // Padding between the right side of the shelf and the close button. 39 // Padding between the right side of the shelf and the close button.
39 const int kRightPadding = 10; 40 const int kRightPadding = 10;
40 41
41 // The background color of the shelf.
42 const GdkColor kBackgroundColor = GDK_COLOR_RGB(230, 237, 244);
43
44 // Border color (the top pixel of the shelf). 42 // Border color (the top pixel of the shelf).
45 const GdkColor kBorderColor = GDK_COLOR_RGB(214, 214, 214); 43 const GdkColor kBorderColor = GDK_COLOR_RGB(214, 214, 214);
46 44
47 // Speed of the shelf show/hide animation. 45 // Speed of the shelf show/hide animation.
48 const int kShelfAnimationDurationMs = 120; 46 const int kShelfAnimationDurationMs = 120;
49 47
50 } // namespace 48 } // namespace
51 49
52 DownloadShelfGtk::DownloadShelfGtk(Browser* browser, GtkWidget* parent) 50 DownloadShelfGtk::DownloadShelfGtk(Browser* browser, GtkWidget* parent)
53 : DownloadShelf(browser), 51 : DownloadShelf(browser),
(...skipping 13 matching lines...) Expand all
67 65
68 // Create |hbox_|. 66 // Create |hbox_|.
69 hbox_.Own(gtk_hbox_new(FALSE, kDownloadItemPadding)); 67 hbox_.Own(gtk_hbox_new(FALSE, kDownloadItemPadding));
70 gtk_widget_set_size_request(hbox_.get(), -1, kDownloadItemHeight); 68 gtk_widget_set_size_request(hbox_.get(), -1, kDownloadItemHeight);
71 69
72 // Get the padding and background color for |hbox_| right. 70 // Get the padding and background color for |hbox_| right.
73 GtkWidget* padding = gtk_alignment_new(0, 0, 1, 1); 71 GtkWidget* padding = gtk_alignment_new(0, 0, 1, 1);
74 // Subtract 1 from top spacing to account for top border. 72 // Subtract 1 from top spacing to account for top border.
75 gtk_alignment_set_padding(GTK_ALIGNMENT(padding), 73 gtk_alignment_set_padding(GTK_ALIGNMENT(padding),
76 kTopBottomPadding - 1, kTopBottomPadding, kLeftPadding, kRightPadding); 74 kTopBottomPadding - 1, kTopBottomPadding, kLeftPadding, kRightPadding);
77 GtkWidget* padding_bg = gtk_event_box_new(); 75 padding_bg_ = gtk_event_box_new();
78 gtk_container_add(GTK_CONTAINER(padding_bg), padding); 76 gtk_container_add(GTK_CONTAINER(padding_bg_), padding);
79 gtk_container_add(GTK_CONTAINER(padding), hbox_.get()); 77 gtk_container_add(GTK_CONTAINER(padding), hbox_.get());
80 gtk_widget_modify_bg(padding_bg, GTK_STATE_NORMAL, &kBackgroundColor);
81 78
82 GtkWidget* vbox = gtk_vbox_new(FALSE, 0); 79 GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
83 gtk_box_pack_start(GTK_BOX(vbox), top_border, FALSE, FALSE, 0); 80 gtk_box_pack_start(GTK_BOX(vbox), top_border, FALSE, FALSE, 0);
84 gtk_box_pack_start(GTK_BOX(vbox), padding_bg, FALSE, FALSE, 0); 81 gtk_box_pack_start(GTK_BOX(vbox), padding_bg_, FALSE, FALSE, 0);
85 82
86 // Put the shelf in an event box so it gets its own window, which makes it 83 // Put the shelf in an event box so it gets its own window, which makes it
87 // easier to get z-ordering right. 84 // easier to get z-ordering right.
88 shelf_.Own(gtk_event_box_new()); 85 shelf_.Own(gtk_event_box_new());
89 gtk_container_add(GTK_CONTAINER(shelf_.get()), vbox); 86 gtk_container_add(GTK_CONTAINER(shelf_.get()), vbox);
90 87
91 // Create and pack the close button. 88 // Create and pack the close button.
92 close_button_.reset(CustomDrawButton::CloseButton()); 89 close_button_.reset(CustomDrawButton::CloseButton());
93 gtk_util::CenterWidgetInHBox(hbox_.get(), close_button_->widget(), true, 0); 90 gtk_util::CenterWidgetInHBox(hbox_.get(), close_button_->widget(), true, 0);
94 g_signal_connect(close_button_->widget(), "clicked", 91 g_signal_connect(close_button_->widget(), "clicked",
(...skipping 18 matching lines...) Expand all
113 // Pack the link and the icon in an hbox. 110 // Pack the link and the icon in an hbox.
114 link_hbox_ = gtk_hbox_new(FALSE, 5); 111 link_hbox_ = gtk_hbox_new(FALSE, 5);
115 gtk_util::CenterWidgetInHBox(link_hbox_, download_image, false, 0); 112 gtk_util::CenterWidgetInHBox(link_hbox_, download_image, false, 0);
116 gtk_util::CenterWidgetInHBox(link_hbox_, link_button, false, 0); 113 gtk_util::CenterWidgetInHBox(link_hbox_, link_button, false, 0);
117 gtk_box_pack_end(GTK_BOX(hbox_.get()), link_hbox_, FALSE, FALSE, 0); 114 gtk_box_pack_end(GTK_BOX(hbox_.get()), link_hbox_, FALSE, FALSE, 0);
118 115
119 slide_widget_.reset(new SlideAnimatorGtk(shelf_.get(), 116 slide_widget_.reset(new SlideAnimatorGtk(shelf_.get(),
120 SlideAnimatorGtk::UP, 117 SlideAnimatorGtk::UP,
121 kShelfAnimationDurationMs, 118 kShelfAnimationDurationMs,
122 false, NULL)); 119 false, NULL));
120
121 GtkThemeProperties properties(browser->profile());
122 UserChangedTheme(&properties);
123
123 gtk_widget_show_all(shelf_.get()); 124 gtk_widget_show_all(shelf_.get());
124 125
125 // Stick ourselves at the bottom of the parent browser. 126 // Stick ourselves at the bottom of the parent browser.
126 gtk_box_pack_end(GTK_BOX(parent), slide_widget_->widget(), 127 gtk_box_pack_end(GTK_BOX(parent), slide_widget_->widget(),
127 FALSE, FALSE, 0); 128 FALSE, FALSE, 0);
128 slide_widget_->Open(); 129 slide_widget_->Open();
129 } 130 }
130 131
131 DownloadShelfGtk::~DownloadShelfGtk() { 132 DownloadShelfGtk::~DownloadShelfGtk() {
132 for (std::vector<DownloadItemGtk*>::iterator iter = download_items_.begin(); 133 for (std::vector<DownloadItemGtk*>::iterator iter = download_items_.begin();
(...skipping 29 matching lines...) Expand all
162 slide_widget_->Close(); 163 slide_widget_->Close();
163 164
164 // TODO(estade): Remove. The status bubble should query its window instead. 165 // TODO(estade): Remove. The status bubble should query its window instead.
165 browser_->UpdateDownloadShelfVisibility(false); 166 browser_->UpdateDownloadShelfVisibility(false);
166 } 167 }
167 168
168 int DownloadShelfGtk::GetHeight() const { 169 int DownloadShelfGtk::GetHeight() const {
169 return slide_widget_->widget()->allocation.height; 170 return slide_widget_->widget()->allocation.height;
170 } 171 }
171 172
173 void DownloadShelfGtk::UserChangedTheme(GtkThemeProperties* properties) {
174 GdkColor color = properties->GetGdkColor(BrowserThemeProvider::COLOR_TOOLBAR);
175 gtk_widget_modify_bg(padding_bg_, GTK_STATE_NORMAL, &color);
176
177 for (std::vector<DownloadItemGtk*>::iterator it = download_items_.begin();
178 it != download_items_.end(); ++it) {
179 (*it)->UserChangedTheme(properties);
180 }
181 }
182
172 void DownloadShelfGtk::RemoveDownloadItem(DownloadItemGtk* download_item) { 183 void DownloadShelfGtk::RemoveDownloadItem(DownloadItemGtk* download_item) {
173 DCHECK(download_item); 184 DCHECK(download_item);
174 std::vector<DownloadItemGtk*>::iterator i = 185 std::vector<DownloadItemGtk*>::iterator i =
175 find(download_items_.begin(), download_items_.end(), download_item); 186 find(download_items_.begin(), download_items_.end(), download_item);
176 DCHECK(i != download_items_.end()); 187 DCHECK(i != download_items_.end());
177 download_items_.erase(i); 188 download_items_.erase(i);
178 delete download_item; 189 delete download_item;
179 if (download_items_.empty()) { 190 if (download_items_.empty()) {
180 slide_widget_->CloseWithoutAnimation(); 191 slide_widget_->CloseWithoutAnimation();
181 192
(...skipping 13 matching lines...) Expand all
195 // static 206 // static
196 void DownloadShelfGtk::OnButtonClick(GtkWidget* button, 207 void DownloadShelfGtk::OnButtonClick(GtkWidget* button,
197 DownloadShelfGtk* shelf) { 208 DownloadShelfGtk* shelf) {
198 if (button == shelf->close_button_->widget()) { 209 if (button == shelf->close_button_->widget()) {
199 shelf->Close(); 210 shelf->Close();
200 } else { 211 } else {
201 // The link button was clicked. 212 // The link button was clicked.
202 shelf->ShowAllDownloads(); 213 shelf->ShowAllDownloads();
203 } 214 }
204 } 215 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/download_shelf_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698