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/hover_controller_gtk.h" | 5 #include "chrome/browser/ui/gtk/hover_controller_gtk.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" | 8 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" |
| 9 #include "ui/base/gtk/gtk_compat.h" |
9 | 10 |
10 static const gchar* kHoverControllerGtkKey = "__HOVER_CONTROLLER_GTK__"; | 11 static const gchar* kHoverControllerGtkKey = "__HOVER_CONTROLLER_GTK__"; |
11 | 12 |
12 HoverControllerGtk::HoverControllerGtk(GtkWidget* button) | 13 HoverControllerGtk::HoverControllerGtk(GtkWidget* button) |
13 : throb_animation_(this), | 14 : throb_animation_(this), |
14 hover_animation_(this), | 15 hover_animation_(this), |
15 button_(button) { | 16 button_(button) { |
16 g_object_ref(button_); | 17 g_object_ref(button_); |
17 gtk_chrome_button_set_hover_state(GTK_CHROME_BUTTON(button_), 0); | 18 gtk_chrome_button_set_hover_state(GTK_CHROME_BUTTON(button_), 0); |
18 | 19 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 hover_animation_.Hide(); | 108 hover_animation_.Hide(); |
108 } | 109 } |
109 | 110 |
110 return FALSE; | 111 return FALSE; |
111 } | 112 } |
112 | 113 |
113 void HoverControllerGtk::OnHierarchyChanged(GtkWidget* widget, | 114 void HoverControllerGtk::OnHierarchyChanged(GtkWidget* widget, |
114 GtkWidget* previous_toplevel) { | 115 GtkWidget* previous_toplevel) { |
115 // GTK+ does not emit leave-notify-event signals when a widget | 116 // GTK+ does not emit leave-notify-event signals when a widget |
116 // becomes unanchored, so manually unset the hover states. | 117 // becomes unanchored, so manually unset the hover states. |
117 if (!GTK_WIDGET_TOPLEVEL(gtk_widget_get_toplevel(widget))) { | 118 if (!gtk_widget_is_toplevel(gtk_widget_get_toplevel(widget))) { |
118 gtk_widget_set_state(button_, GTK_STATE_NORMAL); | 119 gtk_widget_set_state(button_, GTK_STATE_NORMAL); |
119 hover_animation_.Reset(); | 120 hover_animation_.Reset(); |
120 gtk_chrome_button_set_hover_state(GTK_CHROME_BUTTON(button_), 0.0); | 121 gtk_chrome_button_set_hover_state(GTK_CHROME_BUTTON(button_), 0.0); |
121 } | 122 } |
122 } | 123 } |
123 | 124 |
124 void HoverControllerGtk::OnDestroy(GtkWidget* widget) { | 125 void HoverControllerGtk::OnDestroy(GtkWidget* widget) { |
125 Destroy(); | 126 Destroy(); |
126 } | 127 } |
OLD | NEW |