summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/browser_toolbar_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/browser_toolbar_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/browser_toolbar_gtk.cc')
-rw-r--r--chrome/browser/gtk/browser_toolbar_gtk.cc29
1 files changed, 9 insertions, 20 deletions
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc
index 03639be..453fea6 100644
--- a/chrome/browser/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_toolbar_gtk.cc
@@ -94,6 +94,8 @@ void BrowserToolbarGtk::Init(Profile* profile,
// Make sure to tell the location bar the profile before calling its Init.
SetProfile(profile);
+ theme_provider_ = GtkThemeProvider::GetFrom(profile);
+
show_home_button_.Init(prefs::kShowHomeButton, profile->GetPrefs(), this);
event_box_ = gtk_event_box_new();
@@ -176,9 +178,6 @@ void BrowserToolbarGtk::Init(Profile* profile,
gtk_box_pack_start(GTK_BOX(toolbar_), menus_hbox_, FALSE, FALSE, 0);
- // Force all the CustomDrawButtons to load the correct rendering style.
- UserChangedTheme();
-
gtk_widget_show_all(event_box_);
if (show_home_button_.GetValue()) {
@@ -291,19 +290,6 @@ void BrowserToolbarGtk::UpdateTabContents(TabContents* contents,
location_bar_->Update(should_restore_state ? contents : NULL);
}
-void BrowserToolbarGtk::UserChangedTheme() {
- bool use_gtk = GtkThemeProvider::UseSystemThemeGraphics(profile_);
- back_->SetUseSystemTheme(use_gtk);
- forward_->SetUseSystemTheme(use_gtk);
- reload_->SetUseSystemTheme(use_gtk);
- home_->SetUseSystemTheme(use_gtk);
-
- gtk_chrome_button_set_use_gtk_rendering(
- GTK_CHROME_BUTTON(page_menu_button_.get()), use_gtk);
- gtk_chrome_button_set_use_gtk_rendering(
- GTK_CHROME_BUTTON(app_menu_button_.get()), use_gtk);
-}
-
gfx::Rect BrowserToolbarGtk::GetPopupBounds() const {
GtkWidget* star = star_->widget();
GtkWidget* go = go_->widget();
@@ -328,7 +314,8 @@ gfx::Rect BrowserToolbarGtk::GetPopupBounds() const {
CustomDrawButton* BrowserToolbarGtk::BuildToolbarButton(
int normal_id, int active_id, int highlight_id, int depressed_id,
const std::string& localized_tooltip, const char* stock_id) {
- CustomDrawButton* button = new CustomDrawButton(profile_->GetThemeProvider(),
+ CustomDrawButton* button = new CustomDrawButton(
+ GtkThemeProvider::GetFrom(profile_),
normal_id, active_id, highlight_id, depressed_id, stock_id);
gtk_widget_set_tooltip_text(button->widget(),
@@ -358,12 +345,14 @@ GtkWidget* BrowserToolbarGtk::BuildToolbarMenuButton(
int icon_id,
const std::string& localized_tooltip,
OwnedWidgetGtk* owner) {
- GtkWidget* button = gtk_chrome_button_new();
+ GtkWidget* button = theme_provider_->BuildChromeButton();
owner->Own(button);
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- if (!GtkThemeProvider::UseSystemThemeGraphics(profile_))
- gtk_container_set_border_width(GTK_CONTAINER(button), 2);
+ // TODO(erg): This was under conditional for gtk, but after playing around
+ // with not having it under conditional, I actually think this is correct
+ // instead. Investigate more later.
+ gtk_container_set_border_width(GTK_CONTAINER(button), 2);
gtk_container_add(GTK_CONTAINER(button),
gtk_image_new_from_pixbuf(rb.GetPixbufNamed(icon_id)));