| 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/message_loop.h" | 10 #include "base/message_loop.h" |
| 10 #include "base/bind.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/gtk_theme_service.h" | |
| 15 #include "chrome/browser/ui/gtk/gtk_util.h" | 14 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 16 #include "chrome/browser/ui/gtk/menu_gtk.h" | 15 #include "chrome/browser/ui/gtk/menu_gtk.h" |
| 16 #include "chrome/browser/ui/gtk/theme_service_gtk.h" |
| 17 #include "chrome/browser/ui/toolbar/back_forward_menu_model.h" | 17 #include "chrome/browser/ui/toolbar/back_forward_menu_model.h" |
| 18 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 19 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
| 20 #include "grit/theme_resources_standard.h" | 20 #include "grit/theme_resources_standard.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 22 | 22 |
| 23 // The time in milliseconds between when the user clicks and the menu appears. | 23 // The time in milliseconds between when the user clicks and the menu appears. |
| 24 static const int kMenuTimerDelay = 500; | 24 static const int kMenuTimerDelay = 500; |
| 25 | 25 |
| 26 BackForwardButtonGtk::BackForwardButtonGtk(Browser* browser, bool is_forward) | 26 BackForwardButtonGtk::BackForwardButtonGtk(Browser* browser, bool is_forward) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 38 stock = GTK_STOCK_GO_FORWARD; | 38 stock = GTK_STOCK_GO_FORWARD; |
| 39 } else { | 39 } else { |
| 40 normal = IDR_BACK; | 40 normal = IDR_BACK; |
| 41 pushed = IDR_BACK_P; | 41 pushed = IDR_BACK_P; |
| 42 hover = IDR_BACK_H; | 42 hover = IDR_BACK_H; |
| 43 disabled = IDR_BACK_D; | 43 disabled = IDR_BACK_D; |
| 44 tooltip = IDS_TOOLTIP_BACK; | 44 tooltip = IDS_TOOLTIP_BACK; |
| 45 stock = GTK_STOCK_GO_BACK; | 45 stock = GTK_STOCK_GO_BACK; |
| 46 } | 46 } |
| 47 button_.reset(new CustomDrawButton( | 47 button_.reset(new CustomDrawButton( |
| 48 GtkThemeService::GetFrom(browser_->profile()), | 48 ThemeServiceGtk::GetFrom(browser_->profile()), |
| 49 normal, pushed, hover, disabled, stock, GTK_ICON_SIZE_SMALL_TOOLBAR)); | 49 normal, pushed, hover, disabled, stock, GTK_ICON_SIZE_SMALL_TOOLBAR)); |
| 50 gtk_widget_set_tooltip_text(widget(), | 50 gtk_widget_set_tooltip_text(widget(), |
| 51 l10n_util::GetStringUTF8(tooltip).c_str()); | 51 l10n_util::GetStringUTF8(tooltip).c_str()); |
| 52 menu_model_.reset(new BackForwardMenuModel(browser, is_forward ? | 52 menu_model_.reset(new BackForwardMenuModel(browser, is_forward ? |
| 53 BackForwardMenuModel::FORWARD_MENU : | 53 BackForwardMenuModel::FORWARD_MENU : |
| 54 BackForwardMenuModel::BACKWARD_MENU)); | 54 BackForwardMenuModel::BACKWARD_MENU)); |
| 55 | 55 |
| 56 g_signal_connect(widget(), "clicked", | 56 g_signal_connect(widget(), "clicked", |
| 57 G_CALLBACK(OnClickThunk), this); | 57 G_CALLBACK(OnClickThunk), this); |
| 58 g_signal_connect(widget(), "button-press-event", | 58 g_signal_connect(widget(), "button-press-event", |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 int drag_min_distance; | 124 int drag_min_distance; |
| 125 g_object_get(settings, "gtk-dnd-drag-threshold", &drag_min_distance, NULL); | 125 g_object_get(settings, "gtk-dnd-drag-threshold", &drag_min_distance, NULL); |
| 126 if (event->y - y_position_of_last_press_ < drag_min_distance) | 126 if (event->y - y_position_of_last_press_ < drag_min_distance) |
| 127 return FALSE; | 127 return FALSE; |
| 128 | 128 |
| 129 // We will show the menu now. Cancel the delayed event. | 129 // We will show the menu now. Cancel the delayed event. |
| 130 weak_factory_.InvalidateWeakPtrs(); | 130 weak_factory_.InvalidateWeakPtrs(); |
| 131 ShowBackForwardMenu(/* button */ 1, event->time); | 131 ShowBackForwardMenu(/* button */ 1, event->time); |
| 132 return FALSE; | 132 return FALSE; |
| 133 } | 133 } |
| OLD | NEW |