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/browser.h" | |
7 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" | 8 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" |
8 #include "chrome/browser/ui/gtk/gtk_util.h" | 9 #include "chrome/browser/ui/gtk/gtk_util.h" |
9 #include "chrome/browser/ui/gtk/rounded_window.h" | 10 #include "chrome/browser/ui/gtk/rounded_window.h" |
10 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
11 #include "grit/ui_strings.h" | 12 #include "grit/ui_strings.h" |
12 #include "ui/base/gtk/gtk_floating_container.h" | 13 #include "ui/base/gtk/gtk_floating_container.h" |
13 #include "ui/base/gtk/gtk_hig_constants.h" | 14 #include "ui/base/gtk/gtk_hig_constants.h" |
14 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.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 |
tony
2011/10/14 17:29:56
Nit: stray blank line. Maybe convert to a TODO()
| |
51 | |
46 link_container_.Own(gtk_util::CreateGtkBorderBin( | 52 link_container_.Own(gtk_util::CreateGtkBorderBin( |
47 link, &ui::kGdkBlack, | 53 link, &ui::kGdkBlack, |
48 kPaddingPx, kPaddingPx, kPaddingPx, kPaddingPx)); | 54 kPaddingPx, kPaddingPx, kPaddingPx, kPaddingPx)); |
49 GdkColor green = GDK_COLOR_RGB(0x00, 0xff, 0x00); | 55 GdkColor green = GDK_COLOR_RGB(0x00, 0xff, 0x00); |
50 gtk_util::ActAsRoundedWindow(link_container_.get(), green, kPaddingPx, | 56 gtk_util::ActAsRoundedWindow(link_container_.get(), green, kPaddingPx, |
51 gtk_util::ROUNDED_BOTTOM_LEFT | gtk_util::ROUNDED_BOTTOM_RIGHT, | 57 gtk_util::ROUNDED_BOTTOM_LEFT | gtk_util::ROUNDED_BOTTOM_RIGHT, |
52 gtk_util::BORDER_NONE); | 58 gtk_util::BORDER_NONE); |
53 | 59 |
54 slide_widget_.reset(new SlideAnimatorGtk(link_container_.get(), | 60 slide_widget_.reset(new SlideAnimatorGtk(link_container_.get(), |
55 SlideAnimatorGtk::DOWN, kSlideOutDurationMs, false, false, NULL)); | 61 SlideAnimatorGtk::DOWN, kSlideOutDurationMs, false, false, NULL)); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 | 137 |
132 g_value_set_int(&value, 0); | 138 g_value_set_int(&value, 0); |
133 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 139 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
134 widget(), "y", &value); | 140 widget(), "y", &value); |
135 g_value_unset(&value); | 141 g_value_unset(&value); |
136 } | 142 } |
137 | 143 |
138 void FullscreenExitBubbleGtk::OnLinkClicked(GtkWidget* link) { | 144 void FullscreenExitBubbleGtk::OnLinkClicked(GtkWidget* link) { |
139 ToggleFullscreen(); | 145 ToggleFullscreen(); |
140 } | 146 } |
OLD | NEW |