Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: chrome/browser/gtk/extension_install_prompt_gtk.cc

Issue 3106033: Don't line wrap on the extension uninstall dialog. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 //
5 // Currently this file is only used for the uninstall prompt. The install prompt
6 // code is in extension_install_prompt2_gtk.cc.
4 7
5 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
6 9
7 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
8 #include "base/string_util.h" 11 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/browser_list.h" 13 #include "chrome/browser/browser_list.h"
11 #include "chrome/browser/browser_window.h" 14 #include "chrome/browser/browser_window.h"
12 #include "chrome/browser/extensions/extension_install_ui.h" 15 #include "chrome/browser/extensions/extension_install_ui.h"
13 #include "chrome/browser/gtk/browser_window_gtk.h" 16 #include "chrome/browser/gtk/browser_window_gtk.h"
14 #include "chrome/browser/gtk/gtk_util.h" 17 #include "chrome/browser/gtk/gtk_util.h"
15 #include "chrome/common/extensions/extension.h" 18 #include "chrome/common/extensions/extension.h"
16 #include "gfx/gtk_util.h" 19 #include "gfx/gtk_util.h"
17 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
18 21
19 class Profile; 22 class Profile;
20 23
21 namespace { 24 namespace {
22 25
23 const int kRightColumnWidth = 290;
24
25 // Left or right margin. 26 // Left or right margin.
26 const int kPanelHorizMargin = 13; 27 const int kPanelHorizMargin = 13;
27 28
28 GtkWidget* MakeMarkupLabel(const char* format, const std::string& str) { 29 GtkWidget* MakeMarkupLabel(const char* format, const std::string& str) {
29 GtkWidget* label = gtk_label_new(NULL); 30 GtkWidget* label = gtk_label_new(NULL);
30 char* markup = g_markup_printf_escaped(format, str.c_str()); 31 char* markup = g_markup_printf_escaped(format, str.c_str());
31 gtk_label_set_markup(GTK_LABEL(label), markup); 32 gtk_label_set_markup(GTK_LABEL(label), markup);
32 g_free(markup); 33 g_free(markup);
33 34
34 // Left align it. 35 // Left align it.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // Create a new vbox for the right column. 84 // Create a new vbox for the right column.
84 GtkWidget* right_column_area = gtk_vbox_new(FALSE, 0); 85 GtkWidget* right_column_area = gtk_vbox_new(FALSE, 0);
85 gtk_box_pack_start(GTK_BOX(icon_hbox), right_column_area, TRUE, TRUE, 0); 86 gtk_box_pack_start(GTK_BOX(icon_hbox), right_column_area, TRUE, TRUE, 0);
86 87
87 int heading_id = ExtensionInstallUI::kHeadingIds[type]; 88 int heading_id = ExtensionInstallUI::kHeadingIds[type];
88 std::string heading_text = l10n_util::GetStringFUTF8( 89 std::string heading_text = l10n_util::GetStringFUTF8(
89 heading_id, UTF8ToUTF16(extension->name())); 90 heading_id, UTF8ToUTF16(extension->name()));
90 GtkWidget* heading_label = MakeMarkupLabel("<span weight=\"bold\">%s</span>", 91 GtkWidget* heading_label = MakeMarkupLabel("<span weight=\"bold\">%s</span>",
91 heading_text); 92 heading_text);
92 gtk_misc_set_alignment(GTK_MISC(heading_label), 0.0, 0.5); 93 gtk_misc_set_alignment(GTK_MISC(heading_label), 0.0, 0.5);
93 gtk_label_set_selectable(GTK_LABEL(heading_label), TRUE);
94 gtk_box_pack_start(GTK_BOX(right_column_area), heading_label, TRUE, TRUE, 0); 94 gtk_box_pack_start(GTK_BOX(right_column_area), heading_label, TRUE, TRUE, 0);
95 95
96 GtkWidget* warning_label = gtk_label_new(UTF16ToUTF8(warning_text).c_str()); 96 GtkWidget* warning_label = gtk_label_new(UTF16ToUTF8(warning_text).c_str());
97 gtk_label_set_line_wrap(GTK_LABEL(warning_label), TRUE);
98 gtk_widget_set_size_request(warning_label, kRightColumnWidth, -1);
99 gtk_misc_set_alignment(GTK_MISC(warning_label), 0.0, 0.5); 97 gtk_misc_set_alignment(GTK_MISC(warning_label), 0.0, 0.5);
100 gtk_label_set_selectable(GTK_LABEL(warning_label), TRUE);
101 gtk_box_pack_start(GTK_BOX(right_column_area), warning_label, TRUE, TRUE, 0); 98 gtk_box_pack_start(GTK_BOX(right_column_area), warning_label, TRUE, TRUE, 0);
102 99
103 g_signal_connect(dialog, "response", G_CALLBACK(OnDialogResponse), delegate); 100 g_signal_connect(dialog, "response", G_CALLBACK(OnDialogResponse), delegate);
104 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); 101 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
105 gtk_widget_show_all(dialog); 102 gtk_widget_show_all(dialog);
106 } 103 }
107 104
108 } // namespace 105 } // namespace
109 106
110 void ExtensionInstallUI::ShowExtensionInstallUIPromptImpl( 107 void ExtensionInstallUI::ShowExtensionInstallUIPromptImpl(
111 Profile* profile, Delegate* delegate, Extension* extension, SkBitmap* icon, 108 Profile* profile, Delegate* delegate, Extension* extension, SkBitmap* icon,
112 const string16& warning_text, ExtensionInstallUI::PromptType type) { 109 const string16& warning_text, ExtensionInstallUI::PromptType type) {
113 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); 110 Browser* browser = BrowserList::GetLastActiveWithProfile(profile);
114 if (!browser) { 111 if (!browser) {
115 delegate->InstallUIAbort(); 112 delegate->InstallUIAbort();
116 return; 113 return;
117 } 114 }
118 115
119 BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>( 116 BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>(
120 browser->window()); 117 browser->window());
121 if (!browser_window) { 118 if (!browser_window) {
122 delegate->InstallUIAbort(); 119 delegate->InstallUIAbort();
123 return; 120 return;
124 } 121 }
125 122
126 ShowInstallPromptDialog(browser_window->window(), icon, extension, 123 ShowInstallPromptDialog(browser_window->window(), icon, extension,
127 delegate, warning_text, type); 124 delegate, warning_text, type);
128 } 125 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698