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

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

Issue 152343006: Clean-up: Replaces obsolete Font/FontList methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced. Created 6 years, 10 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/validation_message_bubble.h" 5 #include "chrome/browser/ui/validation_message_bubble.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" 9 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
10 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 10 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 GtkWidget* label = gtk_label_new(base::UTF16ToUTF8(main_text).c_str()); 102 GtkWidget* label = gtk_label_new(base::UTF16ToUTF8(main_text).c_str());
103 const gfx::Font& main_font = bundle.GetFont(ResourceBundle::MediumFont); 103 const gfx::Font& main_font = bundle.GetFont(ResourceBundle::MediumFont);
104 gtk_util::ForceFontSizePixels(label, main_font.GetHeight()); 104 gtk_util::ForceFontSizePixels(label, main_font.GetHeight());
105 gtk_box_pack_start( 105 gtk_box_pack_start(
106 GTK_BOX(text_box), gtk_util::LeftAlignMisc(label), TRUE, TRUE, 0); 106 GTK_BOX(text_box), gtk_util::LeftAlignMisc(label), TRUE, TRUE, 0);
107 107
108 if (!sub_text.empty()) { 108 if (!sub_text.empty()) {
109 GtkWidget* sub_label = gtk_label_new(base::UTF16ToUTF8(sub_text).c_str()); 109 GtkWidget* sub_label = gtk_label_new(base::UTF16ToUTF8(sub_text).c_str());
110 const gfx::Font& sub_font = bundle.GetFont(ResourceBundle::BaseFont); 110 const gfx::Font& sub_font = bundle.GetFont(ResourceBundle::BaseFont);
111 gtk_util::ForceFontSizePixels(sub_label, sub_font.GetHeight()); 111 gtk_util::ForceFontSizePixels(sub_label, sub_font.GetHeight());
112 int max_characters = kTextMaxWidth / sub_font.GetAverageCharacterWidth(); 112 int max_characters = kTextMaxWidth / sub_font.GetExpectedTextWidth(1);
113 if (sub_text.length() > static_cast<size_t>(max_characters)) 113 if (sub_text.length() > static_cast<size_t>(max_characters))
114 gtk_util::SetLabelWidth(sub_label, kTextMaxWidth); 114 gtk_util::SetLabelWidth(sub_label, kTextMaxWidth);
115 gtk_box_pack_start( 115 gtk_box_pack_start(
116 GTK_BOX(text_box), gtk_util::LeftAlignMisc(sub_label), TRUE, TRUE, 0); 116 GTK_BOX(text_box), gtk_util::LeftAlignMisc(sub_label), TRUE, TRUE, 0);
117 } 117 }
118 gtk_container_add(GTK_CONTAINER(icon_text_box), text_box); 118 gtk_container_add(GTK_CONTAINER(icon_text_box), text_box);
119 119
120 GtkWidget* content = gtk_alignment_new(0, 0, 0, 0); 120 GtkWidget* content = gtk_alignment_new(0, 0, 0, 0);
121 gtk_alignment_set_padding( 121 gtk_alignment_set_padding(
122 GTK_ALIGNMENT(content), kPadding, kPadding, kPadding, kPadding); 122 GTK_ALIGNMENT(content), kPadding, kPadding, kPadding, kPadding);
123 gtk_container_add(GTK_CONTAINER(content), icon_text_box); 123 gtk_container_add(GTK_CONTAINER(content), icon_text_box);
124 return content; 124 return content;
125 } 125 }
126 126
127 } // namespace 127 } // namespace
128 128
129 namespace chrome { 129 namespace chrome {
130 130
131 scoped_ptr<ValidationMessageBubble> ValidationMessageBubble::CreateAndShow( 131 scoped_ptr<ValidationMessageBubble> ValidationMessageBubble::CreateAndShow(
132 content::RenderWidgetHost* widget_host, 132 content::RenderWidgetHost* widget_host,
133 const gfx::Rect& anchor_in_root_view, 133 const gfx::Rect& anchor_in_root_view,
134 const base::string16& main_text, 134 const base::string16& main_text,
135 const base::string16& sub_text) { 135 const base::string16& sub_text) {
136 return scoped_ptr<ValidationMessageBubble>(new ValidationMessageBubbleGtk( 136 return scoped_ptr<ValidationMessageBubble>(new ValidationMessageBubbleGtk(
137 widget_host, anchor_in_root_view, main_text, sub_text)).Pass(); 137 widget_host, anchor_in_root_view, main_text, sub_text)).Pass();
138 } 138 }
139 139
140 } // namespace chrome 140 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/tabs/tab_gtk.cc ('k') | chrome/browser/ui/views/accessibility/invert_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698