Chromium Code Reviews| 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..fc44b31c26a31b55d22915c18aaa86de6fd1b67e 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 |
|
tony
2011/10/14 17:56:05
Nit: 2 spaces before //. Why didn't the presubmit
jeremya
2011/10/15 01:44:55
Done. Not sure why the presubmit didn't pick up on
|
| + |
| 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()); |
|
tony
2011/10/14 17:56:05
Do you have a screenshot of what this looks like a
jeremya
2011/10/15 01:44:55
The mock (http://www.corp.google.com/~glen/chrome/
|
| + 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); |
| + |
| + // 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. |
| + 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, |
|
tony
2011/10/14 17:56:05
Is this supposed to be a fixed frame color or shou
jeremya
2011/10/15 01:44:55
BubbleGtk seems to use a fixed frame color.
|
| + 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()); |
| + |
| + GtkRequisition req; |
|
tony
2011/10/14 17:56:05
I would move the size comment on lines 54-56 here.
jeremya
2011/10/15 01:44:55
Done.
|
| + 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); |
|
tony
2011/10/14 17:56:05
Should the contents of the hbox be horizontally ce
jeremya
2011/10/15 01:44:55
You mean vertically..?
|
| + |
| + 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(); |
| +} |