From 97dc320a8fd7b25abbac5b35d6cc49111668416b Mon Sep 17 00:00:00 2001 From: "erg@google.com" Date: Tue, 23 Jun 2009 22:55:21 +0000 Subject: GTK: Fix status bubble hiding during background tab events. So the GTK version had only one status, setting the status to any URL the user hovered over. When the background tab is done with loading, it sends a SetStatus("") to the StatusBubble. This was what was tickling the bug. So I'm copying the Windows implementation, which can have a URL and a status, with the URL's display overriding the status display. So when the background tab calls SetStatus(""), the URL should still be displayed. http://crbug.com/14802 Review URL: http://codereview.chromium.org/147050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19077 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/gtk/status_bubble_gtk.cc | 44 ++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 12 deletions(-) (limited to 'chrome/browser/gtk/status_bubble_gtk.cc') diff --git a/chrome/browser/gtk/status_bubble_gtk.cc b/chrome/browser/gtk/status_bubble_gtk.cc index 7b377b1..f747570 100644 --- a/chrome/browser/gtk/status_bubble_gtk.cc +++ b/chrome/browser/gtk/status_bubble_gtk.cc @@ -40,23 +40,34 @@ StatusBubbleGtk::~StatusBubbleGtk() { container_.Destroy(); } -void StatusBubbleGtk::SetStatus(const std::string& status) { - if (status.empty()) { - HideInASecond(); +void StatusBubbleGtk::SetStatus(const std::wstring& status_text_wide) { + std::string status_text = WideToUTF8(status_text_wide); + if (status_text_ == status_text) return; - } - gtk_label_set_text(GTK_LABEL(label_), status.c_str()); - - Show(); -} - -void StatusBubbleGtk::SetStatus(const std::wstring& status) { - SetStatus(WideToUTF8(status)); + status_text_ = status_text; + if (!status_text_.empty()) { + SetStatusTextTo(status_text_); + } else if (!url_text_.empty()) { + SetStatusTextTo(url_text_); + } else { + SetStatusTextTo(std::string()); + } } void StatusBubbleGtk::SetURL(const GURL& url, const std::wstring& languages) { - SetStatus(url.possibly_invalid_spec()); + // If we want to clear a displayed URL but there is a status still to + // display, display that status instead. + if (url.is_empty() && !status_text_.empty()) { + url_text_ = std::string(); + SetStatusTextTo(status_text_); + return; + } + + // TODO(erg): We probably want to elide the text from the GURL object. + url_text_ = url.possibly_invalid_spec(); + + SetStatusTextTo(url_text_); } void StatusBubbleGtk::Show() { @@ -73,6 +84,15 @@ void StatusBubbleGtk::Hide() { gtk_widget_hide_all(container_.get()); } +void StatusBubbleGtk::SetStatusTextTo(const std::string& status_utf8) { + if (status_utf8.empty()) { + HideInASecond(); + } else { + gtk_label_set_text(GTK_LABEL(label_), status_utf8.c_str()); + Show(); + } +} + void StatusBubbleGtk::HideInASecond() { if (!timer_factory_.empty()) timer_factory_.RevokeAll(); -- cgit v1.1