OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/gtk/back_forward_button_gtk.h" | 5 #include "chrome/browser/ui/gtk/back_forward_button_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/gtk/event_utils.h" |
14 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 15 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
15 #include "chrome/browser/ui/gtk/gtk_util.h" | 16 #include "chrome/browser/ui/gtk/gtk_util.h" |
16 #include "chrome/browser/ui/gtk/menu_gtk.h" | 17 #include "chrome/browser/ui/gtk/menu_gtk.h" |
17 #include "chrome/browser/ui/toolbar/back_forward_menu_model.h" | 18 #include "chrome/browser/ui/toolbar/back_forward_menu_model.h" |
18 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
19 #include "grit/theme_resources.h" | 20 #include "grit/theme_resources.h" |
20 #include "grit/theme_resources_standard.h" | 21 #include "grit/theme_resources_standard.h" |
21 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
22 | 23 |
23 // The time in milliseconds between when the user clicks and the menu appears. | 24 // The time in milliseconds between when the user clicks and the menu appears. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 menu_.reset(new MenuGtk(this, menu_model_.get())); | 85 menu_.reset(new MenuGtk(this, menu_model_.get())); |
85 button_->SetPaintOverride(GTK_STATE_ACTIVE); | 86 button_->SetPaintOverride(GTK_STATE_ACTIVE); |
86 menu_->PopupForWidget(widget(), button, event_time); | 87 menu_->PopupForWidget(widget(), button, event_time); |
87 } | 88 } |
88 | 89 |
89 void BackForwardButtonGtk::OnClick(GtkWidget* widget) { | 90 void BackForwardButtonGtk::OnClick(GtkWidget* widget) { |
90 weak_factory_.InvalidateWeakPtrs(); | 91 weak_factory_.InvalidateWeakPtrs(); |
91 | 92 |
92 browser_->ExecuteCommandWithDisposition( | 93 browser_->ExecuteCommandWithDisposition( |
93 is_forward_ ? IDC_FORWARD : IDC_BACK, | 94 is_forward_ ? IDC_FORWARD : IDC_BACK, |
94 gtk_util::DispositionForCurrentButtonPressEvent()); | 95 event_utils::DispositionForCurrentButtonPressEvent()); |
95 } | 96 } |
96 | 97 |
97 gboolean BackForwardButtonGtk::OnButtonPress(GtkWidget* widget, | 98 gboolean BackForwardButtonGtk::OnButtonPress(GtkWidget* widget, |
98 GdkEventButton* event) { | 99 GdkEventButton* event) { |
99 if (event->button == 3) | 100 if (event->button == 3) |
100 ShowBackForwardMenu(event->button, event->time); | 101 ShowBackForwardMenu(event->button, event->time); |
101 | 102 |
102 if (event->button != 1) | 103 if (event->button != 1) |
103 return FALSE; | 104 return FALSE; |
104 | 105 |
(...skipping 19 matching lines...) Expand all Loading... |
124 int drag_min_distance; | 125 int drag_min_distance; |
125 g_object_get(settings, "gtk-dnd-drag-threshold", &drag_min_distance, NULL); | 126 g_object_get(settings, "gtk-dnd-drag-threshold", &drag_min_distance, NULL); |
126 if (event->y - y_position_of_last_press_ < drag_min_distance) | 127 if (event->y - y_position_of_last_press_ < drag_min_distance) |
127 return FALSE; | 128 return FALSE; |
128 | 129 |
129 // We will show the menu now. Cancel the delayed event. | 130 // We will show the menu now. Cancel the delayed event. |
130 weak_factory_.InvalidateWeakPtrs(); | 131 weak_factory_.InvalidateWeakPtrs(); |
131 ShowBackForwardMenu(/* button */ 1, event->time); | 132 ShowBackForwardMenu(/* button */ 1, event->time); |
132 return FALSE; | 133 return FALSE; |
133 } | 134 } |
OLD | NEW |