summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/status_bubble_gtk.cc
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-19 03:37:12 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-19 03:37:12 +0000
commitbe06a75bb612b0652f7ba926668b94671b9c6ab8 (patch)
treebc2efae1a3e66d97e0c6b0c9b95f72793b794398 /chrome/browser/gtk/status_bubble_gtk.cc
parentefedc412986c570f16b54e58bb5edc47546e0eee (diff)
downloadchromium_src-be06a75bb612b0652f7ba926668b94671b9c6ab8.zip
chromium_src-be06a75bb612b0652f7ba926668b94671b9c6ab8.tar.gz
chromium_src-be06a75bb612b0652f7ba926668b94671b9c6ab8.tar.bz2
Super-simplistic status bubble on Linux.
(I just want to see when pages are loading, y'know...) Review URL: http://codereview.chromium.org/21500 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10004 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/status_bubble_gtk.cc')
-rw-r--r--chrome/browser/gtk/status_bubble_gtk.cc73
1 files changed, 73 insertions, 0 deletions
diff --git a/chrome/browser/gtk/status_bubble_gtk.cc b/chrome/browser/gtk/status_bubble_gtk.cc
new file mode 100644
index 0000000..4e67bee
--- /dev/null
+++ b/chrome/browser/gtk/status_bubble_gtk.cc
@@ -0,0 +1,73 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/gtk/status_bubble_gtk.h"
+
+#include "base/string_util.h"
+#include "googleurl/src/gurl.h"
+
+StatusBubbleGtk::StatusBubbleGtk(GtkWindow* parent)
+ : parent_(parent), window_(NULL) {
+}
+
+StatusBubbleGtk::~StatusBubbleGtk() {
+ Hide();
+}
+
+void StatusBubbleGtk::SetStatus(const std::string& status) {
+ if (status.empty()) {
+ Hide();
+ return;
+ }
+
+ if (!window_)
+ Create();
+
+ gtk_label_set_text(GTK_LABEL(label_), status.c_str());
+ Reposition();
+ gtk_widget_show(window_);
+}
+
+void StatusBubbleGtk::SetStatus(const std::wstring& status) {
+ SetStatus(WideToUTF8(status));
+}
+
+void StatusBubbleGtk::SetURL(const GURL& url, const std::wstring& languages) {
+ SetStatus(url.spec());
+}
+
+void StatusBubbleGtk::Hide() {
+ if (!window_)
+ return;
+ gtk_widget_destroy(window_);
+ window_ = NULL;
+}
+
+void StatusBubbleGtk::MouseMoved() {
+ if (!window_)
+ return;
+ // We ignore for now.
+ // TODO(port): the fancy sliding behavior.
+}
+
+void StatusBubbleGtk::Create() {
+ if (window_)
+ return;
+
+ window_ = gtk_window_new(GTK_WINDOW_POPUP);
+ gtk_window_set_transient_for(GTK_WINDOW(window_), parent_);
+ gtk_container_set_border_width(GTK_CONTAINER(window_), 2);
+ label_ = gtk_label_new("");
+ gtk_widget_show(label_);
+ gtk_container_add(GTK_CONTAINER(window_), label_);
+}
+
+void StatusBubbleGtk::Reposition() {
+ int x, y, width, height, parent_height;
+ gtk_window_get_position(parent_, &x, &y);
+ gtk_window_get_size(parent_, &width, &parent_height);
+ gtk_window_get_size(GTK_WINDOW(window_), &width, &height);
+ // TODO(port): RTL positioning.
+ gtk_window_move(GTK_WINDOW(window_), x, y + parent_height - height);
+}