diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 16:44:11 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 16:44:11 +0000 |
commit | 2d933813ff07d6747177585a9f62a462d8265474 (patch) | |
tree | c14278817b6d4aad2a36cbf9d8460b1167242169 /chrome/browser | |
parent | 426daf1af6c21115dcf338e1b845ca7f6f4d316b (diff) | |
download | chromium_src-2d933813ff07d6747177585a9f62a462d8265474.zip chromium_src-2d933813ff07d6747177585a9f62a462d8265474.tar.gz chromium_src-2d933813ff07d6747177585a9f62a462d8265474.tar.bz2 |
GTK Themes: Use the GTK close button in the download shelf and popup notification.
Review URL: http://codereview.chromium.org/155939
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21394 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/gtk/blocked_popup_container_view_gtk.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/custom_button.cc | 26 | ||||
-rw-r--r-- | chrome/browser/gtk/custom_button.h | 11 | ||||
-rw-r--r-- | chrome/browser/gtk/download_shelf_gtk.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/find_bar_gtk.cc | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/find_bar_gtk.h | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/infobar_gtk.cc | 3 |
7 files changed, 29 insertions, 23 deletions
diff --git a/chrome/browser/gtk/blocked_popup_container_view_gtk.cc b/chrome/browser/gtk/blocked_popup_container_view_gtk.cc index f68a245..8ada0f0 100644 --- a/chrome/browser/gtk/blocked_popup_container_view_gtk.cc +++ b/chrome/browser/gtk/blocked_popup_container_view_gtk.cc @@ -156,7 +156,7 @@ BlockedPopupContainerViewGtk::BlockedPopupContainerViewGtk( BlockedPopupContainer* container) : model_(container), theme_provider_(GtkThemeProvider::GetFrom(container->profile())), - close_button_(CustomDrawButton::CloseButton()) { + close_button_(CustomDrawButton::CloseButton(theme_provider_)) { Init(); registrar_.Add(this, diff --git a/chrome/browser/gtk/custom_button.cc b/chrome/browser/gtk/custom_button.cc index a2902df..fab4907 100644 --- a/chrome/browser/gtk/custom_button.cc +++ b/chrome/browser/gtk/custom_button.cc @@ -100,7 +100,7 @@ CustomDrawButton::CustomDrawButton(int normal_id, int active_id, Init(); // Initialize the theme stuff with no theme_provider. - SetBrowserTheme(NULL); + SetBrowserTheme(); } CustomDrawButton::CustomDrawButton(GtkThemeProvider* theme_provider, @@ -112,7 +112,7 @@ CustomDrawButton::CustomDrawButton(GtkThemeProvider* theme_provider, gtk_stock_name_(stock_id) { Init(); - theme_provider->InitThemesFor(this); + theme_provider_->InitThemesFor(this); registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); @@ -132,10 +132,7 @@ void CustomDrawButton::Init() { void CustomDrawButton::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { DCHECK(NotificationType::BROWSER_THEME_CHANGED == type); - - GtkThemeProvider* provider = static_cast<GtkThemeProvider*>( - Source<GtkThemeProvider>(source).ptr()); - SetBrowserTheme(provider); + SetBrowserTheme(); } void CustomDrawButton::SetPaintOverride(GtkStateType state) { @@ -154,7 +151,7 @@ void CustomDrawButton::UnsetPaintOverride() { gboolean CustomDrawButton::OnCustomExpose(GtkWidget* widget, GdkEventExpose* e, CustomDrawButton* button) { - if (button->theme_provider_ && button->theme_provider_->UseGtkTheme() ) { + if (button->theme_provider_ && button->theme_provider_->UseGtkTheme()) { // Continue processing this expose event. return FALSE; } else { @@ -163,20 +160,21 @@ gboolean CustomDrawButton::OnCustomExpose(GtkWidget* widget, } // static -CustomDrawButton* CustomDrawButton::CloseButton() { - CustomDrawButton* button = - new CustomDrawButton(IDR_CLOSE_BAR, IDR_CLOSE_BAR_P, - IDR_CLOSE_BAR_H, 0, NULL); +CustomDrawButton* CustomDrawButton::CloseButton( + GtkThemeProvider* theme_provider) { + CustomDrawButton* button = new CustomDrawButton( + theme_provider, IDR_CLOSE_BAR, IDR_CLOSE_BAR_P, + IDR_CLOSE_BAR_H, 0, GTK_STOCK_CLOSE); return button; } -void CustomDrawButton::SetBrowserTheme(GtkThemeProvider* theme_provider) { - bool use_gtk = theme_provider && theme_provider->UseGtkTheme(); +void CustomDrawButton::SetBrowserTheme() { + bool use_gtk = theme_provider_ && theme_provider_->UseGtkTheme(); if (use_gtk && gtk_stock_name_) { gtk_button_set_image( GTK_BUTTON(widget_.get()), - gtk_image_new_from_stock(gtk_stock_name_, GTK_ICON_SIZE_BUTTON)); + gtk_image_new_from_stock(gtk_stock_name_, GTK_ICON_SIZE_SMALL_TOOLBAR)); gtk_widget_set_size_request(widget_.get(), -1, -1); gtk_widget_set_app_paintable(widget_.get(), FALSE); gtk_widget_set_double_buffered(widget_.get(), TRUE); diff --git a/chrome/browser/gtk/custom_button.h b/chrome/browser/gtk/custom_button.h index d92455a..ca248e8 100644 --- a/chrome/browser/gtk/custom_button.h +++ b/chrome/browser/gtk/custom_button.h @@ -118,13 +118,13 @@ class CustomDrawButton : public NotificationObserver { const NotificationSource& source, const NotificationDetails& details); - // Returns a standard close button. - static CustomDrawButton* CloseButton(); + // Returns a standard close button. Pass a |theme_provider| to use Gtk icons + // in Gtk rendering mode. + static CustomDrawButton* CloseButton(GtkThemeProvider* theme_provider); private: - // Sets the button to themed or not. Buttons that don't take a theme_provider - // can safely pass in NULL. - void SetBrowserTheme(GtkThemeProvider* theme_provider); + // Sets the button to themed or not. + void SetBrowserTheme(); // Callback for custom button expose, used to draw the custom graphics. static gboolean OnCustomExpose(GtkWidget* widget, @@ -136,6 +136,7 @@ class CustomDrawButton : public NotificationObserver { CustomDrawButtonBase button_base_; + // Our theme provider. GtkThemeProvider* theme_provider_; // The stock icon name. diff --git a/chrome/browser/gtk/download_shelf_gtk.cc b/chrome/browser/gtk/download_shelf_gtk.cc index d95cb46..8d83f84 100644 --- a/chrome/browser/gtk/download_shelf_gtk.cc +++ b/chrome/browser/gtk/download_shelf_gtk.cc @@ -88,7 +88,7 @@ DownloadShelfGtk::DownloadShelfGtk(Browser* browser, GtkWidget* parent) gtk_container_add(GTK_CONTAINER(shelf_.get()), vbox); // Create and pack the close button. - close_button_.reset(CustomDrawButton::CloseButton()); + close_button_.reset(CustomDrawButton::CloseButton(theme_provider_)); gtk_util::CenterWidgetInHBox(hbox_.get(), close_button_->widget(), true, 0); g_signal_connect(close_button_->widget(), "clicked", G_CALLBACK(OnButtonClick), this); diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc index 99ab85e..c1d4fa0 100644 --- a/chrome/browser/gtk/find_bar_gtk.cc +++ b/chrome/browser/gtk/find_bar_gtk.cc @@ -14,6 +14,7 @@ #include "chrome/browser/find_bar_controller.h" #include "chrome/browser/gtk/browser_window_gtk.h" #include "chrome/browser/gtk/custom_button.h" +#include "chrome/browser/gtk/gtk_theme_provider.h" #include "chrome/browser/gtk/nine_box.h" #include "chrome/browser/gtk/slide_animator_gtk.h" #include "chrome/browser/gtk/tab_contents_container_gtk.h" @@ -85,6 +86,7 @@ const NineBox* GetDialogBorder() { FindBarGtk::FindBarGtk(Browser* browser) : browser_(browser), window_(static_cast<BrowserWindowGtk*>(browser->window())), + theme_provider_(GtkThemeProvider::GetFrom(browser->profile())), container_shaped_(false), ignore_changed_signal_(false) { InitWidgets(); @@ -154,7 +156,7 @@ void FindBarGtk::InitWidgets() { gtk_fixed_put(GTK_FIXED(widget()), slide_widget(), 0, 0); gtk_widget_set_size_request(widget(), -1, 0); - close_button_.reset(CustomDrawButton::CloseButton()); + close_button_.reset(CustomDrawButton::CloseButton(NULL)); gtk_util::CenterWidgetInHBox(hbox, close_button_->widget(), true, kCloseButtonPaddingLeft); g_signal_connect(G_OBJECT(close_button_->widget()), "clicked", diff --git a/chrome/browser/gtk/find_bar_gtk.h b/chrome/browser/gtk/find_bar_gtk.h index fea1b4f..81de33a 100644 --- a/chrome/browser/gtk/find_bar_gtk.h +++ b/chrome/browser/gtk/find_bar_gtk.h @@ -17,6 +17,7 @@ class Browser; class BrowserWindowGtk; class CustomDrawButton; class FindBarController; +class GtkThemeProvider; class NineBox; class SlideAnimatorGtk; class TabContentsContainerGtk; @@ -116,6 +117,9 @@ class FindBarGtk : public FindBar, Browser* browser_; BrowserWindowGtk* window_; + // Provides colors and information about GTK. + GtkThemeProvider* theme_provider_; + // GtkFixed containing the find bar widgets. OwnedWidgetGtk fixed_; diff --git a/chrome/browser/gtk/infobar_gtk.cc b/chrome/browser/gtk/infobar_gtk.cc index c97f65b..06c549c 100644 --- a/chrome/browser/gtk/infobar_gtk.cc +++ b/chrome/browser/gtk/infobar_gtk.cc @@ -92,7 +92,8 @@ InfoBar::InfoBar(InfoBarDelegate* delegate) gtk_box_pack_start(GTK_BOX(hbox_), image, FALSE, FALSE, 0); } - close_button_.reset(CustomDrawButton::CloseButton()); + // TODO(erg): GTK theme the info bar. + close_button_.reset(CustomDrawButton::CloseButton(NULL)); gtk_util::CenterWidgetInHBox(hbox_, close_button_->widget(), true, 0); g_signal_connect(close_button_->widget(), "clicked", G_CALLBACK(OnCloseButton), this); |