From c06504a1ff40d8569a93b9898d9503f5f116ab0b Mon Sep 17 00:00:00 2001 From: "erg@chromium.org" Date: Wed, 14 Apr 2010 16:20:49 +0000 Subject: GTK: Set the selection colors on the omnibox. This prevents GTK theme colors from bleeding into the omnibox. TEST=none BUG=none Review URL: http://codereview.chromium.org/1605026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44482 0039d316-1c4b-4281-b951-d872f2087c98 --- .../autocomplete/autocomplete_edit_view_gtk.cc | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'chrome/browser') diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc index b74ec0a..e193736 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc @@ -27,6 +27,7 @@ #include "chrome/common/notification_service.h" #include "gfx/font.h" #include "gfx/gtk_util.h" +#include "gfx/skia_utils_gtk.h" #include "googleurl/src/gurl.h" #include "grit/generated_resources.h" #include "net/base/escape.h" @@ -41,6 +42,8 @@ #include "chrome/browser/gtk/location_bar_view_gtk.h" #endif +using gfx::SkColorToGdkColor; + namespace { const char kTextBaseColor[] = "#808080"; @@ -597,6 +600,10 @@ void AutocompleteEditViewGtk::SetBaseColor() { if (use_gtk) { gtk_widget_modify_base(text_view_, GTK_STATE_NORMAL, NULL); + gtk_widget_modify_base(text_view_, GTK_STATE_SELECTED, NULL); + gtk_widget_modify_text(text_view_, GTK_STATE_SELECTED, NULL); + gtk_widget_modify_base(text_view_, GTK_STATE_ACTIVE, NULL); + gtk_widget_modify_text(text_view_, GTK_STATE_ACTIVE, NULL); // Grab the text colors out of the style and set our tags to use them. GtkStyle* style = gtk_rc_get_style(text_view_); @@ -621,6 +628,23 @@ void AutocompleteEditViewGtk::SetBaseColor() { #endif gtk_widget_modify_base(text_view_, GTK_STATE_NORMAL, background_color_ptr); +#if !defined(TOOLKIT_VIEWS) + // Override the selected colors so we don't leak colors from the current + // gtk theme into the chrome-theme. + GdkColor c; + c = SkColorToGdkColor(theme_provider_->get_active_selection_bg_color()); + gtk_widget_modify_base(text_view_, GTK_STATE_SELECTED, &c); + + c = SkColorToGdkColor(theme_provider_->get_active_selection_fg_color()); + gtk_widget_modify_text(text_view_, GTK_STATE_SELECTED, &c); + + c = SkColorToGdkColor(theme_provider_->get_inactive_selection_bg_color()); + gtk_widget_modify_base(text_view_, GTK_STATE_ACTIVE, &c); + + c = SkColorToGdkColor(theme_provider_->get_inactive_selection_fg_color()); + gtk_widget_modify_text(text_view_, GTK_STATE_ACTIVE, &c); +#endif + g_object_set(faded_text_tag_, "foreground", kTextBaseColor, NULL); g_object_set(normal_text_tag_, "foreground", "#000000", NULL); } -- cgit v1.1