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

Unified Diff: chrome/browser/gtk/gtk_theme_provider.cc

Issue 160188: GTK Themes: A gtkrc file can now override our choice of frame color by (Closed)
Patch Set: Make 257 a constant 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/gfx/gtk_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/gtk_theme_provider.cc
diff --git a/chrome/browser/gtk/gtk_theme_provider.cc b/chrome/browser/gtk/gtk_theme_provider.cc
index 45ec5940077cbffbb9e75c2802c8137099c0d95d..a9e331b43dc82cc592f69c22438526a6008c61cf 100644
--- a/chrome/browser/gtk/gtk_theme_provider.cc
+++ b/chrome/browser/gtk/gtk_theme_provider.cc
@@ -28,6 +28,8 @@ const int kToolbarImageHeight = 128;
const skia::HSL kExactColor = { -1, -1, -1 };
+const skia::HSL kDefaultFrameShift = { -1, -1, 0.4 };
+
} // namespace
// static
@@ -171,7 +173,50 @@ void GtkThemeProvider::LoadGtkValues() {
GtkStyle* window_style = gtk_rc_get_style(fake_window_);
GtkStyle* label_style = gtk_rc_get_style(fake_label_.get());
- SetThemeColorFromGtk(kColorFrame, &window_style->bg[GTK_STATE_SELECTED]);
+ GdkColor frame_color = window_style->bg[GTK_STATE_SELECTED];
+ GdkColor inactive_frame_color = window_style->bg[GTK_STATE_INSENSITIVE];
+ GdkColor button_color = window_style->bg[GTK_STATE_SELECTED];
+
+ GtkSettings* settings = gtk_settings_get_default();
+ bool theme_has_frame_color = false;
+ if (settings) {
+ GHashTable* color_scheme = NULL;
+ g_object_get(settings, "color-hash", &color_scheme, NULL);
+
+ if (color_scheme) {
+ // If we have a "gtk-color-scheme" set in this theme, mine it for hints
+ // about what we should actually set the frame color to.
+ GdkColor* color = NULL;
+ if ((color = static_cast<GdkColor*>(
+ g_hash_table_lookup(color_scheme, "frame_color")))) {
+ frame_color = *color;
+ theme_has_frame_color = true;
+ }
+
+ if ((color = static_cast<GdkColor*>(
+ g_hash_table_lookup(color_scheme, "inactive_frame_color")))) {
+ inactive_frame_color = *color;
+ }
+ }
+ }
+
+ if (!theme_has_frame_color) {
+ // If the theme's gtkrc doesn't explicitly tell us to use a specific frame
+ // color, change the luminosity of the frame color downwards to 80% of what
+ // it currently is. This is in a futile attempt to match the default
+ // metacity and xfwm themes.
+ SkColor shifted =
+ skia::HSLShift(SkColorSetRGB((frame_color.red >> 8),
+ (frame_color.green >> 8),
+ (frame_color.blue >> 8)),
+ kDefaultFrameShift);
+ frame_color.pixel = 0;
+ frame_color.red = SkColorGetR(shifted) * kSkiaToGDKMultiplier;
+ frame_color.green = SkColorGetG(shifted) * kSkiaToGDKMultiplier;
+ frame_color.blue = SkColorGetB(shifted) * kSkiaToGDKMultiplier;
+ }
+
+ SetThemeColorFromGtk(kColorFrame, &frame_color);
// Skip COLOR_FRAME_INACTIVE and the incognito colors, as they will be
// autogenerated from tints.
SetThemeColorFromGtk(kColorToolbar,
@@ -187,27 +232,24 @@ void GtkThemeProvider::LoadGtkValues() {
SetThemeColorFromGtk(kColorButtonBackground,
&window_style->bg[GTK_STATE_NORMAL]);
- SetThemeTintFromGtk(kTintButtons, &window_style->bg[GTK_STATE_SELECTED],
+ SetThemeTintFromGtk(kTintButtons, &button_color,
kDefaultTintButtons);
- SetThemeTintFromGtk(kTintFrame, &window_style->bg[GTK_STATE_SELECTED],
+ SetThemeTintFromGtk(kTintFrame, &frame_color,
kDefaultTintFrame);
SetThemeTintFromGtk(kTintFrameIncognito,
- &window_style->bg[GTK_STATE_SELECTED],
+ &frame_color,
kDefaultTintFrameIncognito);
SetThemeTintFromGtk(kTintBackgroundTab,
- &window_style->bg[GTK_STATE_SELECTED],
+ &frame_color,
kDefaultTintBackgroundTab);
// The inactive color/tint is special: We *must* use the exact insensitive
// color for all inactive windows, otherwise we end up neon pink half the
// time.
- SetThemeColorFromGtk(kColorFrameInactive,
- &window_style->bg[GTK_STATE_INSENSITIVE]);
- SetThemeTintFromGtk(kTintFrameInactive,
- &window_style->bg[GTK_STATE_INSENSITIVE],
+ SetThemeColorFromGtk(kColorFrameInactive, &inactive_frame_color);
+ SetThemeTintFromGtk(kTintFrameInactive, &inactive_frame_color,
kExactColor);
- SetThemeTintFromGtk(kTintFrameIncognitoInactive,
- &window_style->bg[GTK_STATE_INSENSITIVE],
+ SetThemeTintFromGtk(kTintFrameIncognitoInactive, &inactive_frame_color,
kExactColor);
GenerateFrameColors();
« no previous file with comments | « base/gfx/gtk_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698