diff options
-rw-r--r-- | chrome/browser/gtk/browser_toolbar_gtk.cc | 27 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_toolbar_gtk.h | 15 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_theme_provider.cc | 2 |
3 files changed, 33 insertions, 11 deletions
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc index 453fea6..a571778 100644 --- a/chrome/browser/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/gtk/browser_toolbar_gtk.cc @@ -31,6 +31,7 @@ #include "chrome/browser/profile.h" #include "chrome/common/gtk_util.h" #include "chrome/common/notification_details.h" +#include "chrome/common/notification_service.h" #include "chrome/common/notification_type.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" @@ -76,6 +77,10 @@ BrowserToolbarGtk::BrowserToolbarGtk(Browser* browser, BrowserWindowGtk* window) browser_->command_updater()->AddCommandObserver(IDC_HOME, this); browser_->command_updater()->AddCommandObserver(IDC_STAR, this); + registrar_.Add(this, + NotificationType::BROWSER_THEME_CHANGED, + NotificationService::AllSources()); + InitNineBox(); } @@ -155,9 +160,12 @@ void BrowserToolbarGtk::Init(Profile* profile, // Group the menu buttons together in an hbox. GtkWidget* menus_hbox_ = gtk_hbox_new(FALSE, 0); - GtkWidget* page_menu = BuildToolbarMenuButton(IDR_MENU_PAGE, + GtkWidget* page_menu = BuildToolbarMenuButton( l10n_util::GetStringUTF8(IDS_PAGEMENU_TOOLTIP), &page_menu_button_); + page_menu_image_ = gtk_image_new_from_pixbuf( + theme_provider_->GetRTLEnabledPixbufNamed(IDR_MENU_PAGE)); + gtk_container_add(GTK_CONTAINER(page_menu), page_menu_image_); page_menu_.reset(new MenuGtk(this, GetStandardPageMenu(), accel_group_)); g_signal_connect(page_menu_->widget(), "motion-notify-event", G_CALLBACK(OnPageAppMenuMouseMotion), this); @@ -165,10 +173,13 @@ void BrowserToolbarGtk::Init(Profile* profile, G_CALLBACK(OnPageAppMenuMoveCurrent), this); gtk_box_pack_start(GTK_BOX(menus_hbox_), page_menu, FALSE, FALSE, 0); - GtkWidget* chrome_menu = BuildToolbarMenuButton(IDR_MENU_CHROME, + GtkWidget* chrome_menu = BuildToolbarMenuButton( l10n_util::GetStringFUTF8(IDS_APPMENU_TOOLTIP, WideToUTF16(l10n_util::GetString(IDS_PRODUCT_NAME))), &app_menu_button_); + app_menu_image_ = gtk_image_new_from_pixbuf( + theme_provider_->GetRTLEnabledPixbufNamed(IDR_MENU_CHROME)); + gtk_container_add(GTK_CONTAINER(chrome_menu), app_menu_image_); app_menu_.reset(new MenuGtk(this, GetStandardAppMenu(), accel_group_)); g_signal_connect(app_menu_->widget(), "motion-notify-event", G_CALLBACK(OnPageAppMenuMouseMotion), this); @@ -272,6 +283,14 @@ void BrowserToolbarGtk::Observe(NotificationType type, gtk_widget_hide(home_->widget()); } } + } else if (type == NotificationType::BROWSER_THEME_CHANGED) { + // Update the menu button images. + gtk_image_set_from_pixbuf(GTK_IMAGE(page_menu_image_), + theme_provider_->GetRTLEnabledPixbufNamed(IDR_MENU_PAGE)); + gtk_image_set_from_pixbuf(GTK_IMAGE(app_menu_image_), + theme_provider_->GetRTLEnabledPixbufNamed(IDR_MENU_CHROME)); + } else { + NOTREACHED(); } } @@ -342,19 +361,15 @@ ToolbarStarToggleGtk* BrowserToolbarGtk::BuildStarButton( } GtkWidget* BrowserToolbarGtk::BuildToolbarMenuButton( - int icon_id, const std::string& localized_tooltip, OwnedWidgetGtk* owner) { GtkWidget* button = theme_provider_->BuildChromeButton(); owner->Own(button); - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); // TODO(erg): This was under conditional for gtk, but after playing around // with not having it under conditional, I actually think this is correct // instead. Investigate more later. gtk_container_set_border_width(GTK_CONTAINER(button), 2); - gtk_container_add(GTK_CONTAINER(button), - gtk_image_new_from_pixbuf(rb.GetPixbufNamed(icon_id))); gtk_widget_set_tooltip_text(button, localized_tooltip.c_str()); g_signal_connect(button, "button-press-event", diff --git a/chrome/browser/gtk/browser_toolbar_gtk.h b/chrome/browser/gtk/browser_toolbar_gtk.h index 9aeee9a..ab86f41 100644 --- a/chrome/browser/gtk/browser_toolbar_gtk.h +++ b/chrome/browser/gtk/browser_toolbar_gtk.h @@ -12,6 +12,8 @@ #include "chrome/browser/autocomplete/autocomplete_popup_view.h" #include "chrome/browser/command_updater.h" #include "chrome/browser/gtk/menu_gtk.h" +#include "chrome/common/notification_observer.h" +#include "chrome/common/notification_registrar.h" #include "chrome/common/pref_member.h" class BackForwardButtonGtk; @@ -99,10 +101,8 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver, // Create a menu for the toolbar given the icon id and tooltip. Returns the // widget created. - GtkWidget* BuildToolbarMenuButton( - int icon_id, - const std::string& localized_tooltip, - OwnedWidgetGtk* owner); + GtkWidget* BuildToolbarMenuButton(const std::string& localized_tooltip, + OwnedWidgetGtk* owner); // Connect signals for dragging a url onto the home button. void SetUpDragForHomeButton(); @@ -174,6 +174,11 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver, scoped_ptr<GoButtonGtk> go_; OwnedWidgetGtk page_menu_button_, app_menu_button_; + // Keep a pointer to the menu button images because we change them when + // the theme changes. + GtkWidget* page_menu_image_; + GtkWidget* app_menu_image_; + // The model that contains the security level, text, icon to display... ToolbarModel* model_; @@ -192,6 +197,8 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver, // The event state the last time we observed a button release event. int last_release_event_flags_; + NotificationRegistrar registrar_; + DISALLOW_COPY_AND_ASSIGN(BrowserToolbarGtk); }; diff --git a/chrome/browser/gtk/gtk_theme_provider.cc b/chrome/browser/gtk/gtk_theme_provider.cc index 91136db..81565d1 100644 --- a/chrome/browser/gtk/gtk_theme_provider.cc +++ b/chrome/browser/gtk/gtk_theme_provider.cc @@ -128,7 +128,7 @@ void GtkThemeProvider::LoadThemePrefs() { void GtkThemeProvider::NotifyThemeChanged() { BrowserThemeProvider::NotifyThemeChanged(); - // Notify all constructored GtkChromeButtons of their new rendering mode: + // Notify all GtkChromeButtons of their new rendering mode: for (std::vector<GtkWidget*>::iterator it = chrome_buttons_.begin(); it != chrome_buttons_.end(); ++it) { gtk_chrome_button_set_use_gtk_rendering( |