summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-03 18:43:28 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-03 18:43:28 +0000
commitc7e082e2c8b24f56089b7b9fc465785dabae9ab1 (patch)
tree2c3a5c0fabd1a33283cf9d561c411c728b82ffb0
parentc0e271526431ce0ea45f8a2fb47d19f6ca12858a (diff)
downloadchromium_src-c7e082e2c8b24f56089b7b9fc465785dabae9ab1.zip
chromium_src-c7e082e2c8b24f56089b7b9fc465785dabae9ab1.tar.gz
chromium_src-c7e082e2c8b24f56089b7b9fc465785dabae9ab1.tar.bz2
GTK Themes: Theme labels in LocationBarViewGtk.
Labels in LocationBarViewGtk should be black even when a dark GTK theme is used when we're not in GTK theme mode. Likewise, when we're using a GTK theme, we should have the background and border color of the "Search X for:" box use colors from the theme instead of having hard coded ones. Review URL: http://codereview.chromium.org/159798 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22293 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/gtk/blocked_popup_container_view_gtk.cc10
-rw-r--r--chrome/browser/gtk/bookmark_utils_gtk.cc11
-rw-r--r--chrome/browser/gtk/location_bar_view_gtk.cc53
-rw-r--r--chrome/browser/gtk/location_bar_view_gtk.h21
-rw-r--r--chrome/common/gtk_util.cc7
-rw-r--r--chrome/common/gtk_util.h3
6 files changed, 80 insertions, 25 deletions
diff --git a/chrome/browser/gtk/blocked_popup_container_view_gtk.cc b/chrome/browser/gtk/blocked_popup_container_view_gtk.cc
index 8ada0f0..6fe1671 100644
--- a/chrome/browser/gtk/blocked_popup_container_view_gtk.cc
+++ b/chrome/browser/gtk/blocked_popup_container_view_gtk.cc
@@ -110,17 +110,11 @@ void BlockedPopupContainerViewGtk::Observe(NotificationType type,
// Update the label's colors.
GtkWidget* label = gtk_bin_get_child(GTK_BIN(menu_button_));
if (theme_provider_->UseGtkTheme()) {
- gtk_widget_modify_fg(label, GTK_STATE_NORMAL, NULL);
- gtk_widget_modify_fg(label, GTK_STATE_ACTIVE, NULL);
- gtk_widget_modify_fg(label, GTK_STATE_PRELIGHT, NULL);
- gtk_widget_modify_fg(label, GTK_STATE_INSENSITIVE, NULL);
+ gtk_util::SetLabelColor(label, NULL);
} else {
GdkColor color = theme_provider_->GetGdkColor(
BrowserThemeProvider::COLOR_BOOKMARK_TEXT);
- gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &color);
- gtk_widget_modify_fg(label, GTK_STATE_ACTIVE, &color);
- gtk_widget_modify_fg(label, GTK_STATE_PRELIGHT, &color);
- gtk_widget_modify_fg(label, GTK_STATE_INSENSITIVE, &color);
+ gtk_util::SetLabelColor(label, &color);
}
}
diff --git a/chrome/browser/gtk/bookmark_utils_gtk.cc b/chrome/browser/gtk/bookmark_utils_gtk.cc
index 07e87ec..cf67b54 100644
--- a/chrome/browser/gtk/bookmark_utils_gtk.cc
+++ b/chrome/browser/gtk/bookmark_utils_gtk.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/gtk/gtk_dnd_util.h"
#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/browser/profile.h"
+#include "chrome/common/gtk_util.h"
#include "grit/app_resources.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -162,17 +163,11 @@ const BookmarkNode* BookmarkNodeForWidget(GtkWidget* widget) {
void SetButtonTextColors(GtkWidget* label, GtkThemeProvider* provider) {
if (provider->UseGtkTheme()) {
- gtk_widget_modify_fg(label, GTK_STATE_NORMAL, NULL);
- gtk_widget_modify_fg(label, GTK_STATE_ACTIVE, NULL);
- gtk_widget_modify_fg(label, GTK_STATE_PRELIGHT, NULL);
- gtk_widget_modify_fg(label, GTK_STATE_INSENSITIVE, NULL);
+ gtk_util::SetLabelColor(label, NULL);
} else {
GdkColor color = provider->GetGdkColor(
BrowserThemeProvider::COLOR_BOOKMARK_TEXT);
- gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &color);
- gtk_widget_modify_fg(label, GTK_STATE_ACTIVE, &color);
- gtk_widget_modify_fg(label, GTK_STATE_PRELIGHT, &color);
- gtk_widget_modify_fg(label, GTK_STATE_INSENSITIVE, &color);
+ gtk_util::SetLabelColor(label, &color);
}
}
diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc
index 33bdac0..df06597 100644
--- a/chrome/browser/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/gtk/location_bar_view_gtk.cc
@@ -24,6 +24,7 @@
#include "chrome/browser/search_engines/template_url_model.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/gtk_util.h"
+#include "chrome/common/notification_service.h"
#include "chrome/common/page_transition_types.h"
#include "grit/generated_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -103,6 +104,8 @@ LocationBarViewGtk::LocationBarViewGtk(CommandUpdater* command_updater,
info_label_align_(NULL),
info_label_(NULL),
tab_to_search_(NULL),
+ tab_to_search_border_(NULL),
+ tab_to_search_box_(NULL),
tab_to_search_label_(NULL),
tab_to_search_hint_(NULL),
tab_to_search_hint_leading_label_(NULL),
@@ -115,7 +118,8 @@ LocationBarViewGtk::LocationBarViewGtk(CommandUpdater* command_updater,
disposition_(CURRENT_TAB),
transition_(PageTransition::TYPED),
first_run_bubble_(this),
- popup_window_mode_(false) {
+ popup_window_mode_(false),
+ theme_provider_(NULL) {
}
LocationBarViewGtk::~LocationBarViewGtk() {
@@ -168,12 +172,11 @@ void LocationBarViewGtk::Init(bool popup_window_mode) {
// This crazy stack of alignments and event boxes creates a box around the
// keyword text with a border, background color, and padding around the text.
- gtk_container_add(GTK_CONTAINER(tab_to_search_),
- gtk_util::CreateGtkBorderBin(
- gtk_util::CreateGtkBorderBin(
- tab_to_search_label_, &kKeywordBackgroundColor, 1, 1, 2, 2),
- &kKeywordBorderColor, 1, 1, 1, 1));
-
+ tab_to_search_box_ = gtk_util::CreateGtkBorderBin(
+ tab_to_search_label_, NULL, 1, 1, 2, 2);
+ tab_to_search_border_ = gtk_util::CreateGtkBorderBin(
+ tab_to_search_box_, NULL, 1, 1, 1, 1);
+ gtk_container_add(GTK_CONTAINER(tab_to_search_), tab_to_search_border_);
gtk_box_pack_start(GTK_BOX(hbox_.get()), tab_to_search_, FALSE, FALSE, 0);
GtkWidget* align = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
@@ -248,6 +251,12 @@ void LocationBarViewGtk::Init(bool popup_window_mode) {
gtk_container_add(GTK_CONTAINER(event_box), security_icon_box);
gtk_container_add(GTK_CONTAINER(security_icon_align_), event_box);
gtk_box_pack_end(GTK_BOX(hbox_.get()), security_icon_align_, FALSE, FALSE, 0);
+
+ registrar_.Add(this,
+ NotificationType::BROWSER_THEME_CHANGED,
+ NotificationService::AllSources());
+ theme_provider_ = GtkThemeProvider::GetFrom(profile_);
+ theme_provider_->InitThemesFor(this);
}
void LocationBarViewGtk::SetProfile(Profile* profile) {
@@ -393,6 +402,36 @@ int LocationBarViewGtk::PageActionVisibleCount() {
return -1;
}
+void LocationBarViewGtk::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ DCHECK_EQ(type.value, NotificationType::BROWSER_THEME_CHANGED);
+
+ if (theme_provider_->UseGtkTheme()) {
+ gtk_widget_modify_bg(tab_to_search_box_, GTK_STATE_NORMAL, NULL);
+
+ GdkColor border_color = theme_provider_->GetGdkColor(
+ BrowserThemeProvider::COLOR_FRAME);
+ gtk_widget_modify_bg(tab_to_search_border_, GTK_STATE_NORMAL,
+ &border_color);
+
+ gtk_util::SetLabelColor(tab_to_search_label_, NULL);
+ gtk_util::SetLabelColor(tab_to_search_hint_leading_label_, NULL);
+ gtk_util::SetLabelColor(tab_to_search_hint_trailing_label_, NULL);
+ } else {
+ gtk_widget_modify_bg(tab_to_search_box_, GTK_STATE_NORMAL,
+ &kKeywordBackgroundColor);
+ gtk_widget_modify_bg(tab_to_search_border_, GTK_STATE_NORMAL,
+ &kKeywordBorderColor);
+
+ gtk_util::SetLabelColor(tab_to_search_label_, &gfx::kGdkBlack);
+ gtk_util::SetLabelColor(tab_to_search_hint_leading_label_,
+ &gfx::kGdkBlack);
+ gtk_util::SetLabelColor(tab_to_search_hint_trailing_label_,
+ &gfx::kGdkBlack);
+ }
+}
+
gboolean LocationBarViewGtk::HandleExpose(GtkWidget* widget,
GdkEventExpose* event) {
GdkDrawable* drawable = GDK_DRAWABLE(event->window);
diff --git a/chrome/browser/gtk/location_bar_view_gtk.h b/chrome/browser/gtk/location_bar_view_gtk.h
index b5731a2..7e7d232 100644
--- a/chrome/browser/gtk/location_bar_view_gtk.h
+++ b/chrome/browser/gtk/location_bar_view_gtk.h
@@ -14,6 +14,8 @@
#include "chrome/browser/autocomplete/autocomplete_edit.h"
#include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h"
#include "chrome/browser/location_bar.h"
+#include "chrome/common/notification_observer.h"
+#include "chrome/common/notification_registrar.h"
#include "chrome/common/owned_widget_gtk.h"
#include "chrome/common/page_transition_types.h"
#include "webkit/glue/window_open_disposition.h"
@@ -28,7 +30,8 @@ class ToolbarModel;
class LocationBarViewGtk : public AutocompleteEditController,
public LocationBar,
- public LocationBarTesting {
+ public LocationBarTesting,
+ public NotificationObserver {
public:
LocationBarViewGtk(CommandUpdater* command_updater,
ToolbarModel* toolbar_model,
@@ -77,6 +80,11 @@ class LocationBarViewGtk : public AutocompleteEditController,
// Implement the LocationBarTesting interface.
virtual int PageActionVisibleCount();
+ // Implement the NotificationObserver interface.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
// Translation between a security level and the background color. Both the
// location bar and edit have to manage and match the background color.
static const GdkColor kBackgroundColorByLevel[3];
@@ -120,9 +128,13 @@ class LocationBarViewGtk : public AutocompleteEditController,
GtkWidget* info_label_align_;
GtkWidget* info_label_;
- // Tab to search widgets.
+ // Area on the left shown when in tab to search mode.
GtkWidget* tab_to_search_;
+ GtkWidget* tab_to_search_border_;
+ GtkWidget* tab_to_search_box_;
GtkWidget* tab_to_search_label_;
+
+ // Hint to user that they can tab-to-search by hitting tab.
GtkWidget* tab_to_search_hint_;
GtkWidget* tab_to_search_hint_leading_label_;
GtkWidget* tab_to_search_hint_icon_;
@@ -155,6 +167,11 @@ class LocationBarViewGtk : public AutocompleteEditController,
// different presentation (font size / color). This is used for popups.
bool popup_window_mode_;
+ // Provides colors and rendering mode.
+ GtkThemeProvider* theme_provider_;
+
+ NotificationRegistrar registrar_;
+
DISALLOW_COPY_AND_ASSIGN(LocationBarViewGtk);
};
diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc
index 6eb67007..39b9167 100644
--- a/chrome/common/gtk_util.cc
+++ b/chrome/common/gtk_util.cc
@@ -417,4 +417,11 @@ GtkWidget* AddButtonToDialog(GtkWidget* dialog, const gchar* text,
return button;
}
+void SetLabelColor(GtkWidget* label, const GdkColor* color) {
+ gtk_widget_modify_fg(label, GTK_STATE_NORMAL, color);
+ gtk_widget_modify_fg(label, GTK_STATE_ACTIVE, color);
+ gtk_widget_modify_fg(label, GTK_STATE_PRELIGHT, color);
+ gtk_widget_modify_fg(label, GTK_STATE_INSENSITIVE, color);
+}
+
} // namespace gtk_util
diff --git a/chrome/common/gtk_util.h b/chrome/common/gtk_util.h
index d24442c..b032d45 100644
--- a/chrome/common/gtk_util.h
+++ b/chrome/common/gtk_util.h
@@ -138,6 +138,9 @@ void SetWindowIcon(GtkWindow* window);
GtkWidget* AddButtonToDialog(GtkWidget* dialog, const gchar* text,
const gchar* stock_id, gint response_id);
+// Sets all the foreground color states of |label| to |color|.
+void SetLabelColor(GtkWidget* label, const GdkColor* color);
+
} // namespace gtk_util
#endif // CHROME_COMMON_GTK_UTIL_H_