OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/reload_button_gtk.h" | 5 #include "chrome/browser/ui/gtk/reload_button_gtk.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" | 12 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" |
13 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 13 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
14 #include "chrome/browser/ui/gtk/gtk_util.h" | 14 #include "chrome/browser/ui/gtk/gtk_util.h" |
15 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" | 15 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
| 16 #include "chrome/common/chrome_notification_types.h" |
16 #include "content/common/notification_source.h" | 17 #include "content/common/notification_source.h" |
17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
18 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
19 #include "grit/theme_resources_standard.h" | 20 #include "grit/theme_resources_standard.h" |
20 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
21 | 22 |
22 // The width of this button in GTK+ theme mode. The Stop and Refresh stock icons | 23 // The width of this button in GTK+ theme mode. The Stop and Refresh stock icons |
23 // can be different sizes; this variable is used to make sure that the button | 24 // can be different sizes; this variable is used to make sure that the button |
24 // doesn't change sizes when switching between the two. | 25 // doesn't change sizes when switching between the two. |
25 static int GtkButtonWidth = 0; | 26 static int GtkButtonWidth = 0; |
(...skipping 28 matching lines...) Expand all Loading... |
54 gtk_widget_set_has_tooltip(widget(), TRUE); | 55 gtk_widget_set_has_tooltip(widget(), TRUE); |
55 g_signal_connect(widget(), "query-tooltip", G_CALLBACK(OnQueryTooltipThunk), | 56 g_signal_connect(widget(), "query-tooltip", G_CALLBACK(OnQueryTooltipThunk), |
56 this); | 57 this); |
57 | 58 |
58 hover_controller_.Init(widget()); | 59 hover_controller_.Init(widget()); |
59 gtk_util::SetButtonTriggersNavigation(widget()); | 60 gtk_util::SetButtonTriggersNavigation(widget()); |
60 | 61 |
61 if (theme_service_) { | 62 if (theme_service_) { |
62 theme_service_->InitThemesFor(this); | 63 theme_service_->InitThemesFor(this); |
63 registrar_.Add(this, | 64 registrar_.Add(this, |
64 NotificationType::BROWSER_THEME_CHANGED, | 65 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
65 Source<ThemeService>(theme_service_)); | 66 Source<ThemeService>(theme_service_)); |
66 } | 67 } |
67 | 68 |
68 // Set the default double-click timer delay to the system double-click time. | 69 // Set the default double-click timer delay to the system double-click time. |
69 int timer_delay_ms; | 70 int timer_delay_ms; |
70 GtkSettings* settings = gtk_settings_get_default(); | 71 GtkSettings* settings = gtk_settings_get_default(); |
71 g_object_get(G_OBJECT(settings), "gtk-double-click-time", &timer_delay_ms, | 72 g_object_get(G_OBJECT(settings), "gtk-double-click-time", &timer_delay_ms, |
72 NULL); | 73 NULL); |
73 double_click_timer_delay_ = base::TimeDelta::FromMilliseconds(timer_delay_ms); | 74 double_click_timer_delay_ = base::TimeDelta::FromMilliseconds(timer_delay_ms); |
74 } | 75 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 if (!stop_to_reload_timer_.IsRunning()) { | 121 if (!stop_to_reload_timer_.IsRunning()) { |
121 stop_to_reload_timer_.Start(stop_to_reload_timer_delay_, this, | 122 stop_to_reload_timer_.Start(stop_to_reload_timer_delay_, this, |
122 &ReloadButtonGtk::OnStopToReloadTimer); | 123 &ReloadButtonGtk::OnStopToReloadTimer); |
123 } | 124 } |
124 } | 125 } |
125 } | 126 } |
126 | 127 |
127 //////////////////////////////////////////////////////////////////////////////// | 128 //////////////////////////////////////////////////////////////////////////////// |
128 // ReloadButtonGtk, NotificationObserver implementation: | 129 // ReloadButtonGtk, NotificationObserver implementation: |
129 | 130 |
130 void ReloadButtonGtk::Observe(NotificationType type, | 131 void ReloadButtonGtk::Observe(int type, |
131 const NotificationSource& source, | 132 const NotificationSource& source, |
132 const NotificationDetails& /* details */) { | 133 const NotificationDetails& /* details */) { |
133 DCHECK(NotificationType::BROWSER_THEME_CHANGED == type); | 134 DCHECK(chrome::NOTIFICATION_BROWSER_THEME_CHANGED == type); |
134 | 135 |
135 GtkThemeService* provider = static_cast<GtkThemeService*>( | 136 GtkThemeService* provider = static_cast<GtkThemeService*>( |
136 Source<ThemeService>(source).ptr()); | 137 Source<ThemeService>(source).ptr()); |
137 DCHECK_EQ(provider, theme_service_); | 138 DCHECK_EQ(provider, theme_service_); |
138 GtkButtonWidth = 0; | 139 GtkButtonWidth = 0; |
139 UpdateThemeButtons(); | 140 UpdateThemeButtons(); |
140 } | 141 } |
141 | 142 |
142 //////////////////////////////////////////////////////////////////////////////// | 143 //////////////////////////////////////////////////////////////////////////////// |
143 // ReloadButtonGtk, private: | 144 // ReloadButtonGtk, private: |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 gtk_chrome_button_set_use_gtk_rendering(GTK_CHROME_BUTTON(widget()), use_gtk); | 272 gtk_chrome_button_set_use_gtk_rendering(GTK_CHROME_BUTTON(widget()), use_gtk); |
272 } | 273 } |
273 | 274 |
274 void ReloadButtonGtk::OnDoubleClickTimer() { | 275 void ReloadButtonGtk::OnDoubleClickTimer() { |
275 ChangeMode(intended_mode_, false); | 276 ChangeMode(intended_mode_, false); |
276 } | 277 } |
277 | 278 |
278 void ReloadButtonGtk::OnStopToReloadTimer() { | 279 void ReloadButtonGtk::OnStopToReloadTimer() { |
279 ChangeMode(intended_mode_, true); | 280 ChangeMode(intended_mode_, true); |
280 } | 281 } |
OLD | NEW |