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

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

Issue 3304015: Use PrefChangeRegistrar everywhere (Closed)
Patch Set: final version for commit Created 10 years, 2 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
« no previous file with comments | « chrome/browser/gtk/gtk_theme_provider.h ('k') | chrome/browser/gtk/options/general_page_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <set> 9 #include <set>
10 10
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 // Only realized widgets receive style-set notifications, which we need to 251 // Only realized widgets receive style-set notifications, which we need to
252 // broadcast new theme images and colors. Only realized widgets have style 252 // broadcast new theme images and colors. Only realized widgets have style
253 // properties, too, which we query for some colors. 253 // properties, too, which we query for some colors.
254 gtk_widget_realize(fake_frame_); 254 gtk_widget_realize(fake_frame_);
255 gtk_widget_realize(fake_window_); 255 gtk_widget_realize(fake_window_);
256 signals_->Connect(fake_frame_, "style-set", 256 signals_->Connect(fake_frame_, "style-set",
257 G_CALLBACK(&OnStyleSetThunk), this); 257 G_CALLBACK(&OnStyleSetThunk), this);
258 } 258 }
259 259
260 GtkThemeProvider::~GtkThemeProvider() { 260 GtkThemeProvider::~GtkThemeProvider() {
261 profile()->GetPrefs()->RemovePrefObserver(prefs::kUsesSystemTheme, this);
262 gtk_widget_destroy(fake_window_); 261 gtk_widget_destroy(fake_window_);
263 gtk_widget_destroy(fake_frame_); 262 gtk_widget_destroy(fake_frame_);
264 fake_label_.Destroy(); 263 fake_label_.Destroy();
265 fake_entry_.Destroy(); 264 fake_entry_.Destroy();
266 fake_menu_item_.Destroy(); 265 fake_menu_item_.Destroy();
267 266
268 FreeIconSets(); 267 FreeIconSets();
269 268
270 // We have to call this because FreePlatformCached() in ~BrowserThemeProvider 269 // We have to call this because FreePlatformCached() in ~BrowserThemeProvider
271 // doesn't call the right virutal FreePlatformCaches. 270 // doesn't call the right virutal FreePlatformCaches.
272 FreePlatformCaches(); 271 FreePlatformCaches();
273 } 272 }
274 273
275 void GtkThemeProvider::Init(Profile* profile) { 274 void GtkThemeProvider::Init(Profile* profile) {
276 profile->GetPrefs()->AddPrefObserver(prefs::kUsesSystemTheme, this); 275 registrar_.Init(profile->GetPrefs());
276 registrar_.Add(prefs::kUsesSystemTheme, this);
277 use_gtk_ = profile->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); 277 use_gtk_ = profile->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme);
278 278
279 BrowserThemeProvider::Init(profile); 279 BrowserThemeProvider::Init(profile);
280 } 280 }
281 281
282 SkBitmap* GtkThemeProvider::GetBitmapNamed(int id) const { 282 SkBitmap* GtkThemeProvider::GetBitmapNamed(int id) const {
283 // Try to get our cached version: 283 // Try to get our cached version:
284 ImageCache::const_iterator it = gtk_images_.find(id); 284 ImageCache::const_iterator it = gtk_images_.find(id);
285 if (it != gtk_images_.end()) 285 if (it != gtk_images_.end())
286 return it->second; 286 return it->second;
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 cairo_set_line_width(cr, 1.0); 1047 cairo_set_line_width(cr, 1.0);
1048 cairo_move_to(cr, start_x, widget->allocation.y); 1048 cairo_move_to(cr, start_x, widget->allocation.y);
1049 cairo_line_to(cr, start_x, 1049 cairo_line_to(cr, start_x,
1050 widget->allocation.y + widget->allocation.height); 1050 widget->allocation.y + widget->allocation.height);
1051 cairo_stroke(cr); 1051 cairo_stroke(cr);
1052 cairo_destroy(cr); 1052 cairo_destroy(cr);
1053 cairo_pattern_destroy(pattern); 1053 cairo_pattern_destroy(pattern);
1054 1054
1055 return TRUE; 1055 return TRUE;
1056 } 1056 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/gtk_theme_provider.h ('k') | chrome/browser/gtk/options/general_page_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698