| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/libgtkui/native_theme_gtk3.h" | 5 #include "chrome/browser/ui/libgtkui/native_theme_gtk3.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "chrome/browser/ui/libgtkui/chrome_gtk_frame.h" | 9 #include "chrome/browser/ui/libgtkui/chrome_gtk_frame.h" |
| 10 #include "chrome/browser/ui/libgtkui/chrome_gtk_menu_subclasses.h" | 10 #include "chrome/browser/ui/libgtkui/chrome_gtk_menu_subclasses.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 const gchar* prop_name) { | 31 const gchar* prop_name) { |
| 32 GValue layout = G_VALUE_INIT; | 32 GValue layout = G_VALUE_INIT; |
| 33 g_value_init(&layout, G_TYPE_STRING); | 33 g_value_init(&layout, G_TYPE_STRING); |
| 34 g_object_get_property(G_OBJECT(settings), prop_name, &layout); | 34 g_object_get_property(G_OBJECT(settings), prop_name, &layout); |
| 35 DCHECK(G_VALUE_HOLDS_STRING(&layout)); | 35 DCHECK(G_VALUE_HOLDS_STRING(&layout)); |
| 36 std::string prop_value(g_value_get_string(&layout)); | 36 std::string prop_value(g_value_get_string(&layout)); |
| 37 g_value_unset(&layout); | 37 g_value_unset(&layout); |
| 38 return prop_value; | 38 return prop_value; |
| 39 } | 39 } |
| 40 | 40 |
| 41 ScopedStyleContext GetTooltipContext() { |
| 42 return AppendCssNodeToStyleContext( |
| 43 nullptr, GtkVersionCheck(3, 20) ? "#tooltip.background" |
| 44 : "GtkWindow#window.background.tooltip"); |
| 45 } |
| 46 |
| 41 SkBitmap GetWidgetBitmap(const gfx::Size& size, | 47 SkBitmap GetWidgetBitmap(const gfx::Size& size, |
| 42 GtkStyleContext* context, | 48 GtkStyleContext* context, |
| 43 BackgroundRenderMode bg_mode, | 49 BackgroundRenderMode bg_mode, |
| 44 bool render_frame) { | 50 bool render_frame) { |
| 45 DCHECK(bg_mode != BG_RENDER_NONE || render_frame); | 51 DCHECK(bg_mode != BG_RENDER_NONE || render_frame); |
| 46 SkBitmap bitmap; | 52 SkBitmap bitmap; |
| 47 bitmap.allocN32Pixels(size.width(), size.height()); | 53 bitmap.allocN32Pixels(size.width(), size.height()); |
| 48 bitmap.eraseColor(0); | 54 bitmap.eraseColor(0); |
| 49 | 55 |
| 50 CairoSurface surface(bitmap); | 56 CairoSurface surface(bitmap); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 return GetFgColor(GtkVersionCheck(3, 20) | 239 return GetFgColor(GtkVersionCheck(3, 20) |
| 234 ? "GtkTextView#textview.view #text #selection" | 240 ? "GtkTextView#textview.view #text #selection" |
| 235 : "GtkTextView.view:selected"); | 241 : "GtkTextView.view:selected"); |
| 236 case ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused: | 242 case ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused: |
| 237 return GetSelectionBgColor( | 243 return GetSelectionBgColor( |
| 238 GtkVersionCheck(3, 20) ? "GtkTextView#textview.view #text #selection" | 244 GtkVersionCheck(3, 20) ? "GtkTextView#textview.view #text #selection" |
| 239 : "GtkTextView.view:selected"); | 245 : "GtkTextView.view:selected"); |
| 240 | 246 |
| 241 // Tooltips | 247 // Tooltips |
| 242 case ui::NativeTheme::kColorId_TooltipBackground: | 248 case ui::NativeTheme::kColorId_TooltipBackground: |
| 243 return GetBgColor("GtkTooltip#tooltip"); | 249 return GetBgColorFromStyleContext(GetTooltipContext()); |
| 244 case ui::NativeTheme::kColorId_TooltipText: | 250 case ui::NativeTheme::kColorId_TooltipText: { |
| 245 return GetFgColor("GtkTooltip#tooltip GtkLabel"); | 251 auto context = GetTooltipContext(); |
| 252 context = AppendCssNodeToStyleContext(context, "GtkLabel"); |
| 253 return GetFgColorFromStyleContext(context); |
| 254 } |
| 246 | 255 |
| 247 // Trees and Tables (implemented on GTK using the same class) | 256 // Trees and Tables (implemented on GTK using the same class) |
| 248 case ui::NativeTheme::kColorId_TableBackground: | 257 case ui::NativeTheme::kColorId_TableBackground: |
| 249 case ui::NativeTheme::kColorId_TreeBackground: | 258 case ui::NativeTheme::kColorId_TreeBackground: |
| 250 return GetBgColor( | 259 return GetBgColor( |
| 251 "GtkTreeView#treeview.view GtkTreeView#treeview.view.cell"); | 260 "GtkTreeView#treeview.view GtkTreeView#treeview.view.cell"); |
| 252 case ui::NativeTheme::kColorId_TableText: | 261 case ui::NativeTheme::kColorId_TableText: |
| 253 case ui::NativeTheme::kColorId_TreeText: | 262 case ui::NativeTheme::kColorId_TreeText: |
| 254 case ui::NativeTheme::kColorId_TableGroupingIndicatorColor: | 263 case ui::NativeTheme::kColorId_TableGroupingIndicatorColor: |
| 255 return GetFgColor( | 264 return GetFgColor( |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 g_type_class_unref(g_type_class_ref(gtk_label_get_type())); | 408 g_type_class_unref(g_type_class_ref(gtk_label_get_type())); |
| 400 g_type_class_unref(g_type_class_ref(gtk_menu_get_type())); | 409 g_type_class_unref(g_type_class_ref(gtk_menu_get_type())); |
| 401 g_type_class_unref(g_type_class_ref(gtk_menu_bar_get_type())); | 410 g_type_class_unref(g_type_class_ref(gtk_menu_bar_get_type())); |
| 402 g_type_class_unref(g_type_class_ref(gtk_menu_item_get_type())); | 411 g_type_class_unref(g_type_class_ref(gtk_menu_item_get_type())); |
| 403 g_type_class_unref(g_type_class_ref(gtk_range_get_type())); | 412 g_type_class_unref(g_type_class_ref(gtk_range_get_type())); |
| 404 g_type_class_unref(g_type_class_ref(gtk_scrollbar_get_type())); | 413 g_type_class_unref(g_type_class_ref(gtk_scrollbar_get_type())); |
| 405 g_type_class_unref(g_type_class_ref(gtk_scrolled_window_get_type())); | 414 g_type_class_unref(g_type_class_ref(gtk_scrolled_window_get_type())); |
| 406 g_type_class_unref(g_type_class_ref(gtk_separator_get_type())); | 415 g_type_class_unref(g_type_class_ref(gtk_separator_get_type())); |
| 407 g_type_class_unref(g_type_class_ref(gtk_spinner_get_type())); | 416 g_type_class_unref(g_type_class_ref(gtk_spinner_get_type())); |
| 408 g_type_class_unref(g_type_class_ref(gtk_text_view_get_type())); | 417 g_type_class_unref(g_type_class_ref(gtk_text_view_get_type())); |
| 409 g_type_class_unref(g_type_class_ref(gtk_tooltip_get_type())); | |
| 410 g_type_class_unref(g_type_class_ref(gtk_tree_view_get_type())); | 418 g_type_class_unref(g_type_class_ref(gtk_tree_view_get_type())); |
| 411 g_type_class_unref(g_type_class_ref(gtk_window_get_type())); | 419 g_type_class_unref(g_type_class_ref(gtk_window_get_type())); |
| 412 | 420 |
| 413 g_signal_connect_after(gtk_settings_get_default(), "notify::gtk-theme-name", | 421 g_signal_connect_after(gtk_settings_get_default(), "notify::gtk-theme-name", |
| 414 G_CALLBACK(OnThemeChangedThunk), this); | 422 G_CALLBACK(OnThemeChangedThunk), this); |
| 415 OnThemeChanged(gtk_settings_get_default(), nullptr); | 423 OnThemeChanged(gtk_settings_get_default(), nullptr); |
| 416 } | 424 } |
| 417 | 425 |
| 418 NativeThemeGtk3::~NativeThemeGtk3() { | 426 NativeThemeGtk3::~NativeThemeGtk3() { |
| 419 NOTREACHED(); | 427 NOTREACHED(); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 | 646 |
| 639 if (frame_top_area.incognito) { | 647 if (frame_top_area.incognito) { |
| 640 bitmap = SkBitmapOperations::CreateHSLShiftedBitmap( | 648 bitmap = SkBitmapOperations::CreateHSLShiftedBitmap( |
| 641 bitmap, kDefaultTintFrameIncognito); | 649 bitmap, kDefaultTintFrameIncognito); |
| 642 } | 650 } |
| 643 | 651 |
| 644 canvas->drawBitmap(bitmap, rect.x(), rect.y()); | 652 canvas->drawBitmap(bitmap, rect.x(), rect.y()); |
| 645 } | 653 } |
| 646 | 654 |
| 647 } // namespace libgtkui | 655 } // namespace libgtkui |
| OLD | NEW |