diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-20 23:27:33 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-20 23:27:33 +0000 |
commit | 0679f33432fc97bfc5f51caca700a18a3723fcc8 (patch) | |
tree | af9a02cce3e133d263f843aa0f573f0afce0fea6 /chrome/browser/gtk | |
parent | d11c8e956955c9dd87e98033c7c4fa152da9fd76 (diff) | |
download | chromium_src-0679f33432fc97bfc5f51caca700a18a3723fcc8.zip chromium_src-0679f33432fc97bfc5f51caca700a18a3723fcc8.tar.gz chromium_src-0679f33432fc97bfc5f51caca700a18a3723fcc8.tar.bz2 |
GTK: theme the info bar border.
Also apply the default border for non-gtk themes.
BUG=23390
TEST=none
Review URL: http://codereview.chromium.org/304012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29587 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/infobar_container_gtk.cc | 7 | ||||
-rw-r--r-- | chrome/browser/gtk/infobar_container_gtk.h | 8 | ||||
-rw-r--r-- | chrome/browser/gtk/infobar_gtk.cc | 33 | ||||
-rw-r--r-- | chrome/browser/gtk/infobar_gtk.h | 20 |
5 files changed, 56 insertions, 14 deletions
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index edd3ae9..269be50 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -1687,7 +1687,7 @@ void BrowserWindowGtk::InitWidgets() { // |render_area_vbox_| is packed in |render_area_event_box_|. render_area_vbox_ = gtk_vbox_new(FALSE, 0); gtk_widget_set_name(render_area_vbox_, "chrome-render-area-vbox"); - infobar_container_.reset(new InfoBarContainerGtk(this)); + infobar_container_.reset(new InfoBarContainerGtk(browser_->profile())); gtk_box_pack_start(GTK_BOX(render_area_vbox_), infobar_container_->widget(), FALSE, FALSE, 0); diff --git a/chrome/browser/gtk/infobar_container_gtk.cc b/chrome/browser/gtk/infobar_container_gtk.cc index 4723903..07d7618 100644 --- a/chrome/browser/gtk/infobar_container_gtk.cc +++ b/chrome/browser/gtk/infobar_container_gtk.cc @@ -7,6 +7,7 @@ #include <gtk/gtk.h> #include "chrome/browser/browser_window.h" +#include "chrome/browser/gtk/gtk_theme_provider.h" #include "chrome/browser/gtk/infobar_gtk.h" #include "chrome/browser/tab_contents/infobar_delegate.h" #include "chrome/browser/tab_contents/tab_contents.h" @@ -63,15 +64,14 @@ void SumAnimatingBarHeight(GtkWidget* widget, gpointer userdata) { // InfoBarContainerGtk, public: ------------------------------------------------ -InfoBarContainerGtk::InfoBarContainerGtk(BrowserWindow* browser_window) - : browser_window_(browser_window), +InfoBarContainerGtk::InfoBarContainerGtk(Profile* profile) + : profile_(profile), tab_contents_(NULL), container_(gtk_vbox_new(FALSE, 0)) { gtk_widget_show(widget()); } InfoBarContainerGtk::~InfoBarContainerGtk() { - browser_window_ = NULL; ChangeTabContents(NULL); container_.Destroy(); @@ -138,6 +138,7 @@ void InfoBarContainerGtk::UpdateInfoBars() { void InfoBarContainerGtk::AddInfoBar(InfoBarDelegate* delegate, bool animate) { InfoBar* infobar = delegate->CreateInfoBar(); infobar->set_container(this); + infobar->SetThemeProvider(GtkThemeProvider::GetFrom(profile_)); gtk_box_pack_end(GTK_BOX(widget()), infobar->widget(), FALSE, FALSE, 0); if (animate) diff --git a/chrome/browser/gtk/infobar_container_gtk.h b/chrome/browser/gtk/infobar_container_gtk.h index e8a3c7c..56a7b95 100644 --- a/chrome/browser/gtk/infobar_container_gtk.h +++ b/chrome/browser/gtk/infobar_container_gtk.h @@ -9,15 +9,15 @@ #include "chrome/common/notification_registrar.h" #include "chrome/common/owned_widget_gtk.h" -class BrowserWindow; class InfoBarDelegate; +class Profile; class TabContents; typedef struct _GtkWidget GtkWidget; class InfoBarContainerGtk : public NotificationObserver { public: - explicit InfoBarContainerGtk(BrowserWindow* browser_window); + explicit InfoBarContainerGtk(Profile* profile); virtual ~InfoBarContainerGtk(); // Get the native widget. @@ -59,8 +59,8 @@ class InfoBarContainerGtk : public NotificationObserver { NotificationRegistrar registrar_; - // The BrowserView that hosts this InfoBarContainer. - BrowserWindow* browser_window_; + // The profile for the browser that hosts this InfoBarContainer. + Profile* profile_; // The TabContents for which we are currently showing InfoBars. TabContents* tab_contents_; diff --git a/chrome/browser/gtk/infobar_gtk.cc b/chrome/browser/gtk/infobar_gtk.cc index ac0a2d5..cf6ea83 100644 --- a/chrome/browser/gtk/infobar_gtk.cc +++ b/chrome/browser/gtk/infobar_gtk.cc @@ -10,9 +10,11 @@ #include "base/string_util.h" #include "chrome/browser/gtk/custom_button.h" #include "chrome/browser/gtk/gtk_chrome_link_button.h" +#include "chrome/browser/gtk/gtk_theme_provider.h" #include "chrome/browser/gtk/infobar_container_gtk.h" #include "chrome/browser/tab_contents/infobar_delegate.h" #include "chrome/common/gtk_util.h" +#include "chrome/common/notification_service.h" namespace { @@ -21,9 +23,6 @@ const double kBackgroundColorTop[3] = const double kBackgroundColorBottom[3] = {250.0 / 255.0, 230.0 / 255.0, 145.0 / 255.0}; -// Border color (the top pixel of the infobar). -const GdkColor kBorderColor = GDK_COLOR_RGB(0xbe, 0xc8, 0xd4); - // The total height of the info bar. const int kInfoBarHeight = 37; @@ -64,7 +63,8 @@ static gboolean OnBackgroundExpose(GtkWidget* widget, GdkEventExpose* event, InfoBar::InfoBar(InfoBarDelegate* delegate) : container_(NULL), - delegate_(delegate) { + delegate_(delegate), + theme_provider_(NULL) { // Create |hbox_| and pad the sides. hbox_ = gtk_hbox_new(FALSE, kElementPadding); GtkWidget* padding = gtk_alignment_new(0, 0, 1, 1); @@ -80,7 +80,7 @@ InfoBar::InfoBar(InfoBarDelegate* delegate) // The -1 on the kInfoBarHeight is to account for the border. gtk_widget_set_size_request(bg_box, -1, kInfoBarHeight - 1); - border_bin_.Own(gtk_util::CreateGtkBorderBin(bg_box, &kBorderColor, + border_bin_.Own(gtk_util::CreateGtkBorderBin(bg_box, NULL, 0, 1, 0, 0)); // Add the icon on the left, if any. @@ -148,6 +148,29 @@ void InfoBar::Closed() { Close(); } +void InfoBar::SetThemeProvider(GtkThemeProvider* theme_provider) { + if (theme_provider_) { + NOTREACHED(); + return; + } + + theme_provider_ = theme_provider; + registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, + NotificationService::AllSources()); + UpdateBorderColor(); +} + +void InfoBar::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + UpdateBorderColor(); +} + +void InfoBar::UpdateBorderColor() { + GdkColor border_color = theme_provider_->GetBorderColor(); + gtk_widget_modify_bg(border_bin_.get(), GTK_STATE_NORMAL, &border_color); +} + // static void InfoBar::OnCloseButton(GtkWidget* button, InfoBar* info_bar) { if (info_bar->delegate_) diff --git a/chrome/browser/gtk/infobar_gtk.h b/chrome/browser/gtk/infobar_gtk.h index 9fea78b..ff907c1 100644 --- a/chrome/browser/gtk/infobar_gtk.h +++ b/chrome/browser/gtk/infobar_gtk.h @@ -8,13 +8,17 @@ #include "base/basictypes.h" #include "base/scoped_ptr.h" #include "chrome/browser/gtk/slide_animator_gtk.h" +#include "chrome/common/notification_observer.h" +#include "chrome/common/notification_registrar.h" #include "chrome/common/owned_widget_gtk.h" class CustomDrawButton; +class GtkThemeProvider; class InfoBarContainerGtk; class InfoBarDelegate; -class InfoBar : public SlideAnimatorGtk::Delegate { +class InfoBar : public SlideAnimatorGtk::Delegate, + public NotificationObserver { public: explicit InfoBar(InfoBarDelegate* delegate); virtual ~InfoBar(); @@ -46,9 +50,16 @@ class InfoBar : public SlideAnimatorGtk::Delegate { // Returns true if the infobar is showing the its open or close animation. bool IsAnimating(); + void SetThemeProvider(GtkThemeProvider* theme_provider); + // SlideAnimatorGtk::Delegate implementation. virtual void Closed(); + // NotificationOPbserver implementation. + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + protected: // Removes our associated InfoBarDelegate from the associated TabContents. // (Will lead to this InfoBar being closed). @@ -72,9 +83,16 @@ class InfoBar : public SlideAnimatorGtk::Delegate { // The InfoBar's delegate. InfoBarDelegate* delegate_; + // The theme provider, used for getting border colors. + GtkThemeProvider* theme_provider_; + + NotificationRegistrar registrar_; + private: static void OnCloseButton(GtkWidget* button, InfoBar* info_bar); + void UpdateBorderColor(); + DISALLOW_COPY_AND_ASSIGN(InfoBar); }; |