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

Unified Diff: chrome/browser/ui/libgtk2ui/native_theme_gtk2.cc

Issue 1234223005: Initial gtk3 support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gtk2 regressions Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/libgtk2ui/native_theme_gtk2.h ('k') | chrome/browser/ui/libgtk2ui/owned_widget_gtk2.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/libgtk2ui/native_theme_gtk2.cc
diff --git a/chrome/browser/ui/libgtk2ui/native_theme_gtk2.cc b/chrome/browser/ui/libgtk2ui/native_theme_gtk2.cc
index 91d220f01229d555f18c75248cc027f41af8391b..213b280afca52afe3f08a6cf1f7dad2f0d6c3895 100644
--- a/chrome/browser/ui/libgtk2ui/native_theme_gtk2.cc
+++ b/chrome/browser/ui/libgtk2ui/native_theme_gtk2.cc
@@ -6,6 +6,7 @@
#include <gtk/gtk.h>
+#include "chrome/browser/ui/libgtk2ui/chrome_gtk_frame.h"
#include "chrome/browser/ui/libgtk2ui/chrome_gtk_menu_subclasses.h"
#include "chrome/browser/ui/libgtk2ui/gtk2_ui.h"
#include "chrome/browser/ui/libgtk2ui/gtk2_util.h"
@@ -18,32 +19,75 @@
#include "ui/gfx/skia_util.h"
#include "ui/native_theme/common_theme.h"
-namespace {
-// Theme colors returned by GetSystemColor().
-const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128);
+#if GTK_MAJOR_VERSION == 2
+
+#define GET_FG_COLOR(gtkwidget, gtkstate) \
+ GdkColorToSkColor(gtk_rc_get_style(gtkwidget)->fg[GTK_STATE_ ## gtkstate])
Elliot Glaysher 2015/09/09 17:58:10 Prefer inline functions to #define.
+
+#define GET_BG_COLOR(gtkwidget, gtkstate) \
+ GdkColorToSkColor(gtk_rc_get_style(gtkwidget)->bg[GTK_STATE_ ## gtkstate])
-const GdkColor kURLTextColor = GDK_COLOR_RGB(0x0b, 0x80, 0x43);
+#define GET_TEXT_COLOR(gtkwidget, gtkstate) \
+ GdkColorToSkColor(gtk_rc_get_style(gtkwidget)->text[GTK_STATE_ ## gtkstate])
-GdkColor GdkAlphaBlend(GdkColor foreground,
- GdkColor background,
- SkAlpha alpha) {
- return libgtk2ui::SkColorToGdkColor(
- color_utils::AlphaBlend(libgtk2ui::GdkColorToSkColor(foreground),
- libgtk2ui::GdkColorToSkColor(background), alpha));
+#define GET_TEXT_AA_COLOR(gtkwidget, gtkstate) \
+ GdkColorToSkColor(gtk_rc_get_style(gtkwidget)->text_aa[GTK_STATE_ ## gtkstate])
+
+#define GET_BASE_COLOR(gtkwidget, gtkstate) \
+ GdkColorToSkColor(gtk_rc_get_style(gtkwidget)->base[GTK_STATE_ ## gtkstate])
+
+#else
+
+inline SkColor FgColorToSkColor(GtkWidget* widget, GtkStateFlags flags) {
+ GdkRGBA color;
+ gtk_style_context_get_color(
+ gtk_widget_get_style_context(widget), flags, &color);
+ return SkColorSetRGB(color.red * 255, color.green * 255, color.blue * 255);
}
+inline SkColor BgColorToSkColor(GtkWidget* widget, GtkStateFlags flags) {
+ GdkRGBA color;
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ gtk_style_context_get_background_color(
+ gtk_widget_get_style_context(widget), flags, &color);
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
+ //Hack for default color
+ if (color.alpha == 0.0)
+ color = {1, 1, 1, 1};
+
+ return SkColorSetRGB(color.red * 255, color.green * 255, color.blue * 255);
+}
+
+
+#define GET_FG_COLOR(gtkwidget, gtkstate) \
+ FgColorToSkColor(gtkwidget, GTK_STATE_FLAG_ ## gtkstate)
+
+#define GET_BG_COLOR(gtkwidget, gtkstate) \
+ BgColorToSkColor(gtkwidget, GTK_STATE_FLAG_ ## gtkstate)
+
+#define GET_TEXT_COLOR GET_FG_COLOR
+#define GET_TEXT_AA_COLOR GET_FG_COLOR
+#define GET_BASE_COLOR GET_BG_COLOR
+
+#endif
+
+
+namespace {
+
+// Theme colors returned by GetSystemColor().
+const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128);
+const SkColor kURLTextColor = SkColorSetRGB(0x0b, 0x80, 0x43);
// Generates the normal URL color, a green color used in unhighlighted URL
// text. It is a mix of |kURLTextColor| and the current text color. Unlike the
// selected text color, it is more important to match the qualities of the
// foreground typeface color instead of taking the background into account.
-GdkColor NormalURLColor(GdkColor foreground) {
- color_utils::HSL fg_hsl;
- color_utils::SkColorToHSL(libgtk2ui::GdkColorToSkColor(foreground), &fg_hsl);
-
- color_utils::HSL hue_hsl;
- color_utils::SkColorToHSL(libgtk2ui::GdkColorToSkColor(kURLTextColor),
- &hue_hsl);
+SkColor NormalURLColor(SkColor foreground) {
+ color_utils::HSL fg_hsl, hue_hsl;
+ color_utils::SkColorToHSL(foreground, &fg_hsl);
+ color_utils::SkColorToHSL(kURLTextColor, &hue_hsl);
// Only allow colors that have a fair amount of saturation in them (color vs
// white). This means that our output color will always be fairly green.
@@ -58,7 +102,7 @@ GdkColor NormalURLColor(GdkColor foreground) {
l = (fg_hsl.l + hue_hsl.l) / 2;
color_utils::HSL output = { hue_hsl.h, s, l };
- return libgtk2ui::SkColorToGdkColor(color_utils::HSLToSkColor(output, 255));
+ return color_utils::HSLToSkColor(output, 255);
}
// Generates the selected URL color, a green color used on URL text in the
@@ -66,18 +110,11 @@ GdkColor NormalURLColor(GdkColor foreground) {
// |kURLTextColor|, the current text color, and the background color (the
// select highlight). It is more important to contrast with the background
// saturation than to look exactly like the foreground color.
-GdkColor SelectedURLColor(GdkColor foreground, GdkColor background) {
- color_utils::HSL fg_hsl;
- color_utils::SkColorToHSL(libgtk2ui::GdkColorToSkColor(foreground),
- &fg_hsl);
-
- color_utils::HSL bg_hsl;
- color_utils::SkColorToHSL(libgtk2ui::GdkColorToSkColor(background),
- &bg_hsl);
-
- color_utils::HSL hue_hsl;
- color_utils::SkColorToHSL(libgtk2ui::GdkColorToSkColor(kURLTextColor),
- &hue_hsl);
+SkColor SelectedURLColor(SkColor foreground, SkColor background) {
+ color_utils::HSL fg_hsl, bg_hsl, hue_hsl;
+ color_utils::SkColorToHSL(foreground, &fg_hsl);
+ color_utils::SkColorToHSL(background, &bg_hsl);
+ color_utils::SkColorToHSL(kURLTextColor, &hue_hsl);
// The saturation of the text should be opposite of the background, clamped
// to 0.2-0.8. We make sure it's greater than 0.2 so there's some color, but
@@ -91,12 +128,7 @@ GdkColor SelectedURLColor(GdkColor foreground, GdkColor background) {
double l = std::max(0.1, std::min(0.9, opposite_l));
color_utils::HSL output = { hue_hsl.h, s, l };
- return libgtk2ui::SkColorToGdkColor(color_utils::HSLToSkColor(output, 255));
-}
-
-GdkColor GetReadableColor(SkColor color, const GdkColor& background) {
- return libgtk2ui::SkColorToGdkColor(color_utils::GetReadableColor(
- color, libgtk2ui::GdkColorToSkColor(background)));
+ return color_utils::HSLToSkColor(output, 255);
}
} // namespace
@@ -110,58 +142,12 @@ NativeThemeGtk2* NativeThemeGtk2::instance() {
return &s_native_theme;
}
-NativeThemeGtk2::NativeThemeGtk2()
- : fake_window_(NULL),
- fake_tooltip_(NULL),
- fake_menu_item_(NULL) {
-}
-
-NativeThemeGtk2::~NativeThemeGtk2() {
- if (fake_window_)
- gtk_widget_destroy(fake_window_);
- if (fake_tooltip_)
- gtk_widget_destroy(fake_tooltip_);
-
- fake_entry_.Destroy();
- fake_label_.Destroy();
- fake_button_.Destroy();
- fake_tree_.Destroy();
- fake_menu_.Destroy();
-}
-
-gfx::Size NativeThemeGtk2::GetPartSize(Part part,
- State state,
- const ExtraParams& extra) const {
- if (part == kComboboxArrow)
- return gfx::Size(12, 12);
-
- return ui::NativeThemeBase::GetPartSize(part, state, extra);
-}
-
-void NativeThemeGtk2::Paint(SkCanvas* canvas,
- Part part,
- State state,
- const gfx::Rect& rect,
- const ExtraParams& extra) const {
- if (rect.IsEmpty())
- return;
+//Constructors automatically called
+NativeThemeGtk2::NativeThemeGtk2() {}
+//This doesn't actually get called
+NativeThemeGtk2::~NativeThemeGtk2() {}
- switch (part) {
- case kComboboxArrow:
- PaintComboboxArrow(canvas, GetGtkState(state), rect);
- return;
- default:
- NativeThemeBase::Paint(canvas, part, state, rect, extra);
- }
-}
-
-SkColor NativeThemeGtk2::GetSystemColor(ColorId color_id) const {
- if (color_id == kColorId_BlueButtonShadowColor)
- return SK_ColorTRANSPARENT;
-
- return GdkColorToSkColor(GetSystemGdkColor(color_id));
-}
void NativeThemeGtk2::PaintMenuPopupBackground(
SkCanvas* canvas,
@@ -213,208 +199,203 @@ void NativeThemeGtk2::PaintMenuItemBackground(
canvas->drawRect(gfx::RectToSkRect(rect), paint);
}
-GdkColor NativeThemeGtk2::GetSystemGdkColor(ColorId color_id) const {
+SkColor NativeThemeGtk2::GetSystemColor(ColorId color_id) const {
+ if (color_id == kColorId_BlueButtonShadowColor)
+ return SK_ColorTRANSPARENT;
+
const SkColor kPositiveTextColor = SkColorSetRGB(0x0b, 0x80, 0x43);
const SkColor kNegativeTextColor = SkColorSetRGB(0xc5, 0x39, 0x29);
+
switch (color_id) {
// Windows
case kColorId_WindowBackground:
- return GetWindowStyle()->bg[GTK_STATE_NORMAL];
+ return GET_BG_COLOR(GetWindow(), SELECTED);
// Dialogs
case kColorId_DialogBackground:
- return GetWindowStyle()->bg[GTK_STATE_NORMAL];
+ return GET_BG_COLOR(GetWindow(), NORMAL);
// FocusableBorder
case kColorId_FocusedBorderColor:
- return GetEntryStyle()->bg[GTK_STATE_SELECTED];
+ return GET_BG_COLOR(GetEntry(), SELECTED);
case kColorId_UnfocusedBorderColor:
- return GetEntryStyle()->text_aa[GTK_STATE_NORMAL];
+ return GET_TEXT_AA_COLOR(GetEntry(), NORMAL);
// MenuItem
case kColorId_EnabledMenuItemForegroundColor:
case kColorId_DisabledEmphasizedMenuItemForegroundColor:
- return GetMenuItemStyle()->text[GTK_STATE_NORMAL];
+ return GET_TEXT_COLOR(GetMenuItem(), NORMAL);
case kColorId_DisabledMenuItemForegroundColor:
- return GetMenuItemStyle()->text[GTK_STATE_INSENSITIVE];
+ return GET_TEXT_COLOR(GetMenuItem(), INSENSITIVE);
case kColorId_SelectedMenuItemForegroundColor:
- return GetMenuItemStyle()->text[GTK_STATE_SELECTED];
+ return GET_TEXT_COLOR(GetMenuItem(), SELECTED);
case kColorId_FocusedMenuItemBackgroundColor:
- return GetMenuItemStyle()->bg[GTK_STATE_SELECTED];
+ return GET_BG_COLOR(GetMenuItem(), SELECTED);
case kColorId_HoverMenuItemBackgroundColor:
- return GetMenuItemStyle()->bg[GTK_STATE_PRELIGHT];
+ return GET_BG_COLOR(GetMenuItem(), PRELIGHT);
case kColorId_FocusedMenuButtonBorderColor:
- return GetEntryStyle()->bg[GTK_STATE_NORMAL];
+ return GET_BG_COLOR(GetEntry(), NORMAL);
case kColorId_HoverMenuButtonBorderColor:
- return GetEntryStyle()->text_aa[GTK_STATE_PRELIGHT];
+ return GET_TEXT_AA_COLOR(GetEntry(), PRELIGHT);
case kColorId_MenuBorderColor:
case kColorId_EnabledMenuButtonBorderColor:
case kColorId_MenuSeparatorColor: {
- return GetMenuItemStyle()->text[GTK_STATE_INSENSITIVE];
+ return GET_TEXT_COLOR(GetMenuItem(), INSENSITIVE);
}
case kColorId_MenuBackgroundColor:
- return GetMenuStyle()->bg[GTK_STATE_NORMAL];
+ return GET_BG_COLOR(GetMenu(), NORMAL);
// Label
case kColorId_LabelEnabledColor:
- return GetLabelStyle()->text[GTK_STATE_NORMAL];
+ return GET_TEXT_COLOR(GetEntry(), NORMAL);
case kColorId_LabelDisabledColor:
- return GetLabelStyle()->text[GTK_STATE_INSENSITIVE];
+ return GET_TEXT_COLOR(GetLabel(), INSENSITIVE);
case kColorId_LabelBackgroundColor:
- return GetWindowStyle()->bg[GTK_STATE_NORMAL];
+ return GET_BG_COLOR(GetWindow(), NORMAL);
// Button
case kColorId_ButtonBackgroundColor:
- return GetButtonStyle()->bg[GTK_STATE_NORMAL];
+ return GET_BG_COLOR(GetButton(), NORMAL);
case kColorId_ButtonEnabledColor:
case kColorId_BlueButtonEnabledColor:
- return GetButtonStyle()->text[GTK_STATE_NORMAL];
+ return GET_TEXT_COLOR(GetButton(), NORMAL);
case kColorId_ButtonDisabledColor:
case kColorId_BlueButtonDisabledColor:
- return GetButtonStyle()->text[GTK_STATE_INSENSITIVE];
+ return GET_TEXT_COLOR(GetButton(), INSENSITIVE);
case kColorId_ButtonHighlightColor:
- return GetButtonStyle()->base[GTK_STATE_SELECTED];
+ return GET_BASE_COLOR(GetButton(), SELECTED);
case kColorId_ButtonHoverColor:
case kColorId_BlueButtonHoverColor:
- return GetButtonStyle()->text[GTK_STATE_PRELIGHT];
+ return GET_TEXT_COLOR(GetButton(), PRELIGHT);
case kColorId_ButtonHoverBackgroundColor:
- return GetButtonStyle()->bg[GTK_STATE_PRELIGHT];
+ return GET_BG_COLOR(GetButton(), PRELIGHT);
case kColorId_BlueButtonPressedColor:
- return GetButtonStyle()->text[GTK_STATE_ACTIVE];
+ return GET_TEXT_COLOR(GetButton(), ACTIVE);
case kColorId_BlueButtonShadowColor:
// Should be handled in GetSystemColor().
NOTREACHED();
- return GetButtonStyle()->text[GTK_STATE_NORMAL];
+ return GET_TEXT_COLOR(GetButton(), NORMAL);
// Textfield
case kColorId_TextfieldDefaultColor:
- return GetEntryStyle()->text[GTK_STATE_NORMAL];
+ return GET_TEXT_COLOR(GetEntry(), NORMAL);
case kColorId_TextfieldDefaultBackground:
- return GetEntryStyle()->base[GTK_STATE_NORMAL];
+ return GET_BASE_COLOR(GetEntry(), NORMAL);
case kColorId_TextfieldReadOnlyColor:
- return GetEntryStyle()->text[GTK_STATE_INSENSITIVE];
+ return GET_TEXT_COLOR(GetEntry(), INSENSITIVE);
case kColorId_TextfieldReadOnlyBackground:
- return GetEntryStyle()->base[GTK_STATE_INSENSITIVE];
+ return GET_BASE_COLOR(GetEntry(), INSENSITIVE);
case kColorId_TextfieldSelectionColor:
- return GetEntryStyle()->text[GTK_STATE_SELECTED];
+ return GET_TEXT_COLOR(GetEntry(), SELECTED);
case kColorId_TextfieldSelectionBackgroundFocused:
- return GetEntryStyle()->base[GTK_STATE_SELECTED];
+ return GET_BASE_COLOR(GetEntry(), SELECTED);
// Tooltips
case kColorId_TooltipBackground:
- return GetTooltipStyle()->bg[GTK_STATE_NORMAL];
+ return GET_BG_COLOR(GetTooltip(), NORMAL);
case kColorId_TooltipText:
- return GetTooltipStyle()->fg[GTK_STATE_NORMAL];
+ return GET_FG_COLOR(GetTooltip(), NORMAL);
// Trees and Tables (implemented on GTK using the same class)
case kColorId_TableBackground:
case kColorId_TreeBackground:
- return GetTreeStyle()->bg[GTK_STATE_NORMAL];
+ return GET_BG_COLOR(GetTree(), NORMAL);
case kColorId_TableText:
case kColorId_TreeText:
- return GetTreeStyle()->text[GTK_STATE_NORMAL];
+ return GET_TEXT_COLOR(GetTree(), NORMAL);
case kColorId_TableSelectedText:
case kColorId_TableSelectedTextUnfocused:
case kColorId_TreeSelectedText:
case kColorId_TreeSelectedTextUnfocused:
- return GetTreeStyle()->text[GTK_STATE_SELECTED];
+ return GET_TEXT_COLOR(GetTree(), SELECTED);
case kColorId_TableSelectionBackgroundFocused:
case kColorId_TableSelectionBackgroundUnfocused:
case kColorId_TreeSelectionBackgroundFocused:
case kColorId_TreeSelectionBackgroundUnfocused:
- return GetTreeStyle()->bg[GTK_STATE_SELECTED];
+ return GET_BG_COLOR(GetTree(), SELECTED);
case kColorId_TreeArrow:
- return GetTreeStyle()->fg[GTK_STATE_NORMAL];
+ return GET_FG_COLOR(GetTree(), NORMAL);
case kColorId_TableGroupingIndicatorColor:
- return GetTreeStyle()->text_aa[GTK_STATE_NORMAL];
+ return GET_TEXT_AA_COLOR(GetTree(), NORMAL);
// Results Table
case kColorId_ResultsTableNormalBackground:
- return GetEntryStyle()->base[GTK_STATE_NORMAL];
- case kColorId_ResultsTableHoveredBackground: {
- GtkStyle* entry_style = GetEntryStyle();
- return GdkAlphaBlend(
- entry_style->base[GTK_STATE_NORMAL],
- entry_style->base[GTK_STATE_SELECTED], 0x80);
- }
+ return GET_BASE_COLOR(GetEntry(), NORMAL);
+ case kColorId_ResultsTableHoveredBackground:
+ return color_utils::AlphaBlend(GET_BASE_COLOR(GetEntry(), NORMAL),
+ GET_BASE_COLOR(GetEntry(), SELECTED),
+ 0x80);
case kColorId_ResultsTableSelectedBackground:
- return GetEntryStyle()->base[GTK_STATE_SELECTED];
+ return GET_BASE_COLOR(GetEntry(), SELECTED);
case kColorId_ResultsTableNormalText:
case kColorId_ResultsTableHoveredText:
- return GetEntryStyle()->text[GTK_STATE_NORMAL];
+ return GET_TEXT_COLOR(GetEntry(), NORMAL);
case kColorId_ResultsTableSelectedText:
- return GetEntryStyle()->text[GTK_STATE_SELECTED];
+ return GET_TEXT_COLOR(GetEntry(), SELECTED);
case kColorId_ResultsTableNormalDimmedText:
- case kColorId_ResultsTableHoveredDimmedText: {
- GtkStyle* entry_style = GetEntryStyle();
- return GdkAlphaBlend(
- entry_style->text[GTK_STATE_NORMAL],
- entry_style->base[GTK_STATE_NORMAL], 0x80);
- }
- case kColorId_ResultsTableSelectedDimmedText: {
- GtkStyle* entry_style = GetEntryStyle();
- return GdkAlphaBlend(
- entry_style->text[GTK_STATE_SELECTED],
- entry_style->base[GTK_STATE_NORMAL], 0x80);
- }
+ case kColorId_ResultsTableHoveredDimmedText:
+ return color_utils::AlphaBlend(GET_TEXT_COLOR(GetEntry(), NORMAL),
+ GET_BASE_COLOR(GetEntry(), NORMAL),
+ 0x80);
+ case kColorId_ResultsTableSelectedDimmedText:
+ return color_utils::AlphaBlend(GET_TEXT_COLOR(GetEntry(), SELECTED),
+ GET_BASE_COLOR(GetEntry(), NORMAL),
+ 0x80);
case kColorId_ResultsTableNormalUrl:
- case kColorId_ResultsTableHoveredUrl: {
- return NormalURLColor(GetEntryStyle()->text[GTK_STATE_NORMAL]);
- }
- case kColorId_ResultsTableSelectedUrl: {
- GtkStyle* entry_style = GetEntryStyle();
- return SelectedURLColor(entry_style->text[GTK_STATE_SELECTED],
- entry_style->base[GTK_STATE_SELECTED]);
- }
- case kColorId_ResultsTableNormalDivider: {
- GtkStyle* win_style = GetWindowStyle();
- return GdkAlphaBlend(win_style->text[GTK_STATE_NORMAL],
- win_style->bg[GTK_STATE_NORMAL], 0x34);
- }
- case kColorId_ResultsTableHoveredDivider: {
- GtkStyle* win_style = GetWindowStyle();
- return GdkAlphaBlend(win_style->text[GTK_STATE_PRELIGHT],
- win_style->bg[GTK_STATE_PRELIGHT], 0x34);
- }
- case kColorId_ResultsTableSelectedDivider: {
- GtkStyle* win_style = GetWindowStyle();
- return GdkAlphaBlend(win_style->text[GTK_STATE_SELECTED],
- win_style->bg[GTK_STATE_SELECTED], 0x34);
- }
+ case kColorId_ResultsTableHoveredUrl:
+ return NormalURLColor(GET_TEXT_COLOR(GetEntry(), NORMAL));
+
+ case kColorId_ResultsTableSelectedUrl:
+ return SelectedURLColor(GET_TEXT_COLOR(GetEntry(), SELECTED),
+ GET_BASE_COLOR(GetEntry(), SELECTED));
+ case kColorId_ResultsTableNormalDivider:
+ return color_utils::AlphaBlend(GET_TEXT_COLOR(GetWindow(), NORMAL),
+ GET_BG_COLOR(GetWindow(), NORMAL),
+ 0x34);
+ case kColorId_ResultsTableHoveredDivider:
+ return color_utils::AlphaBlend(GET_TEXT_COLOR(GetWindow(), PRELIGHT),
+ GET_BG_COLOR(GetWindow(), PRELIGHT),
+ 0x34);
+ case kColorId_ResultsTableSelectedDivider:
+ return color_utils::AlphaBlend(GET_TEXT_COLOR(GetWindow(), SELECTED),
+ GET_BG_COLOR(GetWindow(), SELECTED),
+ 0x34);
+
case kColorId_ResultsTablePositiveText: {
- return GetReadableColor(kPositiveTextColor,
- GetEntryStyle()->base[GTK_STATE_NORMAL]);
+ return color_utils::GetReadableColor(kPositiveTextColor,
+ GET_BASE_COLOR(GetEntry(), NORMAL));
}
case kColorId_ResultsTablePositiveHoveredText: {
- return GetReadableColor(kPositiveTextColor,
- GetEntryStyle()->base[GTK_STATE_PRELIGHT]);
+ return color_utils::GetReadableColor(kPositiveTextColor,
+ GET_BASE_COLOR(GetEntry(), PRELIGHT));
}
case kColorId_ResultsTablePositiveSelectedText: {
- return GetReadableColor(kPositiveTextColor,
- GetEntryStyle()->base[GTK_STATE_SELECTED]);
+ return color_utils::GetReadableColor(kPositiveTextColor,
+ GET_BASE_COLOR(GetEntry(), SELECTED));
}
case kColorId_ResultsTableNegativeText: {
- return GetReadableColor(kNegativeTextColor,
- GetEntryStyle()->base[GTK_STATE_NORMAL]);
+ return color_utils::GetReadableColor(kNegativeTextColor,
+ GET_BASE_COLOR(GetEntry(), NORMAL));
}
case kColorId_ResultsTableNegativeHoveredText: {
- return GetReadableColor(kNegativeTextColor,
- GetEntryStyle()->base[GTK_STATE_PRELIGHT]);
+ return color_utils::GetReadableColor(kNegativeTextColor,
+ GET_BASE_COLOR(GetEntry(), PRELIGHT));
}
case kColorId_ResultsTableNegativeSelectedText: {
- return GetReadableColor(kNegativeTextColor,
- GetEntryStyle()->base[GTK_STATE_SELECTED]);
+ return color_utils::GetReadableColor(kNegativeTextColor,
+ GET_BASE_COLOR(GetEntry(), SELECTED));
}
// Throbber
case kColorId_ThrobberSpinningColor:
case kColorId_ThrobberLightColor: {
- return GetEntryStyle()->bg[GTK_STATE_SELECTED];
+ return GET_BG_COLOR(GetEntry(), SELECTED);
}
case kColorId_ThrobberWaitingColor: {
- return GdkAlphaBlend(GetEntryStyle()->bg[GTK_STATE_SELECTED],
- GetWindowStyle()->bg[GTK_STATE_NORMAL], 0xff / 2);
+ return color_utils::AlphaBlend(GET_BG_COLOR(GetEntry(), SELECTED),
+ GET_BG_COLOR(GetWindow(), NORMAL),
+ 0x80);
}
case kColorId_ChromeIconGrey:
@@ -424,118 +405,76 @@ GdkColor NativeThemeGtk2::GetSystemGdkColor(ColorId color_id) const {
break;
}
- return SkColorToGdkColor(kInvalidColorIdColor);
+ return kInvalidColorIdColor;
}
-GtkWidget* NativeThemeGtk2::GetRealizedWindow() const {
- if (!fake_window_) {
- fake_window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_widget_realize(fake_window_);
+GtkWidget* NativeThemeGtk2::GetWindow() const {
+ if (!fake_window_.get()) {
+ fake_window_.Own(chrome_gtk_frame_new());
+ gtk_widget_realize(fake_window_.get());
}
- return fake_window_;
+ return fake_window_.get();
}
-GtkStyle* NativeThemeGtk2::GetWindowStyle() const {
- return gtk_rc_get_style(GetRealizedWindow());
-}
-
-GtkStyle* NativeThemeGtk2::GetEntryStyle() const {
+GtkWidget* NativeThemeGtk2::GetEntry() const {
if (!fake_entry_.get()) {
fake_entry_.Own(gtk_entry_new());
// The fake entry needs to be in the window so it can be realized so we can
// use the computed parts of the style.
- gtk_container_add(GTK_CONTAINER(GetRealizedWindow()), fake_entry_.get());
+ gtk_container_add(GTK_CONTAINER(GetWindow()), fake_entry_.get());
gtk_widget_realize(fake_entry_.get());
}
- return gtk_rc_get_style(fake_entry_.get());
+
+ return fake_entry_.get();
}
-GtkStyle* NativeThemeGtk2::GetLabelStyle() const {
+GtkWidget* NativeThemeGtk2::GetLabel() const {
if (!fake_label_.get())
fake_label_.Own(gtk_label_new(""));
- return gtk_rc_get_style(fake_label_.get());
+ return fake_label_.get();
}
-GtkStyle* NativeThemeGtk2::GetButtonStyle() const {
+GtkWidget* NativeThemeGtk2::GetButton() const {
if (!fake_button_.get())
fake_button_.Own(gtk_button_new());
- return gtk_rc_get_style(fake_button_.get());
+ return fake_button_.get();
}
-GtkStyle* NativeThemeGtk2::GetTreeStyle() const {
+GtkWidget* NativeThemeGtk2::GetTree() const {
if (!fake_tree_.get())
fake_tree_.Own(gtk_tree_view_new());
- return gtk_rc_get_style(fake_tree_.get());
+ return fake_tree_.get();
}
-GtkStyle* NativeThemeGtk2::GetTooltipStyle() const {
- if (!fake_tooltip_) {
- fake_tooltip_ = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_widget_set_name(fake_tooltip_, "gtk-tooltip");
- gtk_widget_realize(fake_tooltip_);
+GtkWidget* NativeThemeGtk2::GetTooltip() const {
+ if (!fake_tooltip_.get()) {
+ fake_tooltip_.Own(gtk_window_new(GTK_WINDOW_TOPLEVEL));
+ gtk_widget_set_name(fake_tooltip_.get(), "gtk-tooltip");
+ gtk_widget_realize(fake_tooltip_.get());
}
- return gtk_rc_get_style(fake_tooltip_);
+
+ return fake_tooltip_.get();
}
-GtkStyle* NativeThemeGtk2::GetMenuStyle() const {
+GtkWidget* NativeThemeGtk2::GetMenu() const {
if (!fake_menu_.get())
fake_menu_.Own(gtk_custom_menu_new());
- return gtk_rc_get_style(fake_menu_.get());
-}
-GtkStyle* NativeThemeGtk2::GetMenuItemStyle() const {
- if (!fake_menu_item_) {
- if (!fake_menu_.get())
- fake_menu_.Own(gtk_custom_menu_new());
+ return fake_menu_.get();
+}
- fake_menu_item_ = gtk_custom_menu_item_new();
- gtk_menu_shell_append(GTK_MENU_SHELL(fake_menu_.get()), fake_menu_item_);
+GtkWidget* NativeThemeGtk2::GetMenuItem() const {
+ if (!fake_menu_item_.get()) {
+ fake_menu_item_.Own(gtk_custom_menu_item_new());
+ gtk_menu_shell_append(GTK_MENU_SHELL(GetMenu()), fake_menu_item_.get());
}
- return gtk_rc_get_style(fake_menu_item_);
-}
-
-void NativeThemeGtk2::PaintComboboxArrow(SkCanvas* canvas,
- GtkStateType state,
- const gfx::Rect& rect) const {
- GdkPixmap* pm = gdk_pixmap_new(gtk_widget_get_window(GetRealizedWindow()),
- rect.width(),
- rect.height(),
- -1);
- // Paint the background.
- gtk_paint_flat_box(GetWindowStyle(),
- pm,
- state,
- GTK_SHADOW_NONE,
- NULL,
- GetRealizedWindow(),
- NULL, 0, 0, rect.width(), rect.height());
- gtk_paint_arrow(GetWindowStyle(),
- pm,
- state,
- GTK_SHADOW_NONE,
- NULL,
- GetRealizedWindow(),
- NULL,
- GTK_ARROW_DOWN,
- true,
- 0, 0, rect.width(), rect.height());
- GdkPixbuf* pb = gdk_pixbuf_get_from_drawable(NULL,
- pm,
- gdk_drawable_get_colormap(pm),
- 0, 0,
- 0, 0,
- rect.width(), rect.height());
- SkBitmap arrow = GdkPixbufToImageSkia(pb);
- canvas->drawBitmap(arrow, rect.x(), rect.y());
-
- g_object_unref(pb);
- g_object_unref(pm);
+ return fake_menu_item_.get();
}
} // namespace libgtk2ui
« no previous file with comments | « chrome/browser/ui/libgtk2ui/native_theme_gtk2.h ('k') | chrome/browser/ui/libgtk2ui/owned_widget_gtk2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698