summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/download_shelf_gtk.cc
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-13 23:23:08 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-13 23:23:08 +0000
commit5fdafb2f68bd61ef92d10194402348d1e5839015 (patch)
treefb8583216c733e2a2218501646cf8c72fec35bb1 /chrome/browser/gtk/download_shelf_gtk.cc
parent0735266658f996210b6f43142ce7f4c55f47ae13 (diff)
downloadchromium_src-5fdafb2f68bd61ef92d10194402348d1e5839015.zip
chromium_src-5fdafb2f68bd61ef92d10194402348d1e5839015.tar.gz
chromium_src-5fdafb2f68bd61ef92d10194402348d1e5839015.tar.bz2
GTK Themes: Refactored to use notifications instead of manual plumbing.
- Removes large amounts of plumbing because: - All GtkChromeButtons are constructed from GtkThemeProvider which keeps a reference to all live buttons and sends them theme change notifications. - CustomDrawButtons now subscribe themselves to the BROWSER_THEME_CHANGED notification; this gets rid of a LOT of plubming. - Removes the GtkThemeProperties struct; just pass the theme provider around. - Move all the constants from the themes namespace to class statics, per tony's suggestion Review URL: http://codereview.chromium.org/149547 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20561 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/download_shelf_gtk.cc')
-rw-r--r--chrome/browser/gtk/download_shelf_gtk.cc28
1 files changed, 15 insertions, 13 deletions
diff --git a/chrome/browser/gtk/download_shelf_gtk.cc b/chrome/browser/gtk/download_shelf_gtk.cc
index a0f523c..4d165df 100644
--- a/chrome/browser/gtk/download_shelf_gtk.cc
+++ b/chrome/browser/gtk/download_shelf_gtk.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/gtk/slide_animator_gtk.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/gtk_util.h"
+#include "chrome/common/notification_service.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -49,7 +50,8 @@ const int kShelfAnimationDurationMs = 120;
DownloadShelfGtk::DownloadShelfGtk(Browser* browser, GtkWidget* parent)
: DownloadShelf(browser),
- is_showing_(false) {
+ is_showing_(false),
+ theme_provider_(GtkThemeProvider::GetFrom(browser->profile())) {
// 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
// the download items and other shelf widgets (close button, show-all-
@@ -118,8 +120,8 @@ DownloadShelfGtk::DownloadShelfGtk(Browser* browser, GtkWidget* parent)
kShelfAnimationDurationMs,
false, NULL));
- GtkThemeProperties properties(browser->profile());
- UserChangedTheme(&properties);
+ registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
+ NotificationService::AllSources());
gtk_widget_show_all(shelf_.get());
@@ -166,18 +168,18 @@ void DownloadShelfGtk::Close() {
browser_->UpdateDownloadShelfVisibility(false);
}
-int DownloadShelfGtk::GetHeight() const {
- return slide_widget_->widget()->allocation.height;
+void DownloadShelfGtk::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ if (type == NotificationType::BROWSER_THEME_CHANGED) {
+ GdkColor color = theme_provider_->GetGdkColor(
+ BrowserThemeProvider::COLOR_TOOLBAR);
+ gtk_widget_modify_bg(padding_bg_, GTK_STATE_NORMAL, &color);
+ }
}
-void DownloadShelfGtk::UserChangedTheme(GtkThemeProperties* properties) {
- GdkColor color = properties->GetGdkColor(BrowserThemeProvider::COLOR_TOOLBAR);
- gtk_widget_modify_bg(padding_bg_, GTK_STATE_NORMAL, &color);
-
- for (std::vector<DownloadItemGtk*>::iterator it = download_items_.begin();
- it != download_items_.end(); ++it) {
- (*it)->UserChangedTheme(properties);
- }
+int DownloadShelfGtk::GetHeight() const {
+ return slide_widget_->widget()->allocation.height;
}
void DownloadShelfGtk::RemoveDownloadItem(DownloadItemGtk* download_item) {