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 <gtk/gtk.h> | 5 #include <gtk/gtk.h> |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/extensions/extension_install_dialog.h" | 9 #include "chrome/browser/extensions/extension_install_dialog.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/browser_list.h" | 11 #include "chrome/browser/ui/browser_list.h" |
12 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
13 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 13 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
14 #include "chrome/browser/ui/gtk/gtk_util.h" | 14 #include "chrome/browser/ui/gtk/gtk_util.h" |
15 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
16 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
17 #include "skia/ext/image_operations.h" | 17 #include "skia/ext/image_operations.h" |
| 18 #include "ui/base/gtk/gtk_hig_constants.h" |
18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
19 #include "ui/gfx/gtk_util.h" | 20 #include "ui/gfx/gtk_util.h" |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 const int kRightColumnMinWidth = 290; | 24 const int kRightColumnMinWidth = 290; |
24 const int kImageSize = 69; | 25 const int kImageSize = 69; |
25 | 26 |
26 // Padding on all sides of each permission in the permissions list. | 27 // Padding on all sides of each permission in the permissions list. |
27 const int kPermissionsPadding = 8; | 28 const int kPermissionsPadding = 8; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 cancel > 0 ? l10n_util::GetStringUTF8(cancel).c_str(): GTK_STOCK_CANCEL, | 69 cancel > 0 ? l10n_util::GetStringUTF8(cancel).c_str(): GTK_STOCK_CANCEL, |
69 GTK_RESPONSE_CLOSE); | 70 GTK_RESPONSE_CLOSE); |
70 gtk_dialog_add_button( | 71 gtk_dialog_add_button( |
71 GTK_DIALOG(dialog), | 72 GTK_DIALOG(dialog), |
72 l10n_util::GetStringUTF8(ExtensionInstallUI::kButtonIds[type]).c_str(), | 73 l10n_util::GetStringUTF8(ExtensionInstallUI::kButtonIds[type]).c_str(), |
73 GTK_RESPONSE_ACCEPT); | 74 GTK_RESPONSE_ACCEPT); |
74 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | 75 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
75 | 76 |
76 // Create a two column layout. | 77 // Create a two column layout. |
77 GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); | 78 GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); |
78 gtk_box_set_spacing(GTK_BOX(content_area), gtk_util::kContentAreaSpacing); | 79 gtk_box_set_spacing(GTK_BOX(content_area), ui::kContentAreaSpacing); |
79 | 80 |
80 GtkWidget* icon_hbox = gtk_hbox_new(FALSE, gtk_util::kContentAreaSpacing); | 81 GtkWidget* icon_hbox = gtk_hbox_new(FALSE, ui::kContentAreaSpacing); |
81 gtk_box_pack_start(GTK_BOX(content_area), icon_hbox, TRUE, TRUE, 0); | 82 gtk_box_pack_start(GTK_BOX(content_area), icon_hbox, TRUE, TRUE, 0); |
82 | 83 |
83 // Resize the icon if necessary. | 84 // Resize the icon if necessary. |
84 SkBitmap scaled_icon = *skia_icon; | 85 SkBitmap scaled_icon = *skia_icon; |
85 if (scaled_icon.width() > kImageSize || scaled_icon.height() > kImageSize) { | 86 if (scaled_icon.width() > kImageSize || scaled_icon.height() > kImageSize) { |
86 scaled_icon = skia::ImageOperations::Resize(scaled_icon, | 87 scaled_icon = skia::ImageOperations::Resize(scaled_icon, |
87 skia::ImageOperations::RESIZE_LANCZOS3, | 88 skia::ImageOperations::RESIZE_LANCZOS3, |
88 kImageSize, kImageSize); | 89 kImageSize, kImageSize); |
89 } | 90 } |
90 | 91 |
91 // Put Icon in the left column. | 92 // Put Icon in the left column. |
92 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&scaled_icon); | 93 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&scaled_icon); |
93 GtkWidget* icon = gtk_image_new_from_pixbuf(pixbuf); | 94 GtkWidget* icon = gtk_image_new_from_pixbuf(pixbuf); |
94 g_object_unref(pixbuf); | 95 g_object_unref(pixbuf); |
95 gtk_box_pack_start(GTK_BOX(icon_hbox), icon, FALSE, FALSE, 0); | 96 gtk_box_pack_start(GTK_BOX(icon_hbox), icon, FALSE, FALSE, 0); |
96 // Top justify the image. | 97 // Top justify the image. |
97 gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0); | 98 gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0); |
98 | 99 |
99 // Create a new vbox for the right column. | 100 // Create a new vbox for the right column. |
100 GtkWidget* right_column_area = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); | 101 GtkWidget* right_column_area = gtk_vbox_new(FALSE, ui::kControlSpacing); |
101 gtk_box_pack_start(GTK_BOX(icon_hbox), right_column_area, TRUE, TRUE, 0); | 102 gtk_box_pack_start(GTK_BOX(icon_hbox), right_column_area, TRUE, TRUE, 0); |
102 | 103 |
103 std::string heading_text = l10n_util::GetStringFUTF8( | 104 std::string heading_text = l10n_util::GetStringFUTF8( |
104 ExtensionInstallUI::kHeadingIds[type], UTF8ToUTF16(extension->name())); | 105 ExtensionInstallUI::kHeadingIds[type], UTF8ToUTF16(extension->name())); |
105 GtkWidget* heading_label = MakeMarkupLabel("<span weight=\"bold\">%s</span>", | 106 GtkWidget* heading_label = MakeMarkupLabel("<span weight=\"bold\">%s</span>", |
106 heading_text); | 107 heading_text); |
107 gtk_label_set_line_wrap(GTK_LABEL(heading_label), true); | 108 gtk_label_set_line_wrap(GTK_LABEL(heading_label), true); |
108 gtk_misc_set_alignment(GTK_MISC(heading_label), 0.0, 0.5); | 109 gtk_misc_set_alignment(GTK_MISC(heading_label), 0.0, 0.5); |
109 bool show_permissions = !permissions.empty(); | 110 bool show_permissions = !permissions.empty(); |
110 // If we are not going to show the permissions, vertically center the title. | 111 // If we are not going to show the permissions, vertically center the title. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>( | 189 BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>( |
189 browser->window()); | 190 browser->window()); |
190 if (!browser_window) { | 191 if (!browser_window) { |
191 delegate->InstallUIAbort(false); | 192 delegate->InstallUIAbort(false); |
192 return; | 193 return; |
193 } | 194 } |
194 | 195 |
195 ShowInstallDialog( | 196 ShowInstallDialog( |
196 browser_window->window(), icon, extension, delegate, permissions, type); | 197 browser_window->window(), icon, extension, delegate, permissions, type); |
197 } | 198 } |
OLD | NEW |