diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-21 17:59:33 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-21 17:59:33 +0000 |
commit | 3e6058b3cfe2fbc401d4abb1c3ac7c16fc48bda3 (patch) | |
tree | 9c27d9a4fc24dbe01460a776bfd93498d75f57b2 /chrome/browser/gtk | |
parent | f212ee44a72d12eb1f9835c20f65e346639cbd93 (diff) | |
download | chromium_src-3e6058b3cfe2fbc401d4abb1c3ac7c16fc48bda3.zip chromium_src-3e6058b3cfe2fbc401d4abb1c3ac7c16fc48bda3.tar.gz chromium_src-3e6058b3cfe2fbc401d4abb1c3ac7c16fc48bda3.tar.bz2 |
GTK: Don't instantly hide the status bubble; set a callback that does it after a delay.
Review URL: http://codereview.chromium.org/115639
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16625 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/status_bubble_gtk.cc | 21 | ||||
-rw-r--r-- | chrome/browser/gtk/status_bubble_gtk.h | 7 |
2 files changed, 26 insertions, 2 deletions
diff --git a/chrome/browser/gtk/status_bubble_gtk.cc b/chrome/browser/gtk/status_bubble_gtk.cc index 83f2aae..5195135 100644 --- a/chrome/browser/gtk/status_bubble_gtk.cc +++ b/chrome/browser/gtk/status_bubble_gtk.cc @@ -7,6 +7,7 @@ #include <gtk/gtk.h> #include "base/gfx/gtk_util.h" +#include "base/message_loop.h" #include "base/string_util.h" #include "chrome/browser/gtk/slide_animator_gtk.h" #include "chrome/common/gtk_util.h" @@ -24,10 +25,14 @@ const int kInternalLeftRightPadding = 2; // Border of color kFrameBorderColor around the status bubble. const int kBorderPadding = 1; +// Milliseconds before we hide the status bubble widget when you mouseout. +static const int kHideDelay = 250; + } // namespace StatusBubbleGtk::StatusBubbleGtk() - : parent_(NULL) { + : parent_(NULL), + timer_factory_(this) { InitWidgets(); } @@ -37,7 +42,7 @@ StatusBubbleGtk::~StatusBubbleGtk() { void StatusBubbleGtk::SetStatus(const std::string& status) { if (status.empty()) { - Hide(); + HideInASecond(); return; } @@ -62,6 +67,9 @@ void StatusBubbleGtk::SetURL(const GURL& url, const std::wstring& languages) { } void StatusBubbleGtk::Show() { + // If we were going to hide, stop. + timer_factory_.RevokeAll(); + SetStatusBubbleSize(); gtk_widget_show_all(container_.get()); @@ -73,6 +81,15 @@ void StatusBubbleGtk::Hide() { gtk_widget_hide_all(container_.get()); } +void StatusBubbleGtk::HideInASecond() { + if (!timer_factory_.empty()) + timer_factory_.RevokeAll(); + + MessageLoop::current()->PostDelayedTask(FROM_HERE, + timer_factory_.NewRunnableMethod(&StatusBubbleGtk::Hide), + kHideDelay); +} + void StatusBubbleGtk::SetStatusBubbleSize() { if (parent_) { GtkRequisition requisition; diff --git a/chrome/browser/gtk/status_bubble_gtk.h b/chrome/browser/gtk/status_bubble_gtk.h index db8044c..eb37041 100644 --- a/chrome/browser/gtk/status_bubble_gtk.h +++ b/chrome/browser/gtk/status_bubble_gtk.h @@ -10,6 +10,7 @@ #include <string> #include "base/scoped_ptr.h" +#include "base/task.h" #include "chrome/browser/status_bubble.h" #include "chrome/common/owned_widget_gtk.h" @@ -47,6 +48,9 @@ class StatusBubbleGtk : public StatusBubble { // and makes sure that the status bubble has the highest z-order. void Show(); + // Sets an internal timer to hide the status bubble after a delay. + void HideInASecond(); + // Builds the widgets, containers, etc. void InitWidgets(); @@ -68,6 +72,9 @@ class StatusBubbleGtk : public StatusBubble { // |parent_|'s GtkAllocation. We make sure that |container_| lives along the // bottom of this and doesn't protrude. GtkAllocation parent_allocation_; + + // A timer that hides our window after a delay. + ScopedRunnableMethodFactory<StatusBubbleGtk> timer_factory_; }; #endif // CHROME_BROWSER_GTK_STATUS_BUBBLE_GTK_H_ |