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

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

Issue 149432: Add button tinting to the toolbar buttons. (Closed)
Patch Set: Created 11 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
« no previous file with comments | « no previous file | chrome/browser/gtk/browser_toolbar_gtk.cc » ('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 "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "chrome/app/chrome_dll_resource.h" 11 #include "chrome/app/chrome_dll_resource.h"
12 #include "chrome/browser/browser.h" 12 #include "chrome/browser/browser.h"
13 #include "chrome/browser/gtk/back_forward_menu_model_gtk.h" 13 #include "chrome/browser/gtk/back_forward_menu_model_gtk.h"
14 #include "chrome/browser/gtk/menu_gtk.h" 14 #include "chrome/browser/gtk/menu_gtk.h"
15 #include "chrome/browser/profile.h"
15 #include "chrome/common/gtk_util.h" 16 #include "chrome/common/gtk_util.h"
16 #include "grit/generated_resources.h" 17 #include "grit/generated_resources.h"
17 #include "grit/theme_resources.h" 18 #include "grit/theme_resources.h"
18 19
19 // The time in milliseconds between when the user clicks and the menu appears. 20 // The time in milliseconds between when the user clicks and the menu appears.
20 static const int kMenuTimerDelay = 500; 21 static const int kMenuTimerDelay = 500;
21 22
22 BackForwardButtonGtk::BackForwardButtonGtk(Browser* browser, bool is_forward) 23 BackForwardButtonGtk::BackForwardButtonGtk(Browser* browser, bool is_forward)
23 : browser_(browser), 24 : browser_(browser),
24 is_forward_(is_forward), 25 is_forward_(is_forward),
25 last_release_event_flags_(0), 26 last_release_event_flags_(0),
26 show_menu_factory_(this) { 27 show_menu_factory_(this) {
27 int normal, active, highlight, depressed, tooltip; 28 int normal, active, highlight, depressed, tooltip;
28 const char* stock; 29 const char* stock;
29 if (is_forward) { 30 if (is_forward) {
30 normal = IDR_FORWARD; 31 normal = IDR_FORWARD;
31 active = IDR_FORWARD_P; 32 active = IDR_FORWARD_P;
32 highlight = IDR_FORWARD_H; 33 highlight = IDR_FORWARD_H;
33 depressed = IDR_FORWARD_D; 34 depressed = IDR_FORWARD_D;
34 tooltip = IDS_TOOLTIP_FORWARD; 35 tooltip = IDS_TOOLTIP_FORWARD;
35 stock = GTK_STOCK_GO_FORWARD; 36 stock = GTK_STOCK_GO_FORWARD;
36 } else { 37 } else {
37 normal = IDR_BACK; 38 normal = IDR_BACK;
38 active = IDR_BACK_P; 39 active = IDR_BACK_P;
39 highlight = IDR_BACK_H; 40 highlight = IDR_BACK_H;
40 depressed = IDR_BACK_D; 41 depressed = IDR_BACK_D;
41 tooltip = IDS_TOOLTIP_BACK; 42 tooltip = IDS_TOOLTIP_BACK;
42 stock = GTK_STOCK_GO_BACK; 43 stock = GTK_STOCK_GO_BACK;
43 } 44 }
44 button_.reset(new CustomDrawButton(normal, active, highlight, depressed, 45 button_.reset(new CustomDrawButton(browser_->profile()->GetThemeProvider(),
45 stock)); 46 normal, active, highlight, depressed, stock));
46 gtk_widget_set_tooltip_text(widget(), 47 gtk_widget_set_tooltip_text(widget(),
47 l10n_util::GetStringUTF8(tooltip).c_str()); 48 l10n_util::GetStringUTF8(tooltip).c_str());
48 menu_model_.reset(new BackForwardMenuModelGtk(browser, 49 menu_model_.reset(new BackForwardMenuModelGtk(browser,
49 is_forward ? 50 is_forward ?
50 BackForwardMenuModel::FORWARD_MENU : 51 BackForwardMenuModel::FORWARD_MENU :
51 BackForwardMenuModel::BACKWARD_MENU, 52 BackForwardMenuModel::BACKWARD_MENU,
52 this)); 53 this));
53 54
54 g_signal_connect(widget(), "clicked", 55 g_signal_connect(widget(), "clicked",
55 G_CALLBACK(OnClick), this); 56 G_CALLBACK(OnClick), this);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 int drag_min_distance; 143 int drag_min_distance;
143 g_object_get(settings, "gtk-dnd-drag-threshold", &drag_min_distance, NULL); 144 g_object_get(settings, "gtk-dnd-drag-threshold", &drag_min_distance, NULL);
144 if (event->y - button->y_position_of_last_press_ < drag_min_distance) 145 if (event->y - button->y_position_of_last_press_ < drag_min_distance)
145 return FALSE; 146 return FALSE;
146 147
147 // We will show the menu now. Cancel the delayed event. 148 // We will show the menu now. Cancel the delayed event.
148 button->show_menu_factory_.RevokeAll(); 149 button->show_menu_factory_.RevokeAll();
149 button->ShowBackForwardMenu(); 150 button->ShowBackForwardMenu();
150 return FALSE; 151 return FALSE;
151 } 152 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/gtk/browser_toolbar_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698