Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.h" | 5 #include "chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" | 9 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" |
| 10 #include "chrome/browser/ui/gtk/gtk_util.h" | 10 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 11 #include "chrome/browser/ui/gtk/rounded_window.h" | 11 #include "chrome/browser/ui/gtk/rounded_window.h" |
| 12 #include "content/browser/renderer_host/render_widget_host_view.h" | 12 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 13 #include "content/browser/tab_contents/tab_contents.h" | 13 #include "content/browser/tab_contents/tab_contents.h" |
| 14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 15 #include "grit/ui_strings.h" | 15 #include "grit/ui_strings.h" |
| 16 #include "ui/base/gtk/gtk_floating_container.h" | 16 #include "ui/base/gtk/gtk_floating_container.h" |
| 17 #include "ui/base/gtk/gtk_hig_constants.h" | 17 #include "ui/base/gtk/gtk_hig_constants.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 const GdkColor kFrameColor = GDK_COLOR_RGB(0x63, 0x63, 0x63); | 21 const GdkColor kFrameColor = GDK_COLOR_RGB(0x63, 0x63, 0x63); |
| 22 const int kMiddlePaddingPx = 30; | 22 const int kMiddlePaddingPx = 30; |
| 23 } // namespace | 23 } // namespace |
| 24 | 24 |
| 25 FullscreenExitBubbleGtk::FullscreenExitBubbleGtk( | 25 FullscreenExitBubbleGtk::FullscreenExitBubbleGtk( |
| 26 GtkFloatingContainer* container, | 26 GtkFloatingContainer* container, |
| 27 Browser* browser, | 27 Browser* browser, |
| 28 const GURL& url, | 28 const GURL& url, |
| 29 FullscreenExitBubbleType bubble_type) | 29 FullscreenExitBubbleType bubble_type) |
| 30 : FullscreenExitBubble(browser, url, bubble_type), | 30 : FullscreenExitBubble(browser, url, bubble_type), |
| 31 container_(container), | 31 container_(container) { |
| 32 render_widget_host_view_widget_(browser->GetSelectedTabContents()-> | |
| 33 GetRenderWidgetHostView()->GetNativeView()) { | |
| 34 InitWidgets(); | 32 InitWidgets(); |
| 35 } | 33 } |
| 36 | 34 |
| 37 FullscreenExitBubbleGtk::~FullscreenExitBubbleGtk() { | 35 FullscreenExitBubbleGtk::~FullscreenExitBubbleGtk() { |
| 38 } | 36 } |
| 39 | 37 |
| 40 void FullscreenExitBubbleGtk::UpdateContent( | 38 void FullscreenExitBubbleGtk::UpdateContent( |
| 41 const GURL& url, | 39 const GURL& url, |
| 42 FullscreenExitBubbleType bubble_type) { | 40 FullscreenExitBubbleType bubble_type) { |
| 43 if (bubble_type == FEB_TYPE_NONE) { | 41 if (bubble_type == FEB_TYPE_NONE) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 // The exit bubble is a gtk_chrome_link_button inside a gtk event box and gtk | 76 // The exit bubble is a gtk_chrome_link_button inside a gtk event box and gtk |
| 79 // alignment (these provide the background color). This is then made rounded | 77 // alignment (these provide the background color). This is then made rounded |
| 80 // and put into a slide widget. | 78 // and put into a slide widget. |
| 81 | 79 |
| 82 // The Windows code actually looks up the accelerator key in the accelerator | 80 // The Windows code actually looks up the accelerator key in the accelerator |
| 83 // table and then converts the key to a string (in a switch statement). This | 81 // table and then converts the key to a string (in a switch statement). This |
| 84 // doesn't seem to be implemented for Gtk, so we just use F11 directly. | 82 // doesn't seem to be implemented for Gtk, so we just use F11 directly. |
| 85 std::string exit_text_utf8(l10n_util::GetStringFUTF8( | 83 std::string exit_text_utf8(l10n_util::GetStringFUTF8( |
| 86 IDS_EXIT_FULLSCREEN_MODE, l10n_util::GetStringUTF16(IDS_APP_F11_KEY))); | 84 IDS_EXIT_FULLSCREEN_MODE, l10n_util::GetStringUTF16(IDS_APP_F11_KEY))); |
| 87 | 85 |
| 88 hbox_ = gtk_hbox_new(false, ui::kControlSpacing); | 86 hbox_ = gtk_hbox_new(false, ui::kControlSpacing); |
|
scheib
2011/10/21 23:28:13
What happens if you click on any other part of the
yzshen1
2011/10/21 23:29:25
I tried and they didn't take focus.
| |
| 89 | 87 |
| 90 message_label_ = gtk_label_new(GetMessage(url_).c_str()); | 88 message_label_ = gtk_label_new(GetMessage(url_).c_str()); |
| 91 gtk_box_pack_start(GTK_BOX(hbox_), message_label_, FALSE, FALSE, 0); | 89 gtk_box_pack_start(GTK_BOX(hbox_), message_label_, FALSE, FALSE, 0); |
| 92 | 90 |
| 93 allow_button_ = gtk_button_new_with_label( | 91 allow_button_ = gtk_button_new_with_label( |
| 94 l10n_util::GetStringUTF8(IDS_FULLSCREEN_ALLOW).c_str()); | 92 l10n_util::GetStringUTF8(IDS_FULLSCREEN_ALLOW).c_str()); |
| 93 gtk_widget_set_can_focus(allow_button_, FALSE); | |
| 95 gtk_widget_set_no_show_all(allow_button_, FALSE); | 94 gtk_widget_set_no_show_all(allow_button_, FALSE); |
| 96 gtk_box_pack_start(GTK_BOX(hbox_), allow_button_, FALSE, FALSE, 0); | 95 gtk_box_pack_start(GTK_BOX(hbox_), allow_button_, FALSE, FALSE, 0); |
| 97 | 96 |
| 98 deny_button_ = gtk_button_new_with_label( | 97 deny_button_ = gtk_button_new_with_label( |
| 99 l10n_util::GetStringUTF8(IDS_FULLSCREEN_DENY).c_str()); | 98 l10n_util::GetStringUTF8(IDS_FULLSCREEN_DENY).c_str()); |
| 99 gtk_widget_set_can_focus(deny_button_, FALSE); | |
| 100 gtk_widget_set_no_show_all(deny_button_, FALSE); | 100 gtk_widget_set_no_show_all(deny_button_, FALSE); |
| 101 gtk_box_pack_start(GTK_BOX(hbox_), deny_button_, FALSE, FALSE, 0); | 101 gtk_box_pack_start(GTK_BOX(hbox_), deny_button_, FALSE, FALSE, 0); |
| 102 | 102 |
| 103 link_ = gtk_chrome_link_button_new(exit_text_utf8.c_str()); | 103 link_ = gtk_chrome_link_button_new(exit_text_utf8.c_str()); |
| 104 gtk_widget_set_can_focus(link_, FALSE); | |
| 104 gtk_widget_set_no_show_all(link_, FALSE); | 105 gtk_widget_set_no_show_all(link_, FALSE); |
| 105 gtk_chrome_link_button_set_use_gtk_theme(GTK_CHROME_LINK_BUTTON(link_), | 106 gtk_chrome_link_button_set_use_gtk_theme(GTK_CHROME_LINK_BUTTON(link_), |
| 106 FALSE); | 107 FALSE); |
| 107 gtk_box_pack_start(GTK_BOX(hbox_), link_, FALSE, FALSE, 0); | 108 gtk_box_pack_start(GTK_BOX(hbox_), link_, FALSE, FALSE, 0); |
| 108 | 109 |
| 109 | |
| 110 instruction_label_ = gtk_label_new(UTF16ToUTF8(GetInstructionText()).c_str()); | 110 instruction_label_ = gtk_label_new(UTF16ToUTF8(GetInstructionText()).c_str()); |
| 111 gtk_widget_set_no_show_all(instruction_label_, FALSE); | 111 gtk_widget_set_no_show_all(instruction_label_, FALSE); |
| 112 gtk_box_pack_start(GTK_BOX(hbox_), instruction_label_, FALSE, FALSE, 0); | 112 gtk_box_pack_start(GTK_BOX(hbox_), instruction_label_, FALSE, FALSE, 0); |
| 113 | 113 |
| 114 | |
| 115 GtkWidget* bubble = gtk_util::CreateGtkBorderBin( | 114 GtkWidget* bubble = gtk_util::CreateGtkBorderBin( |
| 116 hbox_, &ui::kGdkWhite, | 115 hbox_, &ui::kGdkWhite, |
| 117 kPaddingPx, kPaddingPx, kPaddingPx, kPaddingPx); | 116 kPaddingPx, kPaddingPx, kPaddingPx, kPaddingPx); |
| 118 gtk_util::ActAsRoundedWindow(bubble, kFrameColor, 3, | 117 gtk_util::ActAsRoundedWindow(bubble, kFrameColor, 3, |
| 119 gtk_util::ROUNDED_ALL, gtk_util::BORDER_ALL); | 118 gtk_util::ROUNDED_ALL, gtk_util::BORDER_ALL); |
| 120 GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); | 119 GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); |
| 121 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 5, 0, 0, 0); | 120 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 5, 0, 0, 0); |
| 122 gtk_container_add(GTK_CONTAINER(alignment), bubble); | 121 gtk_container_add(GTK_CONTAINER(alignment), bubble); |
| 123 ui_container_.Own(alignment); | 122 ui_container_.Own(alignment); |
| 124 | 123 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 223 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
| 225 widget(), "x", &value); | 224 widget(), "x", &value); |
| 226 | 225 |
| 227 g_value_set_int(&value, 0); | 226 g_value_set_int(&value, 0); |
| 228 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 227 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
| 229 widget(), "y", &value); | 228 widget(), "y", &value); |
| 230 g_value_unset(&value); | 229 g_value_unset(&value); |
| 231 } | 230 } |
| 232 | 231 |
| 233 void FullscreenExitBubbleGtk::OnLinkClicked(GtkWidget* link) { | 232 void FullscreenExitBubbleGtk::OnLinkClicked(GtkWidget* link) { |
| 234 gtk_widget_grab_focus(render_widget_host_view_widget_); | |
| 235 ToggleFullscreen(); | 233 ToggleFullscreen(); |
| 236 } | 234 } |
| 237 | 235 |
| 238 void FullscreenExitBubbleGtk::OnAllowClicked(GtkWidget* button) { | 236 void FullscreenExitBubbleGtk::OnAllowClicked(GtkWidget* button) { |
| 239 gtk_widget_grab_focus(render_widget_host_view_widget_); | |
| 240 Accept(); | 237 Accept(); |
| 241 UpdateContent(url_, bubble_type_); | 238 UpdateContent(url_, bubble_type_); |
| 242 } | 239 } |
| 243 void FullscreenExitBubbleGtk::OnDenyClicked(GtkWidget* button) { | 240 void FullscreenExitBubbleGtk::OnDenyClicked(GtkWidget* button) { |
| 244 gtk_widget_grab_focus(render_widget_host_view_widget_); | |
| 245 Cancel(); | 241 Cancel(); |
| 246 } | 242 } |
| OLD | NEW |