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

Side by Side Diff: chrome/browser/ui/gtk/web_intent_picker_gtk.cc

Issue 10827341: Factoring out common constants (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More cocoa namespacing. Created 8 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 | Annotate | Revision Log
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 "chrome/browser/ui/gtk/web_intent_picker_gtk.h" 5 #include "chrome/browser/ui/gtk/web_intent_picker_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 30 matching lines...) Expand all
41 #include "ui/base/l10n/l10n_util.h" 41 #include "ui/base/l10n/l10n_util.h"
42 #include "ui/base/resource/resource_bundle.h" 42 #include "ui/base/resource/resource_bundle.h"
43 #include "ui/base/text/text_elider.h" 43 #include "ui/base/text/text_elider.h"
44 #include "ui/gfx/gtk_util.h" 44 #include "ui/gfx/gtk_util.h"
45 #include "ui/gfx/image/image.h" 45 #include "ui/gfx/image/image.h"
46 46
47 using content::WebContents; 47 using content::WebContents;
48 48
49 namespace { 49 namespace {
50 50
51 // The width in pixels of the area between the icon on the left and the close
52 // button on the right.
53 const int kMainContentWidth = 400;
54
55 // The pixel size of the header label when using a non-native theme. 51 // The pixel size of the header label when using a non-native theme.
56 const int kHeaderLabelPixelSize = 15; 52 const int kHeaderLabelPixelSize = 15;
57 53
58 // The pixel size of the font of the main content of the dialog. 54 // The pixel size of the font of the main content of the dialog.
59 const int kMainContentPixelSize = 13; 55 const int kMainContentPixelSize = 13;
60 56
61 // The maximum width in pixels of a suggested extension's title link.
62 const int kTitleLinkMaxWidth = 130;
63
64 // Indices of the extension row widgets. 57 // Indices of the extension row widgets.
65 enum { 58 enum {
66 kIconIndex, 59 kIconIndex,
67 kTitleLinkIndex, 60 kTitleLinkIndex,
68 kStarsIndex, 61 kStarsIndex,
69 kInstallButtonIndex, 62 kInstallButtonIndex,
70 }; 63 };
71 64
72 GtkThemeService *GetThemeService(TabContents* tab_contents) { 65 GtkThemeService *GetThemeService(TabContents* tab_contents) {
73 return GtkThemeService::GetFrom(tab_contents->profile()); 66 return GtkThemeService::GetFrom(tab_contents->profile());
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 gtk_box_pack_start(GTK_BOX(sub_contents), hbox, TRUE, TRUE, 0); 334 gtk_box_pack_start(GTK_BOX(sub_contents), hbox, TRUE, TRUE, 0);
342 GtkThemeService* theme_service = GetThemeService(tab_contents_); 335 GtkThemeService* theme_service = GetThemeService(tab_contents_);
343 GtkWidget* no_service_label = theme_service->BuildLabel( 336 GtkWidget* no_service_label = theme_service->BuildLabel(
344 l10n_util::GetStringUTF8(IDS_INTENT_PICKER_NO_SERVICES).c_str(), 337 l10n_util::GetStringUTF8(IDS_INTENT_PICKER_NO_SERVICES).c_str(),
345 ui::kGdkBlack); 338 ui::kGdkBlack);
346 gtk_label_set_line_wrap(GTK_LABEL(no_service_label), TRUE); 339 gtk_label_set_line_wrap(GTK_LABEL(no_service_label), TRUE);
347 gtk_misc_set_alignment(GTK_MISC(no_service_label), 0, 0); 340 gtk_misc_set_alignment(GTK_MISC(no_service_label), 0, 0);
348 // Set the label width to the size of |sub_contents|, which we don't have 341 // Set the label width to the size of |sub_contents|, which we don't have
349 // access to yet, by calculating the main content width minus borders. 342 // access to yet, by calculating the main content width minus borders.
350 gtk_util::SetLabelWidth(no_service_label, 343 gtk_util::SetLabelWidth(no_service_label,
351 kMainContentWidth - 2 * ui::kContentAreaBorder); 344 kWindowWidth - 2 * ui::kContentAreaBorder);
352 gtk_box_pack_start(GTK_BOX(hbox), no_service_label, TRUE, TRUE, 0); 345 gtk_box_pack_start(GTK_BOX(hbox), no_service_label, TRUE, TRUE, 0);
353 346
354 gtk_widget_show_all(contents_); 347 gtk_widget_show_all(contents_);
355 } 348 }
356 349
357 GtkWidget* WebIntentPickerGtk::GetWidgetRoot() { 350 GtkWidget* WebIntentPickerGtk::GetWidgetRoot() {
358 return contents_; 351 return contents_;
359 } 352 }
360 353
361 GtkWidget* WebIntentPickerGtk::GetFocusWidget() { 354 GtkWidget* WebIntentPickerGtk::GetFocusWidget() {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 454
462 void WebIntentPickerGtk::InitContents() { 455 void WebIntentPickerGtk::InitContents() {
463 GtkThemeService* theme_service = GetThemeService(tab_contents_); 456 GtkThemeService* theme_service = GetThemeService(tab_contents_);
464 457
465 // Main contents vbox. 458 // Main contents vbox.
466 if (!contents_) { 459 if (!contents_) {
467 contents_ = gtk_vbox_new(FALSE, 0); 460 contents_ = gtk_vbox_new(FALSE, 0);
468 g_signal_connect(contents_, "destroy", G_CALLBACK(&OnDestroyThunk), this); 461 g_signal_connect(contents_, "destroy", G_CALLBACK(&OnDestroyThunk), this);
469 } 462 }
470 463
471 gtk_widget_set_size_request(contents_, kMainContentWidth, -1); 464 gtk_widget_set_size_request(contents_, kWindowWidth, -1);
472 465
473 AddCloseButton(contents_); 466 AddCloseButton(contents_);
474 GtkWidget* sub_contents = CreateSubContents(contents_); 467 GtkWidget* sub_contents = CreateSubContents(contents_);
475 AddTitle(sub_contents); 468 AddTitle(sub_contents);
476 469
477 // Add separation between the installed services list and the app suggestions. 470 // Add separation between the installed services list and the app suggestions.
478 GtkWidget* button_alignment = gtk_alignment_new(0.5, 0, 0, 0); 471 GtkWidget* button_alignment = gtk_alignment_new(0.5, 0, 0, 0);
479 gtk_alignment_set_padding(GTK_ALIGNMENT(button_alignment), 0, 472 gtk_alignment_set_padding(GTK_ALIGNMENT(button_alignment), 0,
480 kMainContentPixelSize * 2, 0, 0); 473 kMainContentPixelSize * 2, 0, 0);
481 474
482 // Vbox containing all service buttons. 475 // Vbox containing all service buttons.
483 button_vbox_ = gtk_vbox_new(FALSE, ui::kControlSpacing); 476 button_vbox_ = gtk_vbox_new(FALSE, ui::kControlSpacing);
484 gtk_container_add(GTK_CONTAINER(button_alignment), button_vbox_); 477 gtk_container_add(GTK_CONTAINER(button_alignment), button_vbox_);
485 gtk_box_pack_start(GTK_BOX(sub_contents), button_alignment, TRUE, TRUE, 0); 478 gtk_box_pack_start(GTK_BOX(sub_contents), button_alignment, TRUE, TRUE, 0);
486 479
487 // Chrome Web Store label. 480 // Chrome Web Store label.
488 cws_label_ = theme_service->BuildLabel( 481 cws_label_ = theme_service->BuildLabel(
489 l10n_util::GetStringUTF8(IDS_INTENT_PICKER_GET_MORE_SERVICES).c_str(), 482 l10n_util::GetStringUTF8(IDS_INTENT_PICKER_GET_MORE_SERVICES).c_str(),
490 ui::kGdkBlack); 483 ui::kGdkBlack);
491 gtk_box_pack_start(GTK_BOX(sub_contents), cws_label_, TRUE, TRUE, 0); 484 gtk_box_pack_start(GTK_BOX(sub_contents), cws_label_, TRUE, TRUE, 0);
492 gtk_misc_set_alignment(GTK_MISC(cws_label_), 0, 0); 485 gtk_misc_set_alignment(GTK_MISC(cws_label_), 0, 0);
493 gtk_widget_set_no_show_all(cws_label_, TRUE); 486 gtk_widget_set_no_show_all(cws_label_, TRUE);
494 487
495 // Set the label width to the size of |sub_contents|, which we don't have 488 // Set the label width to the size of |sub_contents|, which we don't have
496 // access to yet, by calculating the main content width minus borders. 489 // access to yet, by calculating the main content width minus borders.
497 gtk_util::SetLabelWidth(cws_label_, 490 gtk_util::SetLabelWidth(cws_label_,
498 kMainContentWidth - 2 * ui::kContentAreaBorder); 491 kWindowWidth - 2 * ui::kContentAreaBorder);
499 gtk_util::ForceFontSizePixels(cws_label_, kMainContentPixelSize); 492 gtk_util::ForceFontSizePixels(cws_label_, kMainContentPixelSize);
500 493
501 // Suggested extensions vbox. 494 // Suggested extensions vbox.
502 extensions_vbox_ = gtk_vbox_new(FALSE, ui::kControlSpacing); 495 extensions_vbox_ = gtk_vbox_new(FALSE, ui::kControlSpacing);
503 GtkWidget* indent_extensions = gtk_alignment_new(0.0, 0.5, 1.0, 1.0); 496 GtkWidget* indent_extensions = gtk_alignment_new(0.0, 0.5, 1.0, 1.0);
504 gtk_alignment_set_padding(GTK_ALIGNMENT(indent_extensions), 0, 0, 497 gtk_alignment_set_padding(GTK_ALIGNMENT(indent_extensions), 0, 0,
505 ui::kGroupIndent, ui::kGroupIndent); 498 ui::kGroupIndent, ui::kGroupIndent);
506 gtk_container_add(GTK_CONTAINER(indent_extensions), extensions_vbox_); 499 gtk_container_add(GTK_CONTAINER(indent_extensions), extensions_vbox_);
507 gtk_widget_set_no_show_all(indent_extensions, TRUE); 500 gtk_widget_set_no_show_all(indent_extensions, TRUE);
508 gtk_box_pack_start(GTK_BOX(sub_contents), indent_extensions, TRUE, TRUE, 0); 501 gtk_box_pack_start(GTK_BOX(sub_contents), indent_extensions, TRUE, TRUE, 0);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 return alignment; 700 return alignment;
708 } 701 }
709 702
710 void WebIntentPickerGtk::RemoveThrobber() { 703 void WebIntentPickerGtk::RemoveThrobber() {
711 GtkWidget* alignment = gtk_widget_get_parent(throbber_->widget()); 704 GtkWidget* alignment = gtk_widget_get_parent(throbber_->widget());
712 DCHECK(alignment); 705 DCHECK(alignment);
713 gtk_container_remove(GTK_CONTAINER(alignment), throbber_->widget()); 706 gtk_container_remove(GTK_CONTAINER(alignment), throbber_->widget());
714 gtk_widget_destroy(alignment); 707 gtk_widget_destroy(alignment);
715 throbber_->Stop(); 708 throbber_->Stop();
716 } 709 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/web_intent_sheet_controller.mm ('k') | chrome/browser/ui/intents/web_intent_picker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698