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

Side by Side Diff: chrome/browser/ui/gtk/extensions/extension_install_dialog_gtk.cc

Issue 10915196: [gtk] fix title wrapping on extension install dialog (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: synced Created 8 years, 3 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 | Annotate | Revision Log
« 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/extensions/bundle_installer.h" 10 #include "chrome/browser/extensions/bundle_installer.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // Divide the dialog vertically (item data and icon on the top, permissions 144 // Divide the dialog vertically (item data and icon on the top, permissions
145 // on the bottom). 145 // on the bottom).
146 GtkWidget* content_vbox = gtk_vbox_new(FALSE, ui::kControlSpacing); 146 GtkWidget* content_vbox = gtk_vbox_new(FALSE, ui::kControlSpacing);
147 gtk_box_pack_start(GTK_BOX(content_area), content_vbox, TRUE, TRUE, 0); 147 gtk_box_pack_start(GTK_BOX(content_area), content_vbox, TRUE, TRUE, 0);
148 148
149 // Create a two column layout for the top (item data on the left, icon on 149 // Create a two column layout for the top (item data on the left, icon on
150 // the right). 150 // the right).
151 GtkWidget* top_content_hbox = gtk_hbox_new(FALSE, ui::kContentAreaSpacing); 151 GtkWidget* top_content_hbox = gtk_hbox_new(FALSE, ui::kContentAreaSpacing);
152 gtk_box_pack_start(GTK_BOX(content_vbox), top_content_hbox, TRUE, TRUE, 0); 152 gtk_box_pack_start(GTK_BOX(content_vbox), top_content_hbox, TRUE, TRUE, 0);
153 153
154 // We don't show the image for bunle installs, so let the left column take up
155 // that space.
156 const int left_column_min_width =
157 kLeftColumnMinWidth + (is_bundle_install ? kImageSize : 0);
158
154 // Create a new vbox for the left column. 159 // Create a new vbox for the left column.
155 GtkWidget* left_column_area = gtk_vbox_new(FALSE, ui::kControlSpacing); 160 GtkWidget* left_column_area = gtk_vbox_new(FALSE, ui::kControlSpacing);
156 gtk_box_pack_start(GTK_BOX(top_content_hbox), left_column_area, 161 gtk_box_pack_start(GTK_BOX(top_content_hbox), left_column_area,
157 TRUE, TRUE, 0); 162 TRUE, TRUE, 0);
158 gtk_widget_set_size_request(left_column_area, kLeftColumnMinWidth, -1); 163 gtk_widget_set_size_request(left_column_area, left_column_min_width, -1);
159 164
160 GtkWidget* heading_vbox = gtk_vbox_new(FALSE, 0); 165 GtkWidget* heading_vbox = gtk_vbox_new(FALSE, 0);
161 // If we are not going to show anything else, vertically center the title. 166 // If we are not going to show anything else, vertically center the title.
162 bool center_heading = 167 bool center_heading =
163 !show_permissions && !show_oauth_issues && !is_inline_install; 168 !show_permissions && !show_oauth_issues && !is_inline_install;
164 gtk_box_pack_start(GTK_BOX(left_column_area), heading_vbox, center_heading, 169 gtk_box_pack_start(GTK_BOX(left_column_area), heading_vbox, center_heading,
165 center_heading, 0); 170 center_heading, 0);
166 171
167 // Heading 172 // Heading
168 GtkWidget* heading_label = gtk_util::CreateBoldLabel( 173 GtkWidget* heading_label = gtk_util::CreateBoldLabel(
169 UTF16ToUTF8(prompt.GetHeading().c_str())); 174 UTF16ToUTF8(prompt.GetHeading().c_str()));
170 gtk_label_set_line_wrap(GTK_LABEL(heading_label), true); 175 gtk_util::SetLabelWidth(heading_label, left_column_min_width);
171 gtk_misc_set_alignment(GTK_MISC(heading_label), 0.0, 0.5);
172 gtk_box_pack_start(GTK_BOX(heading_vbox), heading_label, center_heading, 176 gtk_box_pack_start(GTK_BOX(heading_vbox), heading_label, center_heading,
173 center_heading, 0); 177 center_heading, 0);
174 178
175 if (is_inline_install) { 179 if (is_inline_install) {
176 // Average rating (as stars) and number of ratings. 180 // Average rating (as stars) and number of ratings.
177 GtkWidget* stars_hbox = gtk_hbox_new(FALSE, 0); 181 GtkWidget* stars_hbox = gtk_hbox_new(FALSE, 0);
178 gtk_box_pack_start(GTK_BOX(heading_vbox), stars_hbox, FALSE, FALSE, 0); 182 gtk_box_pack_start(GTK_BOX(heading_vbox), stars_hbox, FALSE, FALSE, 0);
179 prompt.AppendRatingStars(AddResourceIcon, stars_hbox); 183 prompt.AppendRatingStars(AddResourceIcon, stars_hbox);
180 GtkWidget* rating_label = gtk_label_new(UTF16ToUTF8( 184 GtkWidget* rating_label = gtk_label_new(UTF16ToUTF8(
181 prompt.GetRatingCount()).c_str()); 185 prompt.GetRatingCount()).c_str());
182 gtk_util::ForceFontSizePixels(rating_label, kRatingTextSize); 186 gtk_util::ForceFontSizePixels(rating_label, kRatingTextSize);
183 gtk_box_pack_start(GTK_BOX(stars_hbox), rating_label, 187 gtk_box_pack_start(GTK_BOX(stars_hbox), rating_label,
184 FALSE, FALSE, 3); 188 FALSE, FALSE, 3);
185 189
186 // User count. 190 // User count.
187 GtkWidget* users_label = gtk_label_new(UTF16ToUTF8( 191 GtkWidget* users_label = gtk_label_new(UTF16ToUTF8(
188 prompt.GetUserCount()).c_str()); 192 prompt.GetUserCount()).c_str());
189 gtk_util::SetLabelWidth(users_label, kLeftColumnMinWidth); 193 gtk_util::SetLabelWidth(users_label, left_column_min_width);
190 gtk_util::SetLabelColor(users_label, &ui::kGdkGray); 194 gtk_util::SetLabelColor(users_label, &ui::kGdkGray);
191 gtk_util::ForceFontSizePixels(rating_label, kRatingTextSize); 195 gtk_util::ForceFontSizePixels(rating_label, kRatingTextSize);
192 gtk_box_pack_start(GTK_BOX(heading_vbox), users_label, 196 gtk_box_pack_start(GTK_BOX(heading_vbox), users_label,
193 FALSE, FALSE, 0); 197 FALSE, FALSE, 0);
194 198
195 // Store link. 199 // Store link.
196 GtkWidget* store_link = gtk_chrome_link_button_new( 200 GtkWidget* store_link = gtk_chrome_link_button_new(
197 l10n_util::GetStringUTF8(IDS_EXTENSION_PROMPT_STORE_LINK).c_str()); 201 l10n_util::GetStringUTF8(IDS_EXTENSION_PROMPT_STORE_LINK).c_str());
198 gtk_util::ForceFontSizePixels(store_link, kRatingTextSize); 202 gtk_util::ForceFontSizePixels(store_link, kRatingTextSize);
199 GtkWidget* store_link_hbox = gtk_hbox_new(FALSE, 0); 203 GtkWidget* store_link_hbox = gtk_hbox_new(FALSE, 0);
200 // Stick it in an hbox so it doesn't expand to the whole width. 204 // Stick it in an hbox so it doesn't expand to the whole width.
201 gtk_box_pack_start(GTK_BOX(store_link_hbox), store_link, FALSE, FALSE, 0); 205 gtk_box_pack_start(GTK_BOX(store_link_hbox), store_link, FALSE, FALSE, 0);
202 gtk_box_pack_start(GTK_BOX(heading_vbox), store_link_hbox, FALSE, FALSE, 0); 206 gtk_box_pack_start(GTK_BOX(heading_vbox), store_link_hbox, FALSE, FALSE, 0);
203 g_signal_connect(store_link, "clicked", 207 g_signal_connect(store_link, "clicked",
204 G_CALLBACK(OnStoreLinkClickThunk), this); 208 G_CALLBACK(OnStoreLinkClickThunk), this);
205 } 209 }
206 210
207 if (is_bundle_install) { 211 if (is_bundle_install) {
208 // Add the list of extensions to be installed. 212 // Add the list of extensions to be installed.
209 GtkWidget* extensions_vbox = gtk_vbox_new(FALSE, ui::kControlSpacing); 213 GtkWidget* extensions_vbox = gtk_vbox_new(FALSE, ui::kControlSpacing);
210 gtk_box_pack_start(GTK_BOX(heading_vbox), extensions_vbox, FALSE, FALSE, 214 gtk_box_pack_start(GTK_BOX(heading_vbox), extensions_vbox, FALSE, FALSE,
211 ui::kControlSpacing); 215 ui::kControlSpacing);
212 216
213 BundleInstaller::ItemList items = prompt.bundle()->GetItemsWithState( 217 BundleInstaller::ItemList items = prompt.bundle()->GetItemsWithState(
214 BundleInstaller::Item::STATE_PENDING); 218 BundleInstaller::Item::STATE_PENDING);
215 for (size_t i = 0; i < items.size(); ++i) { 219 for (size_t i = 0; i < items.size(); ++i) {
216 GtkWidget* extension_label = gtk_label_new(UTF16ToUTF8( 220 GtkWidget* extension_label = gtk_label_new(UTF16ToUTF8(
217 items[i].GetNameForDisplay()).c_str()); 221 items[i].GetNameForDisplay()).c_str());
218 gtk_util::SetLabelWidth(extension_label, kLeftColumnMinWidth); 222 gtk_util::SetLabelWidth(extension_label, left_column_min_width);
219 gtk_box_pack_start(GTK_BOX(extensions_vbox), extension_label, 223 gtk_box_pack_start(GTK_BOX(extensions_vbox), extension_label,
220 FALSE, FALSE, kExtensionsPadding); 224 FALSE, FALSE, kExtensionsPadding);
221 } 225 }
222 } else { 226 } else {
223 // Resize the icon if necessary. 227 // Resize the icon if necessary.
224 SkBitmap scaled_icon = *prompt.icon().ToSkBitmap(); 228 SkBitmap scaled_icon = *prompt.icon().ToSkBitmap();
225 if (scaled_icon.width() > kImageSize || scaled_icon.height() > kImageSize) { 229 if (scaled_icon.width() > kImageSize || scaled_icon.height() > kImageSize) {
226 scaled_icon = skia::ImageOperations::Resize( 230 scaled_icon = skia::ImageOperations::Resize(
227 scaled_icon, skia::ImageOperations::RESIZE_LANCZOS3, 231 scaled_icon, skia::ImageOperations::RESIZE_LANCZOS3,
228 kImageSize, kImageSize); 232 kImageSize, kImageSize);
(...skipping 16 matching lines...) Expand all
245 if (is_inline_install) { 249 if (is_inline_install) {
246 permissions_container = content_vbox; 250 permissions_container = content_vbox;
247 gtk_box_pack_start(GTK_BOX(content_vbox), gtk_hseparator_new(), 251 gtk_box_pack_start(GTK_BOX(content_vbox), gtk_hseparator_new(),
248 FALSE, FALSE, ui::kControlSpacing); 252 FALSE, FALSE, ui::kControlSpacing);
249 } else { 253 } else {
250 permissions_container = left_column_area; 254 permissions_container = left_column_area;
251 } 255 }
252 256
253 GtkWidget* permissions_header = gtk_util::CreateBoldLabel( 257 GtkWidget* permissions_header = gtk_util::CreateBoldLabel(
254 UTF16ToUTF8(prompt.GetPermissionsHeading()).c_str()); 258 UTF16ToUTF8(prompt.GetPermissionsHeading()).c_str());
255 gtk_util::SetLabelWidth(permissions_header, kLeftColumnMinWidth); 259 gtk_util::SetLabelWidth(permissions_header, left_column_min_width);
256 gtk_box_pack_start(GTK_BOX(permissions_container), permissions_header, 260 gtk_box_pack_start(GTK_BOX(permissions_container), permissions_header,
257 FALSE, FALSE, 0); 261 FALSE, FALSE, 0);
258 262
259 for (size_t i = 0; i < prompt.GetPermissionCount(); ++i) { 263 for (size_t i = 0; i < prompt.GetPermissionCount(); ++i) {
260 std::string permission = l10n_util::GetStringFUTF8( 264 std::string permission = l10n_util::GetStringFUTF8(
261 IDS_EXTENSION_PERMISSION_LINE, prompt.GetPermission(i)); 265 IDS_EXTENSION_PERMISSION_LINE, prompt.GetPermission(i));
262 GtkWidget* permission_label = gtk_label_new(permission.c_str()); 266 GtkWidget* permission_label = gtk_label_new(permission.c_str());
263 gtk_util::SetLabelWidth(permission_label, kLeftColumnMinWidth); 267 gtk_util::SetLabelWidth(permission_label, left_column_min_width);
264 gtk_box_pack_start(GTK_BOX(permissions_container), permission_label, 268 gtk_box_pack_start(GTK_BOX(permissions_container), permission_label,
265 FALSE, FALSE, kPermissionsPadding); 269 FALSE, FALSE, kPermissionsPadding);
266 } 270 }
267 } 271 }
268 272
269 if (show_oauth_issues) { 273 if (show_oauth_issues) {
270 // If permissions are shown, then the scopes will go below them and take 274 // If permissions are shown, then the scopes will go below them and take
271 // up the entire width of the dialog. Otherwise the scopes will go where 275 // up the entire width of the dialog. Otherwise the scopes will go where
272 // the permissions usually go. 276 // the permissions usually go.
273 GtkWidget* oauth_issues_container = 277 GtkWidget* oauth_issues_container =
274 show_permissions ? content_vbox : left_column_area; 278 show_permissions ? content_vbox : left_column_area;
275 int pixel_width = kLeftColumnMinWidth + 279 int pixel_width = left_column_min_width +
276 (show_permissions ? kImageSize : 0); 280 (show_permissions ? kImageSize : 0);
277 281
278 GtkWidget* oauth_issues_header = gtk_util::CreateBoldLabel( 282 GtkWidget* oauth_issues_header = gtk_util::CreateBoldLabel(
279 UTF16ToUTF8(prompt.GetOAuthHeading()).c_str()); 283 UTF16ToUTF8(prompt.GetOAuthHeading()).c_str());
280 gtk_util::SetLabelWidth(oauth_issues_header, pixel_width); 284 gtk_util::SetLabelWidth(oauth_issues_header, pixel_width);
281 gtk_box_pack_start(GTK_BOX(oauth_issues_container), oauth_issues_header, 285 gtk_box_pack_start(GTK_BOX(oauth_issues_container), oauth_issues_header,
282 FALSE, FALSE, 0); 286 FALSE, FALSE, 0);
283 287
284 for (size_t i = 0; i < prompt.GetOAuthIssueCount(); ++i) { 288 for (size_t i = 0; i < prompt.GetOAuthIssueCount(); ++i) {
285 GtkWidget* issue_advice_widget = 289 GtkWidget* issue_advice_widget =
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 383
380 } // namespace browser 384 } // namespace browser
381 385
382 void ShowExtensionInstallDialogImpl( 386 void ShowExtensionInstallDialogImpl(
383 gfx::NativeWindow parent, 387 gfx::NativeWindow parent,
384 content::PageNavigator* navigator, 388 content::PageNavigator* navigator,
385 ExtensionInstallPrompt::Delegate* delegate, 389 ExtensionInstallPrompt::Delegate* delegate,
386 const ExtensionInstallPrompt::Prompt& prompt) { 390 const ExtensionInstallPrompt::Prompt& prompt) {
387 new browser::ExtensionInstallDialog(parent, navigator, delegate, prompt); 391 new browser::ExtensionInstallDialog(parent, navigator, delegate, prompt);
388 } 392 }
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