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-03 00:42:29 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-03 00:42:29 +0000
commita5166af69628552e4bcf746a38f3710cc895eac3 (patch)
tree0d6e0ab20143724111855ac501aad3fd469e6b8d /chrome/browser/gtk/browser_toolbar_gtk.cc
parent08f91cc8431cc6dea19e3c3ff3a229c71a7fc71f (diff)
downloadchromium_src-a5166af69628552e4bcf746a38f3710cc895eac3.zip
chromium_src-a5166af69628552e4bcf746a38f3710cc895eac3.tar.gz
chromium_src-a5166af69628552e4bcf746a38f3710cc895eac3.tar.bz2
GTK: Initial implementation of using GTK themes, partially based on evan's CL 118358.
A lot of stuff works: - Colors are picked out of the GTK theme. - Buttons use the current GTK button theme. - We use the user's icon theme. A lot of stuff doesn't: - We could do a better job of picking colors for the skylines. - The omnibox hasn't been touched. - UI that's not part of the toolbar hasn't been touched. - We currently fail on themes like HighContrastInverse. TEST=Under Options>Personal Stuff, click GTK Theme. Colors and widgets should be rendered with the current GTK theme stuff. TEST=With chrome open and in GTK Theme mode, change your GTK theme or icon theme. chrome should pick up on the change immediately and reimport the colors and images. http://crbug.com/13967 Review URL: http://codereview.chromium.org/150176 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19868 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/browser_toolbar_gtk.cc')
-rw-r--r--chrome/browser/gtk/browser_toolbar_gtk.cc30
1 files changed, 25 insertions, 5 deletions
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc
index d7fddfd..8340cef 100644
--- a/chrome/browser/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_toolbar_gtk.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/gtk/go_button_gtk.h"
#include "chrome/browser/gtk/gtk_chrome_button.h"
#include "chrome/browser/gtk/gtk_dnd_util.h"
+#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/browser/gtk/location_bar_view_gtk.h"
#include "chrome/browser/gtk/nine_box.h"
#include "chrome/browser/gtk/standard_menus.h"
@@ -124,10 +125,12 @@ void BrowserToolbarGtk::Init(Profile* profile,
gtk_box_pack_start(GTK_BOX(toolbar_), back_forward_hbox_, FALSE, FALSE, 0);
reload_.reset(BuildToolbarButton(IDR_RELOAD, IDR_RELOAD_P, IDR_RELOAD_H, 0,
- l10n_util::GetStringUTF8(IDS_TOOLTIP_RELOAD)));
+ l10n_util::GetStringUTF8(IDS_TOOLTIP_RELOAD),
+ GTK_STOCK_REFRESH));
home_.reset(BuildToolbarButton(IDR_HOME, IDR_HOME_P, IDR_HOME_H, 0,
- l10n_util::GetStringUTF8(IDS_TOOLTIP_HOME)));
+ l10n_util::GetStringUTF8(IDS_TOOLTIP_HOME),
+ GTK_STOCK_HOME));
gtk_util::SetButtonTriggersNavigation(home_->widget());
SetUpDragForHomeButton();
@@ -162,6 +165,9 @@ 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(toolbar_);
if (show_home_button_.GetValue()) {
@@ -274,6 +280,19 @@ 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();
@@ -297,9 +316,9 @@ 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 std::string& localized_tooltip, const char* stock_id) {
CustomDrawButton* button = new CustomDrawButton(normal_id, active_id,
- highlight_id, depressed_id);
+ highlight_id, depressed_id, stock_id);
gtk_widget_set_tooltip_text(button->widget(),
localized_tooltip.c_str());
@@ -332,7 +351,8 @@ GtkWidget* BrowserToolbarGtk::BuildToolbarMenuButton(
owner->Own(button);
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- gtk_container_set_border_width(GTK_CONTAINER(button), 2);
+ if (!GtkThemeProvider::UseSystemThemeGraphics(profile_))
+ gtk_container_set_border_width(GTK_CONTAINER(button), 2);
gtk_container_add(GTK_CONTAINER(button),
gtk_image_new_from_pixbuf(rb.GetPixbufNamed(icon_id)));