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

Side by Side Diff: chrome/browser/gtk/gtk_theme_provider.cc

Issue 159143: GTK Themes: Get text color from a label object; this should fix some theme text problems. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/gtk/gtk_theme_provider.h" 5 #include "chrome/browser/gtk/gtk_theme_provider.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "base/gfx/gtk_util.h" 9 #include "base/gfx/gtk_util.h"
10 #include "chrome/browser/metrics/user_metrics.h" 10 #include "chrome/browser/metrics/user_metrics.h"
(...skipping 19 matching lines...) Expand all
30 30
31 } // namespace 31 } // namespace
32 32
33 // static 33 // static
34 GtkThemeProvider* GtkThemeProvider::GetFrom(Profile* profile) { 34 GtkThemeProvider* GtkThemeProvider::GetFrom(Profile* profile) {
35 return static_cast<GtkThemeProvider*>(profile->GetThemeProvider()); 35 return static_cast<GtkThemeProvider*>(profile->GetThemeProvider());
36 } 36 }
37 37
38 GtkThemeProvider::GtkThemeProvider() 38 GtkThemeProvider::GtkThemeProvider()
39 : BrowserThemeProvider(), 39 : BrowserThemeProvider(),
40 fake_window_(gtk_window_new(GTK_WINDOW_TOPLEVEL)) { 40 fake_window_(gtk_window_new(GTK_WINDOW_TOPLEVEL)),
41 fake_label_(gtk_label_new("")) {
41 // Only realized widgets receive style-set notifications, which we need to 42 // Only realized widgets receive style-set notifications, which we need to
42 // broadcast new theme images and colors. 43 // broadcast new theme images and colors.
43 gtk_widget_realize(fake_window_); 44 gtk_widget_realize(fake_window_);
44 g_signal_connect(fake_window_, "style-set", G_CALLBACK(&OnStyleSet), this); 45 g_signal_connect(fake_window_, "style-set", G_CALLBACK(&OnStyleSet), this);
45 } 46 }
46 47
47 GtkThemeProvider::~GtkThemeProvider() { 48 GtkThemeProvider::~GtkThemeProvider() {
48 profile()->GetPrefs()->RemovePrefObserver(prefs::kUsesSystemTheme, this); 49 profile()->GetPrefs()->RemovePrefObserver(prefs::kUsesSystemTheme, this);
49 gtk_widget_destroy(fake_window_); 50 gtk_widget_destroy(fake_window_);
51 gtk_widget_destroy(fake_label_);
50 52
51 // Disconnect from the destroy signal of any redisual widgets in 53 // Disconnect from the destroy signal of any redisual widgets in
52 // |chrome_buttons_|. 54 // |chrome_buttons_|.
53 for (std::vector<GtkWidget*>::iterator it = chrome_buttons_.begin(); 55 for (std::vector<GtkWidget*>::iterator it = chrome_buttons_.begin();
54 it != chrome_buttons_.end(); ++it) { 56 it != chrome_buttons_.end(); ++it) {
55 gtk_signal_disconnect_by_data(GTK_OBJECT(*it), this); 57 gtk_signal_disconnect_by_data(GTK_OBJECT(*it), this);
56 } 58 }
57 } 59 }
58 60
59 void GtkThemeProvider::Init(Profile* profile) { 61 void GtkThemeProvider::Init(Profile* profile) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 GtkStyle* previous_style, 160 GtkStyle* previous_style,
159 GtkThemeProvider* provider) { 161 GtkThemeProvider* provider) {
160 if (provider->profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme)) { 162 if (provider->profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme)) {
161 provider->ClearAllThemeData(); 163 provider->ClearAllThemeData();
162 provider->LoadGtkValues(); 164 provider->LoadGtkValues();
163 provider->NotifyThemeChanged(); 165 provider->NotifyThemeChanged();
164 } 166 }
165 } 167 }
166 168
167 void GtkThemeProvider::LoadGtkValues() { 169 void GtkThemeProvider::LoadGtkValues() {
168 GtkStyle* style = gtk_rc_get_style(fake_window_); 170 GtkStyle* window_style = gtk_rc_get_style(fake_window_);
171 GtkStyle* label_style = gtk_rc_get_style(fake_label_);
169 172
170 SetThemeColorFromGtk(kColorFrame, &style->bg[GTK_STATE_SELECTED]); 173 SetThemeColorFromGtk(kColorFrame, &window_style->bg[GTK_STATE_SELECTED]);
171 // Skip COLOR_FRAME_INACTIVE and the incognito colors, as they will be 174 // Skip COLOR_FRAME_INACTIVE and the incognito colors, as they will be
172 // autogenerated from tints. 175 // autogenerated from tints.
173 SetThemeColorFromGtk(kColorToolbar, 176 SetThemeColorFromGtk(kColorToolbar,
174 &style->bg[GTK_STATE_NORMAL]); 177 &window_style->bg[GTK_STATE_NORMAL]);
175 SetThemeColorFromGtk(kColorTabText, 178 SetThemeColorFromGtk(kColorTabText,
176 &style->text[GTK_STATE_NORMAL]); 179 &label_style->text[GTK_STATE_NORMAL]);
177 SetThemeColorFromGtk(kColorBackgroundTabText, 180 SetThemeColorFromGtk(kColorBackgroundTabText,
Evan Stade 2009/07/21 19:12:19 shouldn't TabText and BackgroundTabText be differe
Elliot Glaysher 2009/07/21 19:21:36 They should, but that's a larger change then this.
178 &style->text[GTK_STATE_NORMAL]); 181 &label_style->text[GTK_STATE_NORMAL]);
179 SetThemeColorFromGtk(kColorBookmarkText, 182 SetThemeColorFromGtk(kColorBookmarkText,
180 &style->text[GTK_STATE_NORMAL]); 183 &label_style->text[GTK_STATE_NORMAL]);
181 SetThemeColorFromGtk(kColorControlBackground, 184 SetThemeColorFromGtk(kColorControlBackground,
182 &style->bg[GTK_STATE_NORMAL]); 185 &window_style->bg[GTK_STATE_NORMAL]);
183 SetThemeColorFromGtk(kColorButtonBackground, 186 SetThemeColorFromGtk(kColorButtonBackground,
184 &style->bg[GTK_STATE_NORMAL]); 187 &window_style->bg[GTK_STATE_NORMAL]);
185 188
186 SetThemeTintFromGtk(kTintButtons, &style->bg[GTK_STATE_SELECTED], 189 SetThemeTintFromGtk(kTintButtons, &window_style->bg[GTK_STATE_SELECTED],
187 kDefaultTintButtons); 190 kDefaultTintButtons);
188 SetThemeTintFromGtk(kTintFrame, &style->bg[GTK_STATE_SELECTED], 191 SetThemeTintFromGtk(kTintFrame, &window_style->bg[GTK_STATE_SELECTED],
189 kDefaultTintFrame); 192 kDefaultTintFrame);
190 SetThemeTintFromGtk(kTintFrameIncognito, 193 SetThemeTintFromGtk(kTintFrameIncognito,
191 &style->bg[GTK_STATE_SELECTED], 194 &window_style->bg[GTK_STATE_SELECTED],
192 kDefaultTintFrameIncognito); 195 kDefaultTintFrameIncognito);
193 SetThemeTintFromGtk(kTintBackgroundTab, 196 SetThemeTintFromGtk(kTintBackgroundTab,
194 &style->bg[GTK_STATE_SELECTED], 197 &window_style->bg[GTK_STATE_SELECTED],
195 kDefaultTintBackgroundTab); 198 kDefaultTintBackgroundTab);
196 199
197 // The inactive color/tint is special: We *must* use the exact insensitive 200 // The inactive color/tint is special: We *must* use the exact insensitive
198 // color for all inactive windows, otherwise we end up neon pink half the 201 // color for all inactive windows, otherwise we end up neon pink half the
199 // time. 202 // time.
200 SetThemeColorFromGtk(kColorFrameInactive, &style->bg[GTK_STATE_INSENSITIVE]); 203 SetThemeColorFromGtk(kColorFrameInactive,
204 &window_style->bg[GTK_STATE_INSENSITIVE]);
201 SetThemeTintFromGtk(kTintFrameInactive, 205 SetThemeTintFromGtk(kTintFrameInactive,
202 &style->bg[GTK_STATE_INSENSITIVE], 206 &window_style->bg[GTK_STATE_INSENSITIVE],
203 kExactColor); 207 kExactColor);
204 SetThemeTintFromGtk(kTintFrameIncognitoInactive, 208 SetThemeTintFromGtk(kTintFrameIncognitoInactive,
205 &style->bg[GTK_STATE_INSENSITIVE], 209 &window_style->bg[GTK_STATE_INSENSITIVE],
206 kExactColor); 210 kExactColor);
207 211
208 GenerateFrameColors(); 212 GenerateFrameColors();
209 GenerateFrameImages(); 213 GenerateFrameImages();
210 } 214 }
211 215
212 void GtkThemeProvider::SetThemeColorFromGtk(const char* id, GdkColor* color) { 216 void GtkThemeProvider::SetThemeColorFromGtk(const char* id, GdkColor* color) {
213 SetColor(id, SkColorSetRGB(color->red >> 8, 217 SetColor(id, SkColorSetRGB(color->red >> 8,
214 color->green >> 8, 218 color->green >> 8,
215 color->blue >> 8)); 219 color->blue >> 8));
(...skipping 14 matching lines...) Expand all
230 } 234 }
231 235
232 void GtkThemeProvider::OnDestroyChromeButton(GtkWidget* button, 236 void GtkThemeProvider::OnDestroyChromeButton(GtkWidget* button,
233 GtkThemeProvider* provider) { 237 GtkThemeProvider* provider) {
234 std::vector<GtkWidget*>::iterator it = 238 std::vector<GtkWidget*>::iterator it =
235 find(provider->chrome_buttons_.begin(), provider->chrome_buttons_.end(), 239 find(provider->chrome_buttons_.begin(), provider->chrome_buttons_.end(),
236 button); 240 button);
237 if (it != provider->chrome_buttons_.end()) 241 if (it != provider->chrome_buttons_.end())
238 provider->chrome_buttons_.erase(it); 242 provider->chrome_buttons_.erase(it);
239 } 243 }
OLDNEW
« chrome/browser/gtk/gtk_theme_provider.h ('K') | « chrome/browser/gtk/gtk_theme_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698