summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc4
-rw-r--r--chrome/browser/gtk/browser_window_gtk.h3
-rw-r--r--chrome/browser/gtk/fullscreen_exit_bubble_gtk.cc106
-rw-r--r--chrome/browser/gtk/fullscreen_exit_bubble_gtk.h46
-rwxr-xr-xchrome/chrome.gyp2
5 files changed, 161 insertions, 0 deletions
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index 87bf9c2..7ecc76b 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -46,6 +46,7 @@
#include "chrome/browser/gtk/download_shelf_gtk.h"
#include "chrome/browser/gtk/edit_search_engine_dialog.h"
#include "chrome/browser/gtk/find_bar_gtk.h"
+#include "chrome/browser/gtk/fullscreen_exit_bubble_gtk.h"
#include "chrome/browser/gtk/gtk_floating_container.h"
#include "chrome/browser/gtk/go_button_gtk.h"
#include "chrome/browser/gtk/gtk_theme_provider.h"
@@ -1425,6 +1426,8 @@ void BrowserWindowGtk::OnStateChanged(GdkWindowState state,
tabstrip_->Hide();
if (IsBookmarkBarSupported())
bookmark_bar_->EnterFullscreen();
+ fullscreen_exit_bubble_.reset(new FullscreenExitBubbleGtk(
+ GTK_FLOATING_CONTAINER(render_area_floating_container_)));
gtk_widget_hide(toolbar_border_);
#if defined(OS_CHROMEOS)
if (main_menu_button_)
@@ -1435,6 +1438,7 @@ void BrowserWindowGtk::OnStateChanged(GdkWindowState state,
status_area_->GetWidget()->Hide();
#endif
} else {
+ fullscreen_exit_bubble_.reset();
UpdateCustomFrame();
ShowSupportedWindowFeatures();
diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h
index 6d79a9a..f531a65 100644
--- a/chrome/browser/gtk/browser_window_gtk.h
+++ b/chrome/browser/gtk/browser_window_gtk.h
@@ -35,6 +35,7 @@ class BrowserToolbarGtk;
class CustomDrawButton;
class DownloadShelfGtk;
class FindBarGtk;
+class FullscreenExitBubbleGtk;
class InfoBarContainerGtk;
class LocationBar;
class StatusBubbleGtk;
@@ -430,6 +431,8 @@ class BrowserWindowGtk : public BrowserWindow,
// The accelerator group used to handle accelerators, owned by this object.
GtkAccelGroup* accel_group_;
+ scoped_ptr<FullscreenExitBubbleGtk> fullscreen_exit_bubble_;
+
DISALLOW_COPY_AND_ASSIGN(BrowserWindowGtk);
};
diff --git a/chrome/browser/gtk/fullscreen_exit_bubble_gtk.cc b/chrome/browser/gtk/fullscreen_exit_bubble_gtk.cc
new file mode 100644
index 0000000..c545def
--- /dev/null
+++ b/chrome/browser/gtk/fullscreen_exit_bubble_gtk.cc
@@ -0,0 +1,106 @@
+// 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/fullscreen_exit_bubble_gtk.h"
+
+#include "app/gfx/gtk_util.h"
+#include "app/l10n_util.h"
+#include "chrome/browser/gtk/gtk_chrome_link_button.h"
+#include "chrome/browser/gtk/gtk_floating_container.h"
+#include "chrome/common/gtk_util.h"
+#include "grit/app_strings.h"
+#include "grit/generated_resources.h"
+
+namespace {
+
+// Padding around the link text.
+const int kPaddingPixels = 8;
+
+// Time before the link disappears or slides away.
+const int kInitialDelayMs = 3000;
+
+}
+
+FullscreenExitBubbleGtk::FullscreenExitBubbleGtk(
+ GtkFloatingContainer* container)
+ : container_(container) {
+ InitWidgets();
+}
+
+FullscreenExitBubbleGtk::~FullscreenExitBubbleGtk() {
+ // If the user exits the browser while in fullscreen mode, we may already
+ // have been removed from the widget hierarchy.
+ GtkWidget* parent = gtk_widget_get_parent(alignment_.get());
+ if (parent) {
+ g_signal_handlers_disconnect_by_func(parent,
+ reinterpret_cast<gpointer>(OnSetFloatingPosition), this);
+ gtk_container_remove(GTK_CONTAINER(parent), alignment_.get());
+ }
+ alignment_.Destroy();
+}
+
+void FullscreenExitBubbleGtk::InitWidgets() {
+ // The exit bubble is a gtk_chrome_link_button inside a gtk event box and gtk
+ // alignment.
+
+ // The Windows code actually looks up the accelerator key in the accelerator
+ // table and then converts the key to a string (in a switch statement).
+ std::string exit_text_utf8("<span color=\"white\" size=\"large\">");
+ exit_text_utf8.append(l10n_util::GetStringFUTF8(
+ IDS_EXIT_FULLSCREEN_MODE, l10n_util::GetStringUTF16(IDS_APP_F11_KEY)));
+ exit_text_utf8.append("</span>");
+ GtkWidget* link = gtk_chrome_link_button_new_with_markup(
+ exit_text_utf8.c_str());
+ gtk_chrome_link_button_set_use_gtk_theme(GTK_CHROME_LINK_BUTTON(link),
+ FALSE);
+ g_signal_connect(link, "clicked", G_CALLBACK(OnLinkClicked), this);
+
+ alignment_.Own(gtk_util::CreateGtkBorderBin(link, &gfx::kGdkBlack,
+ kPaddingPixels, kPaddingPixels, kPaddingPixels, kPaddingPixels));
+ gtk_widget_set_name(alignment_.get(), "exit-fullscreen-bubble");
+ gtk_widget_show_all(alignment_.get());
+
+ // TODO(tc): Implement the more complex logic in the windows version for
+ // when to show/hide the exit bubble.
+ initial_delay_.Start(base::TimeDelta::FromMilliseconds(kInitialDelayMs), this,
+ &FullscreenExitBubbleGtk::Hide);
+
+ gtk_floating_container_add_floating(GTK_FLOATING_CONTAINER(container_),
+ alignment_.get());
+ g_signal_connect(container_, "set-floating-position",
+ G_CALLBACK(OnSetFloatingPosition), this);
+}
+
+void FullscreenExitBubbleGtk::Hide() {
+ // TODO(tc): Slide out animation.
+ gtk_widget_hide(alignment_.get());
+}
+
+// static
+void FullscreenExitBubbleGtk::OnSetFloatingPosition(
+ GtkFloatingContainer* floating_container, GtkAllocation* allocation,
+ FullscreenExitBubbleGtk* bubble) {
+ GtkRequisition bubble_size;
+ gtk_widget_size_request(bubble->alignment_.get(), &bubble_size);
+
+ // Position the bubble at the top center of the screen.
+ GValue value = { 0, };
+ g_value_init(&value, G_TYPE_INT);
+ g_value_set_int(&value, (allocation->width - bubble_size.width) / 2);
+ gtk_container_child_set_property(GTK_CONTAINER(floating_container),
+ bubble->alignment_.get(), "x", &value);
+
+ g_value_set_int(&value, 0);
+ gtk_container_child_set_property(GTK_CONTAINER(floating_container),
+ bubble->alignment_.get(), "y", &value);
+ g_value_unset(&value);
+}
+
+// static
+void FullscreenExitBubbleGtk::OnLinkClicked(GtkWidget* link,
+ FullscreenExitBubbleGtk* bubble) {
+ GtkWindow* window = GTK_WINDOW(gtk_widget_get_toplevel(
+ bubble->alignment_.get()));
+ gtk_window_unfullscreen(window);
+}
diff --git a/chrome/browser/gtk/fullscreen_exit_bubble_gtk.h b/chrome/browser/gtk/fullscreen_exit_bubble_gtk.h
new file mode 100644
index 0000000..f5c3c80
--- /dev/null
+++ b/chrome/browser/gtk/fullscreen_exit_bubble_gtk.h
@@ -0,0 +1,46 @@
+// 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.
+
+#ifndef CHROME_BROWSER_GTK_FULLSCREEN_EXIT_BUBBLE_GTK_H_
+#define CHROME_BROWSER_GTK_FULLSCREEN_EXIT_BUBBLE_GTK_H_
+
+#include <gtk/gtk.h>
+
+#include "base/timer.h"
+#include "chrome/common/owned_widget_gtk.h"
+
+typedef struct _GtkFloatingContainer GtkFloatingContainer;
+
+// FullscreenExitBubbleGTK is responsible for showing a bubble atop the screen
+// in fullscreen mode, telling users how to exit and providing a click target.
+class FullscreenExitBubbleGtk {
+ public:
+ // We place the bubble in |container|.
+ explicit FullscreenExitBubbleGtk(GtkFloatingContainer* container);
+ ~FullscreenExitBubbleGtk();
+
+ void InitWidgets();
+
+ private:
+ // Hide the exit bubble.
+ void Hide();
+
+ static void OnSetFloatingPosition(GtkFloatingContainer* floating_container,
+ GtkAllocation* allocation,
+ FullscreenExitBubbleGtk* bubble);
+
+ static void OnLinkClicked(GtkWidget* link,
+ FullscreenExitBubbleGtk* bubble);
+
+ // A pointer to the floating container that is our parent.
+ GtkFloatingContainer* container_;
+
+ // The top widget of the exit bubble.
+ OwnedWidgetGtk alignment_;
+
+ // The timer that does the initial hiding of the exit bubble.
+ base::OneShotTimer<FullscreenExitBubbleGtk> initial_delay_;
+};
+
+#endif // CHROME_BROWSER_GTK_FULLSCREEN_EXIT_BUBBLE_GTK_H_
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 07dc335..e208e4a 100755
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -1539,6 +1539,8 @@
'browser/gtk/first_run_dialog.h',
'browser/gtk/focus_store_gtk.cc',
'browser/gtk/focus_store_gtk.h',
+ 'browser/gtk/fullscreen_exit_bubble_gtk.cc',
+ 'browser/gtk/fullscreen_exit_bubble_gtk.h',
'browser/gtk/go_button_gtk.cc',
'browser/gtk/go_button_gtk.h',
'browser/gtk/gtk_chrome_button.cc',