| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_GTK_GO_BUTTON_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_GO_BUTTON_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_GO_BUTTON_GTK_H_ | 6 #define CHROME_BROWSER_GTK_GO_BUTTON_GTK_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/task.h" | 11 #include "base/task.h" |
| 12 #include "chrome/browser/gtk/custom_button.h" | 12 #include "chrome/browser/gtk/custom_button.h" |
| 13 #include "chrome/common/owned_widget_gtk.h" | 13 #include "chrome/common/owned_widget_gtk.h" |
| 14 | 14 |
| 15 class Browser; | 15 class Browser; |
| 16 class LocationBarViewGtk; |
| 16 class Task; | 17 class Task; |
| 17 | 18 |
| 18 class GoButtonGtk { | 19 class GoButtonGtk { |
| 19 public: | 20 public: |
| 20 enum Mode { MODE_GO = 0, MODE_STOP }; | 21 enum Mode { MODE_GO = 0, MODE_STOP }; |
| 21 enum ButtonState { BS_NORMAL = 0, BS_HOT }; | 22 enum ButtonState { BS_NORMAL = 0, BS_HOT }; |
| 22 | 23 |
| 23 explicit GoButtonGtk(Browser* browser); | 24 GoButtonGtk(LocationBarViewGtk* location_bar, Browser* browser); |
| 24 ~GoButtonGtk(); | 25 ~GoButtonGtk(); |
| 25 | 26 |
| 26 GtkWidget* widget() const { return widget_.get(); } | 27 GtkWidget* widget() const { return widget_.get(); } |
| 27 ButtonState state() const { return state_; } | 28 ButtonState state() const { return state_; } |
| 28 | 29 |
| 29 // Force the button state. Useful for when the foreground tab changes. | 30 // Force the button state. Useful for when the foreground tab changes. |
| 30 void ChangeMode(Mode mode); | 31 void ChangeMode(Mode mode); |
| 31 | 32 |
| 32 // Ask for a specified button state. This is called when the loading state of | 33 // Ask for a specified button state. This is called when the loading state of |
| 33 // the tab changes. This method may postpone the actual ChangeMode() call | 34 // the tab changes. This method may postpone the actual ChangeMode() call |
| 34 // until another event (such as waiting for a potential double click to end, | 35 // until another event (such as waiting for a potential double click to end, |
| 35 // or for the mouse to stop hovering over the button). | 36 // or for the mouse to stop hovering over the button). |
| 36 void ScheduleChangeMode(Mode mode); | 37 void ScheduleChangeMode(Mode mode); |
| 37 | 38 |
| 38 private: | 39 private: |
| 39 friend class GoButtonGtkPeer; | 40 friend class GoButtonGtkPeer; |
| 40 | 41 |
| 41 // gtk signals | 42 // gtk signals |
| 42 static gboolean OnExpose(GtkWidget* widget, | 43 static gboolean OnExpose(GtkWidget* widget, |
| 43 GdkEventExpose* e, | 44 GdkEventExpose* e, |
| 44 GoButtonGtk* button); | 45 GoButtonGtk* button); |
| 45 static gboolean OnEnter(GtkButton* widget, GoButtonGtk* button); | 46 static gboolean OnEnter(GtkButton* widget, GoButtonGtk* button); |
| 46 static gboolean OnLeave(GtkButton* widget, GoButtonGtk* button); | 47 static gboolean OnLeave(GtkButton* widget, GoButtonGtk* button); |
| 47 static gboolean OnClicked(GtkButton* widget, GoButtonGtk* button); | 48 static gboolean OnClicked(GtkButton* widget, GoButtonGtk* button); |
| 48 | 49 |
| 50 void SetToggled(); |
| 51 |
| 49 Task* CreateButtonTimerTask(); | 52 Task* CreateButtonTimerTask(); |
| 50 void OnButtonTimer(); | 53 void OnButtonTimer(); |
| 54 void SetTooltip(); |
| 55 |
| 56 LocationBarViewGtk* const location_bar_; |
| 51 | 57 |
| 52 // Keep a pointer to the Browser object to execute commands on it. | 58 // Keep a pointer to the Browser object to execute commands on it. |
| 53 Browser* const browser_; | 59 Browser* const browser_; |
| 54 | 60 |
| 55 // Delay time to wait before allowing a mode change. This is to prevent a | 61 // Delay time to wait before allowing a mode change. This is to prevent a |
| 56 // mode switch while the user is double clicking. | 62 // mode switch while the user is double clicking. |
| 57 int button_delay_; | 63 int button_delay_; |
| 58 ScopedRunnableMethodFactory<GoButtonGtk> stop_timer_; | 64 ScopedRunnableMethodFactory<GoButtonGtk> stop_timer_; |
| 59 | 65 |
| 60 // The mode we should be in | 66 // The mode we should be in |
| 61 Mode intended_mode_; | 67 Mode intended_mode_; |
| 62 | 68 |
| 63 // The currently-visible mode - this may different from the intended mode | 69 // The currently-visible mode - this may different from the intended mode |
| 64 Mode visible_mode_; | 70 Mode visible_mode_; |
| 65 | 71 |
| 66 ButtonState state_; | 72 ButtonState state_; |
| 67 | 73 |
| 68 CustomDrawButtonBase go_; | 74 CustomDrawButtonBase go_; |
| 69 CustomDrawButtonBase stop_; | 75 CustomDrawButtonBase stop_; |
| 70 | 76 |
| 71 OwnedWidgetGtk widget_; | 77 OwnedWidgetGtk widget_; |
| 72 | 78 |
| 73 DISALLOW_COPY_AND_ASSIGN(GoButtonGtk); | 79 DISALLOW_COPY_AND_ASSIGN(GoButtonGtk); |
| 74 }; | 80 }; |
| 75 | 81 |
| 76 #endif // CHROME_BROWSER_GTK_GO_BUTTON_GTK_H_ | 82 #endif // CHROME_BROWSER_GTK_GO_BUTTON_GTK_H_ |
| OLD | NEW |