Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_ | 6 #define CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 typedef struct _GdkDisplay GdkDisplay; | 28 typedef struct _GdkDisplay GdkDisplay; |
| 29 typedef struct _GdkEventExpose GdkEventExpose; | 29 typedef struct _GdkEventExpose GdkEventExpose; |
| 30 typedef struct _GdkPixbuf GdkPixbuf; | 30 typedef struct _GdkPixbuf GdkPixbuf; |
| 31 typedef struct _GtkIconSet GtkIconSet; | 31 typedef struct _GtkIconSet GtkIconSet; |
| 32 typedef struct _GtkStyle GtkStyle; | 32 typedef struct _GtkStyle GtkStyle; |
| 33 typedef struct _GtkWidget GtkWidget; | 33 typedef struct _GtkWidget GtkWidget; |
| 34 | 34 |
| 35 // Specialization of ThemeService which supplies system colors. | 35 // Specialization of ThemeService which supplies system colors. |
| 36 class GtkThemeService : public ThemeService { | 36 class GtkThemeService : public ThemeService { |
| 37 public: | 37 public: |
| 38 // A list of integer keys for a separate PerDisplaySurfaceMap that keeps | |
| 39 // what would otherwise be static icons on the X11 server. | |
| 40 enum CairoDefaultIcon { | |
| 41 NATIVE_FAVICON = 1, | |
| 42 CHROME_FAVICON, | |
| 43 NATIVE_FOLDER, | |
| 44 CHROME_FOLDER | |
| 45 }; | |
| 46 | |
| 38 // Returns GtkThemeService, casted from our superclass. | 47 // Returns GtkThemeService, casted from our superclass. |
| 39 static GtkThemeService* GetFrom(Profile* profile); | 48 static GtkThemeService* GetFrom(Profile* profile); |
| 40 | 49 |
| 41 GtkThemeService(); | 50 GtkThemeService(); |
| 42 virtual ~GtkThemeService(); | 51 virtual ~GtkThemeService(); |
| 43 | 52 |
| 44 // Calls |observer|.Observe() for the browser theme with this provider as the | 53 // Calls |observer|.Observe() for the browser theme with this provider as the |
| 45 // source. | 54 // source. |
| 46 void InitThemesFor(content::NotificationObserver* observer); | 55 void InitThemesFor(content::NotificationObserver* observer); |
| 47 | 56 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 GtkWidget* widget_on_display); | 122 GtkWidget* widget_on_display); |
| 114 | 123 |
| 115 // Same as above, but gets the resource from the ResourceBundle instead of the | 124 // Same as above, but gets the resource from the ResourceBundle instead of the |
| 116 // ThemeService. | 125 // ThemeService. |
| 117 // NOTE: Never call this with resource IDs that are ever passed to the above | 126 // NOTE: Never call this with resource IDs that are ever passed to the above |
| 118 // two functions! Depending on which call comes first, all callers will | 127 // two functions! Depending on which call comes first, all callers will |
| 119 // either get the themed or the unthemed version. | 128 // either get the themed or the unthemed version. |
| 120 CairoCachedSurface* GetUnthemedSurfaceNamed(int id, | 129 CairoCachedSurface* GetUnthemedSurfaceNamed(int id, |
| 121 GtkWidget* widget_on_display); | 130 GtkWidget* widget_on_display); |
| 122 | 131 |
| 132 // A way to get a cached cairo surface for the equivalent of GetFolderIcon() | |
| 133 // or GetDefaultFavicon(). Uses the ids defined in CairoDefaultIcon. | |
| 134 CairoCachedSurface* GetCairoIcon(int id, GtkWidget* widget_on_display); | |
| 135 | |
| 123 // Returns colors that we pass to webkit to match the system theme. | 136 // Returns colors that we pass to webkit to match the system theme. |
| 124 const SkColor& get_focus_ring_color() const { return focus_ring_color_; } | 137 const SkColor& get_focus_ring_color() const { return focus_ring_color_; } |
| 125 const SkColor& get_thumb_active_color() const { return thumb_active_color_; } | 138 const SkColor& get_thumb_active_color() const { return thumb_active_color_; } |
| 126 const SkColor& get_thumb_inactive_color() const { | 139 const SkColor& get_thumb_inactive_color() const { |
| 127 return thumb_inactive_color_; | 140 return thumb_inactive_color_; |
| 128 } | 141 } |
| 129 const SkColor& get_track_color() const { return track_color_; } | 142 const SkColor& get_track_color() const { return track_color_; } |
| 130 const SkColor& get_active_selection_bg_color() const { | 143 const SkColor& get_active_selection_bg_color() const { |
| 131 return active_selection_bg_color_; | 144 return active_selection_bg_color_; |
| 132 } | 145 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 149 // environment. Returns true when we GTK defaults to on. | 162 // environment. Returns true when we GTK defaults to on. |
| 150 static bool DefaultUsesSystemTheme(); | 163 static bool DefaultUsesSystemTheme(); |
| 151 | 164 |
| 152 private: | 165 private: |
| 153 typedef std::map<int, SkColor> ColorMap; | 166 typedef std::map<int, SkColor> ColorMap; |
| 154 typedef std::map<int, color_utils::HSL> TintMap; | 167 typedef std::map<int, color_utils::HSL> TintMap; |
| 155 typedef std::map<int, SkBitmap*> ImageCache; | 168 typedef std::map<int, SkBitmap*> ImageCache; |
| 156 typedef std::map<int, CairoCachedSurface*> CairoCachedSurfaceMap; | 169 typedef std::map<int, CairoCachedSurface*> CairoCachedSurfaceMap; |
| 157 typedef std::map<GdkDisplay*, CairoCachedSurfaceMap> PerDisplaySurfaceMap; | 170 typedef std::map<GdkDisplay*, CairoCachedSurfaceMap> PerDisplaySurfaceMap; |
| 158 | 171 |
| 172 typedef GdkPixbuf*(GtkThemeService::*PixbufProvidingMethod)(int id) const; | |
|
Evan Stade
2011/10/28 20:34:25
define type close to where it's used imo
| |
| 173 | |
| 159 // Clears all the GTK color overrides. | 174 // Clears all the GTK color overrides. |
| 160 virtual void ClearAllThemeData(); | 175 virtual void ClearAllThemeData(); |
| 161 | 176 |
| 162 // Load theme data from preferences, possibly picking colors from GTK. | 177 // Load theme data from preferences, possibly picking colors from GTK. |
| 163 virtual void LoadThemePrefs(); | 178 virtual void LoadThemePrefs(); |
| 164 | 179 |
| 165 // Let all the browser views know that themes have changed. | 180 // Let all the browser views know that themes have changed. |
| 166 virtual void NotifyThemeChanged(); | 181 virtual void NotifyThemeChanged(); |
| 167 | 182 |
| 168 // Additionally frees the CairoCachedSurfaces. | 183 // Additionally frees the CairoCachedSurfaces. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 void GetNormalButtonTintHSL(color_utils::HSL* tint) const; | 243 void GetNormalButtonTintHSL(color_utils::HSL* tint) const; |
| 229 | 244 |
| 230 // Returns a tint that's the color of the current normal text in an entry. | 245 // Returns a tint that's the color of the current normal text in an entry. |
| 231 void GetNormalEntryForegroundHSL(color_utils::HSL* tint) const; | 246 void GetNormalEntryForegroundHSL(color_utils::HSL* tint) const; |
| 232 | 247 |
| 233 // Returns a tint that's the color of the current highlighted text in an | 248 // Returns a tint that's the color of the current highlighted text in an |
| 234 // entry. | 249 // entry. |
| 235 void GetSelectedEntryForegroundHSL(color_utils::HSL* tint) const; | 250 void GetSelectedEntryForegroundHSL(color_utils::HSL* tint) const; |
| 236 | 251 |
| 237 // Implements GetXXXSurfaceNamed(), given the appropriate pixbuf to use. | 252 // Implements GetXXXSurfaceNamed(), given the appropriate pixbuf to use. |
| 238 CairoCachedSurface* GetSurfaceNamedImpl(int id, | 253 CairoCachedSurface* GetSurfaceNamedImpl( |
| 239 PerDisplaySurfaceMap* surface_map, | 254 int id, |
| 240 GdkPixbuf* pixbuf, | 255 PerDisplaySurfaceMap* surface_map, |
| 241 GtkWidget* widget_on_display); | 256 PixbufProvidingMethod provider, |
| 257 GtkWidget* widget_on_display); | |
| 258 | |
| 259 // PixbufProvidingMethods passed to GetSurfaceNamedImpl from GetSurface* | |
| 260 // methods. We don't want to always fetch the pixbuf and pass the pixbuf to | |
| 261 // GetSurfaceNamedImpl which will throw away the result most of the time. | |
| 262 // | |
| 263 // Especially since GetUnthemedNativePixbuf always locks and | |
| 264 // GetRTLEnabledPixbufNamedWrapper locks in debug builds. | |
| 265 GdkPixbuf* GetRTLEnabledPixbufNamedWrapper(int id) const; | |
| 266 GdkPixbuf* GetUnthemedNativePixbuf(int id) const; | |
| 267 GdkPixbuf* GetPixbufForIconId(int id) const; | |
| 242 | 268 |
| 243 // Handles signal from GTK that our theme has been changed. | 269 // Handles signal from GTK that our theme has been changed. |
| 244 CHROMEGTK_CALLBACK_1(GtkThemeService, void, OnStyleSet, GtkStyle*); | 270 CHROMEGTK_CALLBACK_1(GtkThemeService, void, OnStyleSet, GtkStyle*); |
| 245 | 271 |
| 246 // A notification from various GObject destructors that we should | 272 // A notification from various GObject destructors that we should |
| 247 // remove it from our internal list. | 273 // remove it from our internal list. |
| 248 CHROMEGTK_CALLBACK_0(GtkThemeService, void, OnDestroyChromeButton); | 274 CHROMEGTK_CALLBACK_0(GtkThemeService, void, OnDestroyChromeButton); |
| 249 CHROMEGTK_CALLBACK_0(GtkThemeService, void, OnDestroyChromeLinkButton); | 275 CHROMEGTK_CALLBACK_0(GtkThemeService, void, OnDestroyChromeLinkButton); |
| 250 CHROMEGTK_CALLBACK_0(GtkThemeService, void, OnDestroyLabel); | 276 CHROMEGTK_CALLBACK_0(GtkThemeService, void, OnDestroyLabel); |
| 251 | 277 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 // colors. | 325 // colors. |
| 300 GtkIconSet* fullscreen_icon_set_; | 326 GtkIconSet* fullscreen_icon_set_; |
| 301 | 327 |
| 302 // Image cache of lazily created images, created when requested by | 328 // Image cache of lazily created images, created when requested by |
| 303 // GetBitmapNamed(). | 329 // GetBitmapNamed(). |
| 304 mutable ImageCache gtk_images_; | 330 mutable ImageCache gtk_images_; |
| 305 | 331 |
| 306 // Cairo surfaces for each GdkDisplay. | 332 // Cairo surfaces for each GdkDisplay. |
| 307 PerDisplaySurfaceMap per_display_surfaces_; | 333 PerDisplaySurfaceMap per_display_surfaces_; |
| 308 PerDisplaySurfaceMap per_display_unthemed_surfaces_; | 334 PerDisplaySurfaceMap per_display_unthemed_surfaces_; |
| 335 PerDisplaySurfaceMap per_display_icon_surfaces_; | |
| 309 | 336 |
| 310 PrefChangeRegistrar registrar_; | 337 PrefChangeRegistrar registrar_; |
| 311 | 338 |
| 312 // This is a dummy widget that only exists so we have something to pass to | 339 // This is a dummy widget that only exists so we have something to pass to |
| 313 // gtk_widget_render_icon(). | 340 // gtk_widget_render_icon(). |
| 314 static GtkWidget* icon_widget_; | 341 static GtkWidget* icon_widget_; |
| 315 | 342 |
| 316 // The default folder icon and default bookmark icon for the GTK theme. | 343 // The default folder icon and default bookmark icon for the GTK theme. |
| 317 // These are static because the system can only have one theme at a time. | 344 // These are static because the system can only have one theme at a time. |
| 318 // They are cached when they are requested the first time, and cleared when | 345 // They are cached when they are requested the first time, and cleared when |
| 319 // the system theme changes. | 346 // the system theme changes. |
| 320 static GdkPixbuf* default_folder_icon_; | 347 static GdkPixbuf* default_folder_icon_; |
| 321 static GdkPixbuf* default_bookmark_icon_; | 348 static GdkPixbuf* default_bookmark_icon_; |
| 322 }; | 349 }; |
| 323 | 350 |
| 324 #endif // CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_ | 351 #endif // CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_ |
| OLD | NEW |