Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: chrome/browser/gtk/back_forward_button_gtk.cc

Issue 3029032: Cleanup: Rename gtk button state names to (a) match other platforms and (b) n... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/gtk/browser_toolbar_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/back_forward_button_gtk.h" 5 #include "chrome/browser/gtk/back_forward_button_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/menus/menu_model.h" 10 #include "app/menus/menu_model.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "chrome/app/chrome_dll_resource.h" 12 #include "chrome/app/chrome_dll_resource.h"
13 #include "chrome/browser/back_forward_menu_model.h" 13 #include "chrome/browser/back_forward_menu_model.h"
14 #include "chrome/browser/browser.h" 14 #include "chrome/browser/browser.h"
15 #include "chrome/browser/gtk/gtk_theme_provider.h" 15 #include "chrome/browser/gtk/gtk_theme_provider.h"
16 #include "chrome/browser/gtk/gtk_util.h" 16 #include "chrome/browser/gtk/gtk_util.h"
17 #include "chrome/browser/gtk/menu_gtk.h" 17 #include "chrome/browser/gtk/menu_gtk.h"
18 #include "chrome/browser/profile.h" 18 #include "chrome/browser/profile.h"
19 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
20 #include "grit/theme_resources.h" 20 #include "grit/theme_resources.h"
21 21
22 // The time in milliseconds between when the user clicks and the menu appears. 22 // The time in milliseconds between when the user clicks and the menu appears.
23 static const int kMenuTimerDelay = 500; 23 static const int kMenuTimerDelay = 500;
24 24
25 BackForwardButtonGtk::BackForwardButtonGtk(Browser* browser, bool is_forward) 25 BackForwardButtonGtk::BackForwardButtonGtk(Browser* browser, bool is_forward)
26 : browser_(browser), 26 : browser_(browser),
27 is_forward_(is_forward), 27 is_forward_(is_forward),
28 show_menu_factory_(this) { 28 show_menu_factory_(this) {
29 int normal, active, highlight, depressed, background, tooltip; 29 int normal, pushed, hover, disabled, background, tooltip;
30 const char* stock; 30 const char* stock;
31 if (is_forward) { 31 if (is_forward) {
32 normal = IDR_FORWARD; 32 normal = IDR_FORWARD;
33 active = IDR_FORWARD_P; 33 pushed = IDR_FORWARD_P;
34 highlight = IDR_FORWARD_H; 34 hover = IDR_FORWARD_H;
35 depressed = IDR_FORWARD_D; 35 disabled = IDR_FORWARD_D;
36 background = IDR_FORWARD_MASK; 36 background = IDR_FORWARD_MASK;
37 tooltip = IDS_TOOLTIP_FORWARD; 37 tooltip = IDS_TOOLTIP_FORWARD;
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 active = IDR_BACK_P; 41 pushed = IDR_BACK_P;
42 highlight = IDR_BACK_H; 42 hover = IDR_BACK_H;
43 depressed = IDR_BACK_D; 43 disabled = IDR_BACK_D;
44 background = IDR_BACK_MASK; 44 background = IDR_BACK_MASK;
45 tooltip = IDS_TOOLTIP_BACK; 45 tooltip = IDS_TOOLTIP_BACK;
46 stock = GTK_STOCK_GO_BACK; 46 stock = GTK_STOCK_GO_BACK;
47 } 47 }
48 button_.reset(new CustomDrawButton( 48 button_.reset(new CustomDrawButton(
49 GtkThemeProvider::GetFrom(browser_->profile()), 49 GtkThemeProvider::GetFrom(browser_->profile()),
50 normal, active, highlight, depressed, background, stock, 50 normal, pushed, hover, disabled, background, stock,
51 GTK_ICON_SIZE_SMALL_TOOLBAR)); 51 GTK_ICON_SIZE_SMALL_TOOLBAR));
52 gtk_widget_set_tooltip_text(widget(), 52 gtk_widget_set_tooltip_text(widget(),
53 l10n_util::GetStringUTF8(tooltip).c_str()); 53 l10n_util::GetStringUTF8(tooltip).c_str());
54 menu_model_.reset( 54 menu_model_.reset(new BackForwardMenuModel(browser, is_forward ?
55 new BackForwardMenuModel(browser, 55 BackForwardMenuModel::FORWARD_MENU :
56 is_forward ? 56 BackForwardMenuModel::BACKWARD_MENU));
57 BackForwardMenuModel::FORWARD_MENU :
58 BackForwardMenuModel::BACKWARD_MENU));
59 57
60 g_signal_connect(widget(), "clicked", 58 g_signal_connect(widget(), "clicked",
61 G_CALLBACK(OnClickThunk), this); 59 G_CALLBACK(OnClickThunk), this);
62 g_signal_connect(widget(), "button-press-event", 60 g_signal_connect(widget(), "button-press-event",
63 G_CALLBACK(OnButtonPressThunk), this); 61 G_CALLBACK(OnButtonPressThunk), this);
64 gtk_widget_add_events(widget(), GDK_POINTER_MOTION_MASK); 62 gtk_widget_add_events(widget(), GDK_POINTER_MOTION_MASK);
65 g_signal_connect(widget(), "motion-notify-event", 63 g_signal_connect(widget(), "motion-notify-event",
66 G_CALLBACK(OnMouseMoveThunk), this); 64 G_CALLBACK(OnMouseMoveThunk), this);
67 65
68 // Popup the menu as left-aligned relative to this widget rather than the 66 // Popup the menu as left-aligned relative to this widget rather than the
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 g_object_get(settings, "gtk-dnd-drag-threshold", &drag_min_distance, NULL); 130 g_object_get(settings, "gtk-dnd-drag-threshold", &drag_min_distance, NULL);
133 if (event->y - y_position_of_last_press_ < drag_min_distance) 131 if (event->y - y_position_of_last_press_ < drag_min_distance)
134 return FALSE; 132 return FALSE;
135 133
136 // We will show the menu now. Cancel the delayed event. 134 // We will show the menu now. Cancel the delayed event.
137 show_menu_factory_.RevokeAll(); 135 show_menu_factory_.RevokeAll();
138 ShowBackForwardMenu(); 136 ShowBackForwardMenu();
139 return FALSE; 137 return FALSE;
140 } 138 }
141 139
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/gtk/browser_toolbar_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698