diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-21 19:21:50 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-21 19:21:50 +0000 |
commit | 6ee6185045be58242771fe6e0504b4147e0c1a2d (patch) | |
tree | dafa4fb063382b5e20f37c67bdb1dfc29d545741 | |
parent | 355284254f9997a21409da26b58f25f34bfd5d64 (diff) | |
download | chromium_src-6ee6185045be58242771fe6e0504b4147e0c1a2d.zip chromium_src-6ee6185045be58242771fe6e0504b4147e0c1a2d.tar.gz chromium_src-6ee6185045be58242771fe6e0504b4147e0c1a2d.tar.bz2 |
GTK Themes: Get text color from a label object; this should fix some theme text problems.
GTK Themes can set colors on a per widget basis, and many do. Previously we were getting
the text color from a GtkWindow object, which sometimes is wrong--the theme just sets the
text color on labels...
Review URL: http://codereview.chromium.org/159143
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21200 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/gtk/gtk_theme_provider.cc | 36 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_theme_provider.h | 5 |
2 files changed, 23 insertions, 18 deletions
diff --git a/chrome/browser/gtk/gtk_theme_provider.cc b/chrome/browser/gtk/gtk_theme_provider.cc index f18ff3f..5f102e2 100644 --- a/chrome/browser/gtk/gtk_theme_provider.cc +++ b/chrome/browser/gtk/gtk_theme_provider.cc @@ -37,7 +37,8 @@ GtkThemeProvider* GtkThemeProvider::GetFrom(Profile* profile) { GtkThemeProvider::GtkThemeProvider() : BrowserThemeProvider(), - fake_window_(gtk_window_new(GTK_WINDOW_TOPLEVEL)) { + fake_window_(gtk_window_new(GTK_WINDOW_TOPLEVEL)), + fake_label_(gtk_label_new("")) { // Only realized widgets receive style-set notifications, which we need to // broadcast new theme images and colors. gtk_widget_realize(fake_window_); @@ -47,6 +48,7 @@ GtkThemeProvider::GtkThemeProvider() GtkThemeProvider::~GtkThemeProvider() { profile()->GetPrefs()->RemovePrefObserver(prefs::kUsesSystemTheme, this); gtk_widget_destroy(fake_window_); + gtk_widget_destroy(fake_label_); // Disconnect from the destroy signal of any redisual widgets in // |chrome_buttons_|. @@ -165,44 +167,46 @@ void GtkThemeProvider::OnStyleSet(GtkWidget* widget, } void GtkThemeProvider::LoadGtkValues() { - GtkStyle* style = gtk_rc_get_style(fake_window_); + GtkStyle* window_style = gtk_rc_get_style(fake_window_); + GtkStyle* label_style = gtk_rc_get_style(fake_label_); - SetThemeColorFromGtk(kColorFrame, &style->bg[GTK_STATE_SELECTED]); + SetThemeColorFromGtk(kColorFrame, &window_style->bg[GTK_STATE_SELECTED]); // Skip COLOR_FRAME_INACTIVE and the incognito colors, as they will be // autogenerated from tints. SetThemeColorFromGtk(kColorToolbar, - &style->bg[GTK_STATE_NORMAL]); + &window_style->bg[GTK_STATE_NORMAL]); SetThemeColorFromGtk(kColorTabText, - &style->text[GTK_STATE_NORMAL]); + &label_style->text[GTK_STATE_NORMAL]); SetThemeColorFromGtk(kColorBackgroundTabText, - &style->text[GTK_STATE_NORMAL]); + &label_style->text[GTK_STATE_NORMAL]); SetThemeColorFromGtk(kColorBookmarkText, - &style->text[GTK_STATE_NORMAL]); + &label_style->text[GTK_STATE_NORMAL]); SetThemeColorFromGtk(kColorControlBackground, - &style->bg[GTK_STATE_NORMAL]); + &window_style->bg[GTK_STATE_NORMAL]); SetThemeColorFromGtk(kColorButtonBackground, - &style->bg[GTK_STATE_NORMAL]); + &window_style->bg[GTK_STATE_NORMAL]); - SetThemeTintFromGtk(kTintButtons, &style->bg[GTK_STATE_SELECTED], + SetThemeTintFromGtk(kTintButtons, &window_style->bg[GTK_STATE_SELECTED], kDefaultTintButtons); - SetThemeTintFromGtk(kTintFrame, &style->bg[GTK_STATE_SELECTED], + SetThemeTintFromGtk(kTintFrame, &window_style->bg[GTK_STATE_SELECTED], kDefaultTintFrame); SetThemeTintFromGtk(kTintFrameIncognito, - &style->bg[GTK_STATE_SELECTED], + &window_style->bg[GTK_STATE_SELECTED], kDefaultTintFrameIncognito); SetThemeTintFromGtk(kTintBackgroundTab, - &style->bg[GTK_STATE_SELECTED], + &window_style->bg[GTK_STATE_SELECTED], 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, &style->bg[GTK_STATE_INSENSITIVE]); + SetThemeColorFromGtk(kColorFrameInactive, + &window_style->bg[GTK_STATE_INSENSITIVE]); SetThemeTintFromGtk(kTintFrameInactive, - &style->bg[GTK_STATE_INSENSITIVE], + &window_style->bg[GTK_STATE_INSENSITIVE], kExactColor); SetThemeTintFromGtk(kTintFrameIncognitoInactive, - &style->bg[GTK_STATE_INSENSITIVE], + &window_style->bg[GTK_STATE_INSENSITIVE], kExactColor); GenerateFrameColors(); diff --git a/chrome/browser/gtk/gtk_theme_provider.h b/chrome/browser/gtk/gtk_theme_provider.h index ae3537e..424ba76 100644 --- a/chrome/browser/gtk/gtk_theme_provider.h +++ b/chrome/browser/gtk/gtk_theme_provider.h @@ -90,9 +90,10 @@ class GtkThemeProvider : public BrowserThemeProvider, // Whether we should be using gtk rendering. bool use_gtk_; - // A GtkWidget that exists only so we can look at its properties (and take - // its colors). + // GtkWidgets that exist only so we can look at their properties (and take + // their colors). GtkWidget* fake_window_; + GtkWidget* fake_label_; // A list of all GtkChromeButton instances. We hold on to these to notify // them of theme changes. |