Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Unified Diff: chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.cc

Issue 8295024: GTK version of new fullscreen exit bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.cc
diff --git a/chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.cc b/chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.cc
index 114006fe4e1468887aba9960b489f10f7eae9b76..c140e731fef39fd6e5cdac358cd7b7aafbe76bfa 100644
--- a/chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.cc
+++ b/chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
#include "chrome/browser/ui/gtk/gtk_util.h"
@@ -14,6 +15,11 @@
#include "ui/base/gtk/gtk_hig_constants.h"
#include "ui/base/l10n/l10n_util.h"
+namespace {
+const GdkColor kFrameColor = GDK_COLOR_RGB(0x63, 0x63, 0x63);
+const int kMiddlePaddingPx = 30;
+} // namespace
+
FullscreenExitBubbleGtk::FullscreenExitBubbleGtk(
GtkFloatingContainer* container,
Browser* browser,
@@ -24,7 +30,6 @@ FullscreenExitBubbleGtk::FullscreenExitBubbleGtk(
url_(url),
show_buttons_(ask_permission) {
InitWidgets();
- StartWatchingMouse();
}
FullscreenExitBubbleGtk::~FullscreenExitBubbleGtk() {
@@ -38,43 +43,95 @@ void FullscreenExitBubbleGtk::InitWidgets() {
// 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). This
// doesn't seem to be implemented for Gtk, so we just use F11 directly.
- std::string exit_text_utf8("<span color=\"white\" size=\"large\">");
- exit_text_utf8.append(l10n_util::GetStringFUTF8(
+ std::string exit_text_utf8(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),
+ link_ = gtk_chrome_link_button_new(exit_text_utf8.c_str());
+ gtk_chrome_link_button_set_use_gtk_theme(GTK_CHROME_LINK_BUTTON(link_),
FALSE);
- signals_.Connect(link, "clicked", G_CALLBACK(OnLinkClickedThunk), this);
-
-
- link_container_.Own(gtk_util::CreateGtkBorderBin(
- link, &ui::kGdkBlack,
- kPaddingPx, kPaddingPx, kPaddingPx, kPaddingPx));
- GdkColor green = GDK_COLOR_RGB(0x00, 0xff, 0x00);
- gtk_util::ActAsRoundedWindow(link_container_.get(), green, kPaddingPx,
- gtk_util::ROUNDED_BOTTOM_LEFT | gtk_util::ROUNDED_BOTTOM_RIGHT,
- gtk_util::BORDER_NONE);
- slide_widget_.reset(new SlideAnimatorGtk(link_container_.get(),
+ GtkWidget* hbox = gtk_hbox_new(false, 0);
+
+ GtkWidget* button_link_hbox = gtk_hbox_new(false, ui::kControlSpacing);
+ allow_button_ = gtk_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_FULLSCREEN_INFOBAR_ALLOW).c_str());
+ deny_button_ = gtk_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_FULLSCREEN_INFOBAR_DENY).c_str());
+ gtk_box_pack_end(GTK_BOX(button_link_hbox), deny_button_, FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(button_link_hbox), allow_button_, FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(button_link_hbox), link_, FALSE, FALSE, 0);
+
+ GtkWidget* message_label = gtk_label_new(GetMessage(url_).c_str());
+
+ gtk_box_pack_start(GTK_BOX(hbox), message_label, FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(hbox), button_link_hbox, FALSE, FALSE, 0);
+
+ GtkWidget* bubble = gtk_util::CreateGtkBorderBin(
+ hbox, &ui::kGdkWhite,
+ kPaddingPx, kPaddingPx, kPaddingPx, kPaddingPx);
+ gtk_util::ActAsRoundedWindow(bubble, kFrameColor, 3,
+ gtk_util::ROUNDED_ALL, gtk_util::BORDER_ALL);
+ GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
+ gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 5, 0, 0, 0);
+ gtk_container_add(GTK_CONTAINER(alignment), bubble);
+ ui_container_.Own(alignment);
+
+ slide_widget_.reset(new SlideAnimatorGtk(ui_container_.get(),
SlideAnimatorGtk::DOWN, kSlideOutDurationMs, false, false, NULL));
gtk_widget_set_name(widget(), "exit-fullscreen-bubble");
- gtk_widget_show_all(link_container_.get());
+ gtk_widget_show_all(ui_container_.get());
gtk_widget_show(widget());
slide_widget_->OpenWithoutAnimation();
gtk_floating_container_add_floating(GTK_FLOATING_CONTAINER(container_),
widget());
+
+ // The widget needs to not change size when the allow/deny buttons are
+ // replaced by the exit link, so we wrap the buttons and the link in their
+ // own HBox, and force its size to be the max of the two sizes.
+ GtkRequisition req;
+ int button_width = 0;
+ gtk_widget_size_request(allow_button_, &req);
+ button_width += req.width;
+ gtk_widget_size_request(deny_button_, &req);
+ button_width += req.width;
+ button_width += ui::kControlSpacing;
+ int height = req.height;
+ gtk_widget_size_request(link_, &req);
+ int width = std::max(button_width, req.width);
+ gtk_widget_set_size_request(button_link_hbox, width, height);
+
+ gtk_widget_size_request(message_label, &req);
+ gtk_widget_set_size_request(hbox, req.width + width + kMiddlePaddingPx, -1);
+
signals_.Connect(container_, "set-floating-position",
G_CALLBACK(OnSetFloatingPositionThunk), this);
+ signals_.Connect(link_, "clicked", G_CALLBACK(OnLinkClickedThunk), this);
+ signals_.Connect(allow_button_, "clicked",
+ G_CALLBACK(&OnAllowClickedThunk), this);
+ signals_.Connect(deny_button_, "clicked",
+ G_CALLBACK(&OnDenyClickedThunk), this);
+ gtk_widget_hide(link_);
+ if (!show_buttons_) {
+ HideButtons();
+ }
+}
+
+std::string FullscreenExitBubbleGtk::GetMessage(const GURL& url) {
+ if (url.is_empty()) {
+ return l10n_util::GetStringUTF8(
+ IDS_FULLSCREEN_INFOBAR_USER_ENTERED_FULLSCREEN);
+ }
+ if (url.SchemeIsFile())
+ return l10n_util::GetStringUTF8(IDS_FULLSCREEN_INFOBAR_FILE_PAGE_NAME);
+ return l10n_util::GetStringFUTF8(IDS_FULLSCREEN_INFOBAR_REQUEST_PERMISSION,
+ UTF8ToUTF16(url.host()));
}
gfx::Rect FullscreenExitBubbleGtk::GetPopupRect(
bool ignore_animation_state) const {
GtkRequisition bubble_size;
if (ignore_animation_state) {
- gtk_widget_size_request(link_container_.get(), &bubble_size);
+ gtk_widget_size_request(ui_container_.get(), &bubble_size);
} else {
gtk_widget_size_request(widget(), &bubble_size);
}
@@ -144,3 +201,18 @@ void FullscreenExitBubbleGtk::OnSetFloatingPosition(
void FullscreenExitBubbleGtk::OnLinkClicked(GtkWidget* link) {
ToggleFullscreen();
}
+
+void FullscreenExitBubbleGtk::HideButtons() {
+ gtk_widget_hide(allow_button_);
+ gtk_widget_hide(deny_button_);
+ gtk_widget_show(link_);
+ StartWatchingMouse();
+}
+
+void FullscreenExitBubbleGtk::OnAllowClicked(GtkWidget* button) {
+ AcceptFullscreen(url_);
+ HideButtons();
+}
+void FullscreenExitBubbleGtk::OnDenyClicked(GtkWidget* button) {
+ CancelFullscreen();
+}
« no previous file with comments | « chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698