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