summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/status_bubble_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/status_bubble_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/status_bubble_gtk.cc')
-rw-r--r--chrome/browser/gtk/status_bubble_gtk.cc26
1 files changed, 19 insertions, 7 deletions
diff --git a/chrome/browser/gtk/status_bubble_gtk.cc b/chrome/browser/gtk/status_bubble_gtk.cc
index 920803e..70e2702 100644
--- a/chrome/browser/gtk/status_bubble_gtk.cc
+++ b/chrome/browser/gtk/status_bubble_gtk.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/browser/gtk/slide_animator_gtk.h"
#include "chrome/common/gtk_util.h"
+#include "chrome/common/notification_service.h"
#include "googleurl/src/gurl.h"
namespace {
@@ -33,11 +34,12 @@ static const int kHideDelay = 250;
} // namespace
StatusBubbleGtk::StatusBubbleGtk(Profile* profile)
- : timer_factory_(this) {
+ : theme_provider_(GtkThemeProvider::GetFrom(profile)),
+ timer_factory_(this) {
InitWidgets();
- GtkThemeProperties properties(profile);
- UserChangedTheme(&properties);
+ registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
+ NotificationService::AllSources());
}
StatusBubbleGtk::~StatusBubbleGtk() {
@@ -115,6 +117,14 @@ void StatusBubbleGtk::MouseMoved() {
// the way to hide the status bubble on mouseover.
}
+void StatusBubbleGtk::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ if (type == NotificationType::BROWSER_THEME_CHANGED) {
+ UserChangedTheme();
+ }
+}
+
void StatusBubbleGtk::InitWidgets() {
label_ = gtk_label_new(NULL);
@@ -131,10 +141,12 @@ void StatusBubbleGtk::InitWidgets() {
kBorderPadding, kBorderPadding, kBorderPadding, kBorderPadding));
gtk_widget_set_name(container_.get(), "status-bubble");
gtk_widget_set_app_paintable(container_.get(), TRUE);
+
+ UserChangedTheme();
}
-void StatusBubbleGtk::UserChangedTheme(GtkThemeProperties* properties) {
- if (properties->use_gtk_rendering) {
+void StatusBubbleGtk::UserChangedTheme() {
+ if (theme_provider_->UseGtkTheme()) {
gtk_widget_modify_fg(label_, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_bg(bg_box_, GTK_STATE_NORMAL, NULL);
} else {
@@ -142,11 +154,11 @@ void StatusBubbleGtk::UserChangedTheme(GtkThemeProperties* properties) {
// toolbar" that I can find. Maybe in later iterations of the theme system,
// there will be a better color to pick.
GdkColor bookmark_text =
- properties->GetGdkColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT);
+ theme_provider_->GetGdkColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT);
gtk_widget_modify_fg(label_, GTK_STATE_NORMAL, &bookmark_text);
GdkColor toolbar_color =
- properties->GetGdkColor(BrowserThemeProvider::COLOR_TOOLBAR);
+ theme_provider_->GetGdkColor(BrowserThemeProvider::COLOR_TOOLBAR);
gtk_widget_modify_bg(bg_box_, GTK_STATE_NORMAL, &toolbar_color);
}