| 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 #include "chrome/browser/ui/gtk/gtk_theme_provider.h" | 5 #include "chrome/browser/ui/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 |
| 11 #include "app/gtk_signal_registrar.h" | |
| 12 #include "app/resource_bundle.h" | 11 #include "app/resource_bundle.h" |
| 13 #include "base/environment.h" | 12 #include "base/environment.h" |
| 14 #include "base/nix/xdg_util.h" | 13 #include "base/nix/xdg_util.h" |
| 15 #include "base/stl_util-inl.h" | 14 #include "base/stl_util-inl.h" |
| 16 #include "chrome/browser/metrics/user_metrics.h" | 15 #include "chrome/browser/metrics/user_metrics.h" |
| 17 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/gtk/cairo_cached_surface.h" | 18 #include "chrome/browser/ui/gtk/cairo_cached_surface.h" |
| 20 #include "chrome/browser/ui/gtk/chrome_gtk_frame.h" | 19 #include "chrome/browser/ui/gtk/chrome_gtk_frame.h" |
| 21 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" | 20 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" |
| 22 #include "chrome/browser/ui/gtk/gtk_util.h" | 21 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 23 #include "chrome/browser/ui/gtk/hover_controller_gtk.h" | 22 #include "chrome/browser/ui/gtk/hover_controller_gtk.h" |
| 24 #include "chrome/common/notification_details.h" | 23 #include "chrome/common/notification_details.h" |
| 25 #include "chrome/common/notification_service.h" | 24 #include "chrome/common/notification_service.h" |
| 26 #include "chrome/common/notification_source.h" | 25 #include "chrome/common/notification_source.h" |
| 27 #include "chrome/common/notification_type.h" | 26 #include "chrome/common/notification_type.h" |
| 28 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 29 #include "gfx/canvas_skia.h" | 28 #include "gfx/canvas_skia.h" |
| 30 #include "gfx/color_utils.h" | 29 #include "gfx/color_utils.h" |
| 31 #include "gfx/gtk_util.h" | 30 #include "gfx/gtk_util.h" |
| 32 #include "gfx/skbitmap_operations.h" | 31 #include "gfx/skbitmap_operations.h" |
| 33 #include "gfx/skia_util.h" | 32 #include "gfx/skia_util.h" |
| 34 #include "gfx/skia_utils_gtk.h" | 33 #include "gfx/skia_utils_gtk.h" |
| 35 #include "grit/app_resources.h" | 34 #include "grit/app_resources.h" |
| 36 #include "grit/theme_resources.h" | 35 #include "grit/theme_resources.h" |
| 37 #include "third_party/skia/include/core/SkBitmap.h" | 36 #include "third_party/skia/include/core/SkBitmap.h" |
| 38 #include "third_party/skia/include/core/SkCanvas.h" | 37 #include "third_party/skia/include/core/SkCanvas.h" |
| 39 #include "third_party/skia/include/core/SkColor.h" | 38 #include "third_party/skia/include/core/SkColor.h" |
| 40 #include "third_party/skia/include/core/SkShader.h" | 39 #include "third_party/skia/include/core/SkShader.h" |
| 40 #include "ui/base/gtk/gtk_signal_registrar.h" |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 // The size of the rendered toolbar image. | 44 // The size of the rendered toolbar image. |
| 45 const int kToolbarImageWidth = 64; | 45 const int kToolbarImageWidth = 64; |
| 46 const int kToolbarImageHeight = 128; | 46 const int kToolbarImageHeight = 128; |
| 47 | 47 |
| 48 // How much to tint the GTK+ color lighter at the top of the window. | 48 // How much to tint the GTK+ color lighter at the top of the window. |
| 49 const color_utils::HSL kGtkFrameShift = { -1, -1, 0.58 }; | 49 const color_utils::HSL kGtkFrameShift = { -1, -1, 0.58 }; |
| 50 | 50 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 246 |
| 247 // static | 247 // static |
| 248 GtkThemeProvider* GtkThemeProvider::GetFrom(Profile* profile) { | 248 GtkThemeProvider* GtkThemeProvider::GetFrom(Profile* profile) { |
| 249 return static_cast<GtkThemeProvider*>(profile->GetThemeProvider()); | 249 return static_cast<GtkThemeProvider*>(profile->GetThemeProvider()); |
| 250 } | 250 } |
| 251 | 251 |
| 252 GtkThemeProvider::GtkThemeProvider() | 252 GtkThemeProvider::GtkThemeProvider() |
| 253 : BrowserThemeProvider(), | 253 : BrowserThemeProvider(), |
| 254 fake_window_(gtk_window_new(GTK_WINDOW_TOPLEVEL)), | 254 fake_window_(gtk_window_new(GTK_WINDOW_TOPLEVEL)), |
| 255 fake_frame_(chrome_gtk_frame_new()), | 255 fake_frame_(chrome_gtk_frame_new()), |
| 256 signals_(new GtkSignalRegistrar), | 256 signals_(new ui::GtkSignalRegistrar), |
| 257 fullscreen_icon_set_(NULL) { | 257 fullscreen_icon_set_(NULL) { |
| 258 fake_label_.Own(gtk_label_new("")); | 258 fake_label_.Own(gtk_label_new("")); |
| 259 fake_entry_.Own(gtk_entry_new()); | 259 fake_entry_.Own(gtk_entry_new()); |
| 260 fake_menu_item_.Own(gtk_menu_item_new()); | 260 fake_menu_item_.Own(gtk_menu_item_new()); |
| 261 | 261 |
| 262 // Only realized widgets receive style-set notifications, which we need to | 262 // Only realized widgets receive style-set notifications, which we need to |
| 263 // broadcast new theme images and colors. Only realized widgets have style | 263 // broadcast new theme images and colors. Only realized widgets have style |
| 264 // properties, too, which we query for some colors. | 264 // properties, too, which we query for some colors. |
| 265 gtk_widget_realize(fake_frame_); | 265 gtk_widget_realize(fake_frame_); |
| 266 gtk_widget_realize(fake_window_); | 266 gtk_widget_realize(fake_window_); |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 cairo_set_line_width(cr, 1.0); | 1123 cairo_set_line_width(cr, 1.0); |
| 1124 cairo_move_to(cr, start_x, widget->allocation.y); | 1124 cairo_move_to(cr, start_x, widget->allocation.y); |
| 1125 cairo_line_to(cr, start_x, | 1125 cairo_line_to(cr, start_x, |
| 1126 widget->allocation.y + widget->allocation.height); | 1126 widget->allocation.y + widget->allocation.height); |
| 1127 cairo_stroke(cr); | 1127 cairo_stroke(cr); |
| 1128 cairo_destroy(cr); | 1128 cairo_destroy(cr); |
| 1129 cairo_pattern_destroy(pattern); | 1129 cairo_pattern_destroy(pattern); |
| 1130 | 1130 |
| 1131 return TRUE; | 1131 return TRUE; |
| 1132 } | 1132 } |
| OLD | NEW |