summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-23 22:55:21 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-23 22:55:21 +0000
commit97dc320a8fd7b25abbac5b35d6cc49111668416b (patch)
tree0e4ef92d4bc7a19d22bd9e15e2b04bd9e04ba0a6 /chrome/browser/gtk
parent01dbd931735c7b7497b7b83664462512f272bf58 (diff)
downloadchromium_src-97dc320a8fd7b25abbac5b35d6cc49111668416b.zip
chromium_src-97dc320a8fd7b25abbac5b35d6cc49111668416b.tar.gz
chromium_src-97dc320a8fd7b25abbac5b35d6cc49111668416b.tar.bz2
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
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/status_bubble_gtk.cc44
-rw-r--r--chrome/browser/gtk/status_bubble_gtk.h12
2 files changed, 42 insertions, 14 deletions
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();
diff --git a/chrome/browser/gtk/status_bubble_gtk.h b/chrome/browser/gtk/status_bubble_gtk.h
index 5de672b..006efd0 100644
--- a/chrome/browser/gtk/status_bubble_gtk.h
+++ b/chrome/browser/gtk/status_bubble_gtk.h
@@ -36,14 +36,16 @@ class StatusBubbleGtk : public StatusBubble {
// the download shelf, when it is visible.
virtual void UpdateDownloadShelfVisibility(bool visible) { }
- void SetStatus(const std::string& status_utf8);
-
// Top of the widget hierarchy for a StatusBubble. This top level widget is
// guarenteed to have its gtk_widget_name set to "status-bubble" for
// identification.
GtkWidget* widget() { return container_.get(); }
private:
+ // Sets the text of the label widget and controls visibility. (As contrasted
+ // with setting the current status or URL text, which may be ignored for now).
+ void SetStatusTextTo(const std::string& status_utf8);
+
// Sets the status bubble's location in the parent GtkFixed, shows the widget
// and makes sure that the status bubble has the highest z-order.
void Show();
@@ -60,6 +62,12 @@ class StatusBubbleGtk : public StatusBubble {
// The GtkLabel holding the text.
GtkWidget* label_;
+ // The status text we want to display when there are no URLs to display.
+ std::string status_text_;
+
+ // The url we want to display when there is no status text to display.
+ std::string url_text_;
+
// A timer that hides our window after a delay.
ScopedRunnableMethodFactory<StatusBubbleGtk> timer_factory_;
};