| 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 "chrome/browser/ui/gtk/gtk_chrome_link_button.h" | 7 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" |
| 8 #include "chrome/browser/ui/gtk/gtk_util.h" | 8 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 9 #include "chrome/browser/ui/gtk/rounded_window.h" | 9 #include "chrome/browser/ui/gtk/rounded_window.h" |
| 10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
| 11 #include "grit/ui_strings.h" | 11 #include "grit/ui_strings.h" |
| 12 #include "ui/base/gtk/gtk_floating_container.h" | 12 #include "ui/base/gtk/gtk_floating_container.h" |
| 13 #include "ui/base/gtk/gtk_hig_constants.h" | 13 #include "ui/base/gtk/gtk_hig_constants.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "chrome/browser/ui/browser.h" |
| 15 | 16 |
| 16 FullscreenExitBubbleGtk::FullscreenExitBubbleGtk( | 17 FullscreenExitBubbleGtk::FullscreenExitBubbleGtk( |
| 17 GtkFloatingContainer* container, | 18 GtkFloatingContainer* container, |
| 18 CommandUpdater::CommandUpdaterDelegate* delegate) | 19 Browser* browser, |
| 19 : FullscreenExitBubble(delegate), | 20 const GURL& url, |
| 20 container_(container) { | 21 bool ask_permission) |
| 22 : FullscreenExitBubble(browser), |
| 23 container_(container), |
| 24 url_(url), |
| 25 show_buttons_(ask_permission) { |
| 21 InitWidgets(); | 26 InitWidgets(); |
| 22 StartWatchingMouse(); | 27 StartWatchingMouse(); |
| 23 } | 28 } |
| 24 | 29 |
| 25 FullscreenExitBubbleGtk::~FullscreenExitBubbleGtk() { | 30 FullscreenExitBubbleGtk::~FullscreenExitBubbleGtk() { |
| 26 } | 31 } |
| 27 | 32 |
| 28 void FullscreenExitBubbleGtk::InitWidgets() { | 33 void FullscreenExitBubbleGtk::InitWidgets() { |
| 29 // The exit bubble is a gtk_chrome_link_button inside a gtk event box and gtk | 34 // The exit bubble is a gtk_chrome_link_button inside a gtk event box and gtk |
| 30 // alignment (these provide the background color). This is then made rounded | 35 // alignment (these provide the background color). This is then made rounded |
| 31 // and put into a slide widget. | 36 // and put into a slide widget. |
| 32 | 37 |
| 33 // The Windows code actually looks up the accelerator key in the accelerator | 38 // The Windows code actually looks up the accelerator key in the accelerator |
| 34 // table and then converts the key to a string (in a switch statement). This | 39 // table and then converts the key to a string (in a switch statement). This |
| 35 // doesn't seem to be implemented for Gtk, so we just use F11 directly. | 40 // doesn't seem to be implemented for Gtk, so we just use F11 directly. |
| 36 std::string exit_text_utf8("<span color=\"white\" size=\"large\">"); | 41 std::string exit_text_utf8("<span color=\"white\" size=\"large\">"); |
| 37 exit_text_utf8.append(l10n_util::GetStringFUTF8( | 42 exit_text_utf8.append(l10n_util::GetStringFUTF8( |
| 38 IDS_EXIT_FULLSCREEN_MODE, l10n_util::GetStringUTF16(IDS_APP_F11_KEY))); | 43 IDS_EXIT_FULLSCREEN_MODE, l10n_util::GetStringUTF16(IDS_APP_F11_KEY))); |
| 39 exit_text_utf8.append("</span>"); | 44 exit_text_utf8.append("</span>"); |
| 40 GtkWidget* link = gtk_chrome_link_button_new_with_markup( | 45 GtkWidget* link = gtk_chrome_link_button_new_with_markup( |
| 41 exit_text_utf8.c_str()); | 46 exit_text_utf8.c_str()); |
| 42 gtk_chrome_link_button_set_use_gtk_theme(GTK_CHROME_LINK_BUTTON(link), | 47 gtk_chrome_link_button_set_use_gtk_theme(GTK_CHROME_LINK_BUTTON(link), |
| 43 FALSE); | 48 FALSE); |
| 44 signals_.Connect(link, "clicked", G_CALLBACK(OnLinkClickedThunk), this); | 49 signals_.Connect(link, "clicked", G_CALLBACK(OnLinkClickedThunk), this); |
| 45 | 50 |
| 51 // hbox |
| 52 GtkWidget* hbox_ = gtk_hbox_new(FALSE, kPaddingPx); |
| 53 |
| 54 gtk_box_pack_end(GTK_BOX(hbox_), link, FALSE, FALSE, 0); |
| 55 |
| 56 if (show_buttons_) { |
| 57 // Add buttons |
| 58 GtkWidget* deny_button = gtk_button_new_with_label("Deny"); |
| 59 gtk_box_pack_end(GTK_BOX(hbox_), deny_button, FALSE, FALSE, 0); |
| 60 GtkWidget* allow_button = gtk_button_new_with_label("Allow"); |
| 61 gtk_box_pack_end(GTK_BOX(hbox_), allow_button, FALSE, FALSE, 0); |
| 62 |
| 63 g_signal_connect(allow_button, "clicked", |
| 64 G_CALLBACK(OnAllowClickedThunk), |
| 65 this); |
| 66 |
| 67 g_signal_connect(deny_button, "clicked", |
| 68 G_CALLBACK(OnDenyClickedThunk), |
| 69 this); |
| 70 } |
| 71 |
| 46 link_container_.Own(gtk_util::CreateGtkBorderBin( | 72 link_container_.Own(gtk_util::CreateGtkBorderBin( |
| 47 link, &ui::kGdkBlack, | 73 link, &ui::kGdkBlack, |
| 48 kPaddingPx, kPaddingPx, kPaddingPx, kPaddingPx)); | 74 kPaddingPx, kPaddingPx, kPaddingPx, kPaddingPx)); |
| 49 GdkColor green = GDK_COLOR_RGB(0x00, 0xff, 0x00); | 75 GdkColor green = GDK_COLOR_RGB(0x00, 0xff, 0x00); |
| 50 gtk_util::ActAsRoundedWindow(link_container_.get(), green, kPaddingPx, | 76 gtk_util::ActAsRoundedWindow(link_container_.get(), green, kPaddingPx, |
| 51 gtk_util::ROUNDED_BOTTOM_LEFT | gtk_util::ROUNDED_BOTTOM_RIGHT, | 77 gtk_util::ROUNDED_BOTTOM_LEFT | gtk_util::ROUNDED_BOTTOM_RIGHT, |
| 52 gtk_util::BORDER_NONE); | 78 gtk_util::BORDER_NONE); |
| 53 | 79 |
| 54 slide_widget_.reset(new SlideAnimatorGtk(link_container_.get(), | 80 slide_widget_.reset(new SlideAnimatorGtk(link_container_.get(), |
| 55 SlideAnimatorGtk::DOWN, kSlideOutDurationMs, false, false, NULL)); | 81 SlideAnimatorGtk::DOWN, kSlideOutDurationMs, false, false, NULL)); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 157 |
| 132 g_value_set_int(&value, 0); | 158 g_value_set_int(&value, 0); |
| 133 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 159 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
| 134 widget(), "y", &value); | 160 widget(), "y", &value); |
| 135 g_value_unset(&value); | 161 g_value_unset(&value); |
| 136 } | 162 } |
| 137 | 163 |
| 138 void FullscreenExitBubbleGtk::OnLinkClicked(GtkWidget* link) { | 164 void FullscreenExitBubbleGtk::OnLinkClicked(GtkWidget* link) { |
| 139 ToggleFullscreen(); | 165 ToggleFullscreen(); |
| 140 } | 166 } |
| 167 |
| 168 void FullscreenExitBubbleGtk::OnAllowClicked(GtkWidget* button) { |
| 169 browser_->OnAcceptFullscreenPermission(url_); |
| 170 } |
| 171 |
| 172 void FullscreenExitBubbleGtk::OnDenyClicked(GtkWidget* button) { |
| 173 ToggleFullscreen(); |
| 174 } |
| OLD | NEW |