| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/gtk/browser_toolbar_gtk.h" | 5 #include "chrome/browser/gtk/browser_toolbar_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #include <X11/XF86keysym.h> | 9 #include <X11/XF86keysym.h> |
| 10 | 10 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 gtk_box_pack_start(GTK_BOX(back_forward_hbox_), forward_->widget(), FALSE, | 168 gtk_box_pack_start(GTK_BOX(back_forward_hbox_), forward_->widget(), FALSE, |
| 169 FALSE, 0); | 169 FALSE, 0); |
| 170 | 170 |
| 171 gtk_box_pack_start(GTK_BOX(toolbar_left_), back_forward_hbox_, FALSE, | 171 gtk_box_pack_start(GTK_BOX(toolbar_left_), back_forward_hbox_, FALSE, |
| 172 FALSE, kToolbarWidgetSpacing); | 172 FALSE, kToolbarWidgetSpacing); |
| 173 | 173 |
| 174 reload_.reset(new ReloadButtonGtk(location_bar_.get(), browser_)); | 174 reload_.reset(new ReloadButtonGtk(location_bar_.get(), browser_)); |
| 175 gtk_box_pack_start(GTK_BOX(toolbar_left_), reload_->widget(), FALSE, FALSE, | 175 gtk_box_pack_start(GTK_BOX(toolbar_left_), reload_->widget(), FALSE, FALSE, |
| 176 0); | 176 0); |
| 177 | 177 |
| 178 home_.reset(BuildToolbarButton(IDR_HOME, IDR_HOME_P, IDR_HOME_H, 0, | 178 home_.reset(new CustomDrawButton(GtkThemeProvider::GetFrom(profile_), |
| 179 IDR_BUTTON_MASK, | 179 IDR_HOME, IDR_HOME_P, IDR_HOME_H, 0, |
| 180 l10n_util::GetStringUTF8(IDS_TOOLTIP_HOME), | 180 IDR_BUTTON_MASK, GTK_STOCK_HOME, |
| 181 GTK_STOCK_HOME, kToolbarWidgetSpacing)); | 181 GTK_ICON_SIZE_SMALL_TOOLBAR)); |
| 182 gtk_widget_set_tooltip_text(home_->widget(), |
| 183 l10n_util::GetStringUTF8(IDS_TOOLTIP_HOME).c_str()); |
| 184 g_signal_connect(home_->widget(), "clicked", |
| 185 G_CALLBACK(OnButtonClickThunk), this); |
| 186 gtk_box_pack_start(GTK_BOX(toolbar_left_), home_->widget(), FALSE, FALSE, |
| 187 kToolbarWidgetSpacing); |
| 182 gtk_util::SetButtonTriggersNavigation(home_->widget()); | 188 gtk_util::SetButtonTriggersNavigation(home_->widget()); |
| 183 | 189 |
| 184 gtk_box_pack_start(GTK_BOX(toolbar_), toolbar_left_, FALSE, FALSE, 0); | 190 gtk_box_pack_start(GTK_BOX(toolbar_), toolbar_left_, FALSE, FALSE, 0); |
| 185 | 191 |
| 186 location_hbox_ = gtk_hbox_new(FALSE, 0); | 192 location_hbox_ = gtk_hbox_new(FALSE, 0); |
| 187 location_bar_->Init(ShouldOnlyShowLocation()); | 193 location_bar_->Init(ShouldOnlyShowLocation()); |
| 188 gtk_box_pack_start(GTK_BOX(location_hbox_), location_bar_->widget(), TRUE, | 194 gtk_box_pack_start(GTK_BOX(location_hbox_), location_bar_->widget(), TRUE, |
| 189 TRUE, 0); | 195 TRUE, 0); |
| 190 | 196 |
| 191 g_signal_connect(location_hbox_, "expose-event", | 197 g_signal_connect(location_hbox_, "expose-event", |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 void BrowserToolbarGtk::UpdateTabContents(TabContents* contents, | 425 void BrowserToolbarGtk::UpdateTabContents(TabContents* contents, |
| 420 bool should_restore_state) { | 426 bool should_restore_state) { |
| 421 location_bar_->Update(should_restore_state ? contents : NULL); | 427 location_bar_->Update(should_restore_state ? contents : NULL); |
| 422 | 428 |
| 423 if (actions_toolbar_.get()) | 429 if (actions_toolbar_.get()) |
| 424 actions_toolbar_->Update(); | 430 actions_toolbar_->Update(); |
| 425 } | 431 } |
| 426 | 432 |
| 427 // BrowserToolbarGtk, private -------------------------------------------------- | 433 // BrowserToolbarGtk, private -------------------------------------------------- |
| 428 | 434 |
| 429 CustomDrawButton* BrowserToolbarGtk::BuildToolbarButton( | |
| 430 int normal_id, int active_id, int highlight_id, int depressed_id, | |
| 431 int background_id, const std::string& localized_tooltip, | |
| 432 const char* stock_id, int spacing) { | |
| 433 CustomDrawButton* button = new CustomDrawButton( | |
| 434 GtkThemeProvider::GetFrom(profile_), | |
| 435 normal_id, active_id, highlight_id, depressed_id, background_id, stock_id, | |
| 436 GTK_ICON_SIZE_SMALL_TOOLBAR); | |
| 437 | |
| 438 gtk_widget_set_tooltip_text(button->widget(), | |
| 439 localized_tooltip.c_str()); | |
| 440 g_signal_connect(button->widget(), "clicked", | |
| 441 G_CALLBACK(OnButtonClickThunk), this); | |
| 442 | |
| 443 gtk_box_pack_start(GTK_BOX(toolbar_left_), button->widget(), FALSE, FALSE, | |
| 444 spacing); | |
| 445 return button; | |
| 446 } | |
| 447 | |
| 448 GtkWidget* BrowserToolbarGtk::BuildToolbarMenuButton( | 435 GtkWidget* BrowserToolbarGtk::BuildToolbarMenuButton( |
| 449 const std::string& localized_tooltip, | 436 const std::string& localized_tooltip, |
| 450 OwnedWidgetGtk* owner) { | 437 OwnedWidgetGtk* owner) { |
| 451 GtkWidget* button = theme_provider_->BuildChromeButton(); | 438 GtkWidget* button = theme_provider_->BuildChromeButton(); |
| 452 owner->Own(button); | 439 owner->Own(button); |
| 453 | 440 |
| 454 gtk_widget_set_tooltip_text(button, localized_tooltip.c_str()); | 441 gtk_widget_set_tooltip_text(button, localized_tooltip.c_str()); |
| 455 g_signal_connect(button, "button-press-event", | 442 g_signal_connect(button, "button-press-event", |
| 456 G_CALLBACK(OnMenuButtonPressEventThunk), this); | 443 G_CALLBACK(OnMenuButtonPressEventThunk), this); |
| 457 GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); | 444 GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 | 729 |
| 743 return FALSE; | 730 return FALSE; |
| 744 } | 731 } |
| 745 | 732 |
| 746 bool BrowserToolbarGtk::UpgradeAnimationIsFaded() { | 733 bool BrowserToolbarGtk::UpgradeAnimationIsFaded() { |
| 747 return upgrade_reminder_animation_.cycles_remaining() > 0 && | 734 return upgrade_reminder_animation_.cycles_remaining() > 0 && |
| 748 // This funky looking math makes the badge throb for 2 seconds once | 735 // This funky looking math makes the badge throb for 2 seconds once |
| 749 // every 8 seconds. | 736 // every 8 seconds. |
| 750 ((upgrade_reminder_animation_.cycles_remaining() - 1) / 2) % 4 == 0; | 737 ((upgrade_reminder_animation_.cycles_remaining() - 1) / 2) % 4 == 0; |
| 751 } | 738 } |
| OLD | NEW |