summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/gtk/status_bubble_gtk.cc43
-rw-r--r--chrome/browser/gtk/status_bubble_gtk.h13
2 files changed, 9 insertions, 47 deletions
diff --git a/chrome/browser/gtk/status_bubble_gtk.cc b/chrome/browser/gtk/status_bubble_gtk.cc
index 6bceeb2..7b377b1 100644
--- a/chrome/browser/gtk/status_bubble_gtk.cc
+++ b/chrome/browser/gtk/status_bubble_gtk.cc
@@ -6,7 +6,6 @@
#include <gtk/gtk.h>
-#include "app/gfx/text_elider.h"
#include "base/gfx/gtk_util.h"
#include "base/message_loop.h"
#include "base/string_util.h"
@@ -42,15 +41,14 @@ StatusBubbleGtk::~StatusBubbleGtk() {
}
void StatusBubbleGtk::SetStatus(const std::string& status) {
- if (status_text_ == status)
+ if (status.empty()) {
+ HideInASecond();
return;
-
- status_text_ = status;
- if (!status_text_.empty()) {
- UpdateWidgetText(status_text_);
- } else {
- UpdateWidgetText(url_text_);
}
+
+ gtk_label_set_text(GTK_LABEL(label_), status.c_str());
+
+ Show();
}
void StatusBubbleGtk::SetStatus(const std::wstring& status) {
@@ -58,34 +56,7 @@ void StatusBubbleGtk::SetStatus(const std::wstring& status) {
}
void StatusBubbleGtk::SetURL(const GURL& url, const std::wstring& languages) {
- // 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_.clear();
- UpdateWidgetText(status_text_);
- return;
- }
-
- // Set Elided Text corresponding to the GURL object. We limit the width of
- // the URL to a third of the width of the browser window (matching the width
- // on windows).
- GdkWindow* window = gtk_widget_get_parent_window(container_.get());
- int window_width;
- gdk_drawable_get_size(GDK_DRAWABLE(window), &window_width, NULL);
- // TODO(tc): We don't actually use gfx::Font as the font in the status
- // bubble. We should extend gfx::ElideUrl to take some sort of pango font.
- url_text_ = WideToUTF8(gfx::ElideUrl(url, gfx::Font(), window_width / 3,
- languages));
- UpdateWidgetText(url_text_);
-}
-
-void StatusBubbleGtk::UpdateWidgetText(const std::string& text) {
- if (text.empty()) {
- HideInASecond();
- } else {
- gtk_label_set_text(GTK_LABEL(label_), text.c_str());
- Show();
- }
+ SetStatus(url.possibly_invalid_spec());
}
void StatusBubbleGtk::Show() {
diff --git a/chrome/browser/gtk/status_bubble_gtk.h b/chrome/browser/gtk/status_bubble_gtk.h
index da4bfe1..5de672b 100644
--- a/chrome/browser/gtk/status_bubble_gtk.h
+++ b/chrome/browser/gtk/status_bubble_gtk.h
@@ -36,18 +36,14 @@ 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:
- // The same as the public SetStatus method, but using utf8 instead.
- void SetStatus(const std::string& status_utf8);
-
- // Set the text in the gtk widget and handle when to show/hide the bubble.
- void UpdateWidgetText(const std::string& text);
-
// 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();
@@ -64,11 +60,6 @@ class StatusBubbleGtk : public StatusBubble {
// The GtkLabel holding the text.
GtkWidget* label_;
- // We keep both the status and url that we want to show and try to pick the
- // right one to display to the user.
- std::string status_text_;
- std::string url_text_;
-
// A timer that hides our window after a delay.
ScopedRunnableMethodFactory<StatusBubbleGtk> timer_factory_;
};