| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <X11/XF86keysym.h> | 8 #include <X11/XF86keysym.h> |
| 9 | 9 |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // we still hold on to the original, and thus own a reference to the group. | 165 // we still hold on to the original, and thus own a reference to the group. |
| 166 accel_group_ = gtk_accel_group_new(); | 166 accel_group_ = gtk_accel_group_new(); |
| 167 gtk_window_add_accel_group(top_level_window, accel_group_); | 167 gtk_window_add_accel_group(top_level_window, accel_group_); |
| 168 | 168 |
| 169 // Group back and forward into an hbox so there's no spacing between them. | 169 // Group back and forward into an hbox so there's no spacing between them. |
| 170 GtkWidget* back_forward_hbox_ = gtk_hbox_new(FALSE, 0); | 170 GtkWidget* back_forward_hbox_ = gtk_hbox_new(FALSE, 0); |
| 171 | 171 |
| 172 back_.reset(new BackForwardButtonGtk(browser_, false)); | 172 back_.reset(new BackForwardButtonGtk(browser_, false)); |
| 173 gtk_box_pack_start(GTK_BOX(back_forward_hbox_), back_->widget(), FALSE, | 173 gtk_box_pack_start(GTK_BOX(back_forward_hbox_), back_->widget(), FALSE, |
| 174 FALSE, 0); | 174 FALSE, 0); |
| 175 g_signal_connect(back_->widget(), "clicked", |
| 176 G_CALLBACK(OnButtonClick), this); |
| 175 | 177 |
| 176 forward_.reset(new BackForwardButtonGtk(browser_, true)); | 178 forward_.reset(new BackForwardButtonGtk(browser_, true)); |
| 177 gtk_box_pack_start(GTK_BOX(back_forward_hbox_), forward_->widget(), FALSE, | 179 gtk_box_pack_start(GTK_BOX(back_forward_hbox_), forward_->widget(), FALSE, |
| 178 FALSE, 0); | 180 FALSE, 0); |
| 181 g_signal_connect(forward_->widget(), "clicked", |
| 182 G_CALLBACK(OnButtonClick), this); |
| 179 gtk_box_pack_start(GTK_BOX(toolbar_), back_forward_hbox_, FALSE, FALSE, 0); | 183 gtk_box_pack_start(GTK_BOX(toolbar_), back_forward_hbox_, FALSE, FALSE, 0); |
| 180 | 184 |
| 181 reload_.reset(BuildToolbarButton(IDR_RELOAD, IDR_RELOAD_P, IDR_RELOAD_H, 0, | 185 reload_.reset(BuildToolbarButton(IDR_RELOAD, IDR_RELOAD_P, IDR_RELOAD_H, 0, |
| 182 l10n_util::GetStringUTF8(IDS_TOOLTIP_RELOAD), | 186 l10n_util::GetStringUTF8(IDS_TOOLTIP_RELOAD), |
| 183 GTK_STOCK_REFRESH)); | 187 GTK_STOCK_REFRESH)); |
| 184 | 188 |
| 185 home_.reset(BuildToolbarButton(IDR_HOME, IDR_HOME_P, IDR_HOME_H, 0, | 189 home_.reset(BuildToolbarButton(IDR_HOME, IDR_HOME_P, IDR_HOME_H, 0, |
| 186 l10n_util::GetStringUTF8(IDS_TOOLTIP_HOME), | 190 l10n_util::GetStringUTF8(IDS_TOOLTIP_HOME), |
| 187 GTK_STOCK_HOME)); | 191 GTK_STOCK_HOME)); |
| 188 gtk_util::SetButtonTriggersNavigation(home_->widget()); | 192 gtk_util::SetButtonTriggersNavigation(home_->widget()); |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 | 612 |
| 609 g_object_unref(our_style); | 613 g_object_unref(our_style); |
| 610 } | 614 } |
| 611 | 615 |
| 612 return FALSE; | 616 return FALSE; |
| 613 } | 617 } |
| 614 | 618 |
| 615 // static | 619 // static |
| 616 void BrowserToolbarGtk::OnButtonClick(GtkWidget* button, | 620 void BrowserToolbarGtk::OnButtonClick(GtkWidget* button, |
| 617 BrowserToolbarGtk* toolbar) { | 621 BrowserToolbarGtk* toolbar) { |
| 622 if ((button == toolbar->back_->widget()) || |
| 623 (button == toolbar->forward_->widget())) { |
| 624 toolbar->location_bar_->Revert(); |
| 625 return; |
| 626 } |
| 627 |
| 618 int tag = -1; | 628 int tag = -1; |
| 619 if (button == toolbar->reload_->widget()) | 629 if (button == toolbar->reload_->widget()) { |
| 620 tag = IDC_RELOAD; | 630 tag = IDC_RELOAD; |
| 621 else if (toolbar->home_.get() && button == toolbar->home_->widget()) | 631 toolbar->location_bar_->Revert(); |
| 632 } else if (toolbar->home_.get() && button == toolbar->home_->widget()) { |
| 622 tag = IDC_HOME; | 633 tag = IDC_HOME; |
| 623 else if (button == toolbar->star_->widget()) | 634 } else if (button == toolbar->star_->widget()) { |
| 624 tag = IDC_STAR; | 635 tag = IDC_STAR; |
| 636 } |
| 625 | 637 |
| 626 DCHECK_NE(tag, -1) << "Unexpected button click callback"; | 638 DCHECK_NE(tag, -1) << "Unexpected button click callback"; |
| 627 toolbar->browser_->ExecuteCommandWithDisposition(tag, | 639 toolbar->browser_->ExecuteCommandWithDisposition(tag, |
| 628 event_utils::DispositionFromEventFlags( | 640 event_utils::DispositionFromEventFlags( |
| 629 toolbar->last_release_event_flags_)); | 641 toolbar->last_release_event_flags_)); |
| 630 } | 642 } |
| 631 | 643 |
| 632 // static | 644 // static |
| 633 gboolean BrowserToolbarGtk::OnButtonRelease(GtkWidget* button, | 645 gboolean BrowserToolbarGtk::OnButtonRelease(GtkWidget* button, |
| 634 GdkEventButton* event, | 646 GdkEventButton* event, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 g_signal_stop_emission_by_name(menu, "move-current"); | 731 g_signal_stop_emission_by_name(menu, "move-current"); |
| 720 default: | 732 default: |
| 721 break; | 733 break; |
| 722 } | 734 } |
| 723 } | 735 } |
| 724 | 736 |
| 725 bool BrowserToolbarGtk::ShouldOnlyShowLocation() const { | 737 bool BrowserToolbarGtk::ShouldOnlyShowLocation() const { |
| 726 // If we're a popup window, only show the location bar (omnibox). | 738 // If we're a popup window, only show the location bar (omnibox). |
| 727 return browser_->type() != Browser::TYPE_NORMAL; | 739 return browser_->type() != Browser::TYPE_NORMAL; |
| 728 } | 740 } |
| OLD | NEW |