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

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

Issue 1234223005: Initial gtk3 support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gtk2 colors Created 5 years, 4 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
Index: chrome/browser/ui/libgtk2ui/native_theme_gtk2.h
diff --git a/chrome/browser/ui/libgtk2ui/native_theme_gtk2.h b/chrome/browser/ui/libgtk2ui/native_theme_gtk2.h
index 78e9c8997708366dd17be024d3a0453cb3e85c9a..a4da945ad35ad870ba4638f910fe2afae81e0b47 100644
--- a/chrome/browser/ui/libgtk2ui/native_theme_gtk2.h
+++ b/chrome/browser/ui/libgtk2ui/native_theme_gtk2.h
@@ -10,7 +10,62 @@
#include "chrome/browser/ui/libgtk2ui/owned_widget_gtk2.h"
#include "ui/native_theme/native_theme_base.h"
-typedef struct _GdkColor GdkColor;
+
+
+//if GTK_MAJOR_VERSION == 2
+#if 1
+
+#define GET_FG_COLOR(gtkwidget, gtkstate) \
+ GdkColorToSkColor(gtk_rc_get_style(gtkwidget)->fg[GTK_STATE_ ## gtkstate])
+
+#define GET_BG_COLOR(gtkwidget, gtkstate) \
+ GdkColorToSkColor(gtk_rc_get_style(gtkwidget)->bg[GTK_STATE_ ## gtkstate])
+
+#define GET_TEXT_COLOR(gtkwidget, gtkstate) \
+ GdkColorToSkColor(gtk_rc_get_style(gtkwidget)->text[GTK_STATE_ ## gtkstate])
+
+#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;
+ gtk_style_context_get_background_color(
+ gtk_widget_get_style_context(widget), flags, &color);
+
+ //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 libgtk2ui {
@@ -41,37 +96,32 @@ class NativeThemeGtk2 : public ui::NativeThemeBase {
const gfx::Rect& rect,
const MenuListExtraParams& menu_list) const override;
+ // Returns various widgets for theming use.
+ GtkWidget* GetWindow() const;
+ GtkWidget* GetEntry() const;
+ GtkWidget* GetLabel() const;
+ GtkWidget* GetButton() const;
+ GtkWidget* GetTree() const;
+ GtkWidget* GetTooltip() const;
+ GtkWidget* GetMenu() const;
+ GtkWidget* GetMenuItem() const;
+
private:
NativeThemeGtk2();
~NativeThemeGtk2() override;
- // Implementation of GetSystemColor.
- GdkColor GetSystemGdkColor(ColorId color_id) const;
-
- // Returns styles associated with various widget types.
- GtkWidget* GetRealizedWindow() const;
- GtkStyle* GetWindowStyle() const;
- GtkStyle* GetEntryStyle() const;
- GtkStyle* GetLabelStyle() const;
- GtkStyle* GetButtonStyle() const;
- GtkStyle* GetTreeStyle() const;
- GtkStyle* GetTooltipStyle() const;
- GtkStyle* GetMenuStyle() const;
- GtkStyle* GetMenuItemStyle() const;
-
void PaintComboboxArrow(SkCanvas* canvas,
- GtkStateType state,
+ State state,
const gfx::Rect& rect) const;
- mutable GtkWidget* fake_window_;
- mutable GtkWidget* fake_tooltip_;
+ mutable OwnedWidgetGtk fake_window_;
mutable OwnedWidgetGtk fake_entry_;
mutable OwnedWidgetGtk fake_label_;
mutable OwnedWidgetGtk fake_button_;
mutable OwnedWidgetGtk fake_tree_;
-
+ mutable OwnedWidgetGtk fake_tooltip_;
mutable OwnedWidgetGtk fake_menu_;
- mutable GtkWidget* fake_menu_item_;
+ mutable OwnedWidgetGtk fake_menu_item_;
DISALLOW_COPY_AND_ASSIGN(NativeThemeGtk2);
};

Powered by Google App Engine
This is Rietveld 408576698