OLD | NEW |
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 | 4 |
5 #include "chrome/browser/gtk/options/fonts_page_gtk.h" | 5 #include "chrome/browser/gtk/options/fonts_page_gtk.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/default_encoding_combo_model.h" | 12 #include "chrome/browser/default_encoding_combo_model.h" |
13 #include "chrome/browser/gtk/gtk_util.h" | 13 #include "chrome/browser/gtk/gtk_util.h" |
14 #include "chrome/browser/gtk/options/options_layout_gtk.h" | 14 #include "chrome/browser/gtk/options/options_layout_gtk.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
17 #include "gfx/font.h" | 17 #include "gfx/font.h" |
18 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 // Make a Gtk font name string from a font family name and pixel size. | 22 // Make a Gtk font name string from a font family name and pixel size. |
23 std::string MakeFontName(std::string family_name, int pixel_size) { | 23 std::string MakeFontName(std::string family_name, int pixel_size) { |
24 // The given font might not be available (the default fonts we use are not | 24 // The given font might not be available (the default fonts we use are not |
25 // installed by default on some distros). So figure out which font we are | 25 // installed by default on some distros). So figure out which font we are |
26 // actually falling back to and display that. (See crbug.com/31381.) | 26 // actually falling back to and display that. (See crbug.com/31381.) |
27 string16 actual_family_name = gfx::Font( | 27 std::wstring actual_family_name = gfx::Font( |
28 UTF8ToUTF16(family_name), pixel_size).GetFontName(); | 28 UTF8ToWide(family_name), pixel_size).GetFontName(); |
29 std::string fontname; | 29 std::string fontname; |
30 // TODO(mattm): We can pass in the size in pixels (px), and the font button | 30 // TODO(mattm): We can pass in the size in pixels (px), and the font button |
31 // actually honors it, but when you open the selector it interprets it as | 31 // actually honors it, but when you open the selector it interprets it as |
32 // points. See crbug.com/17857 | 32 // points. See crbug.com/17857 |
33 base::SStringPrintf(&fontname, "%s, %dpx", | 33 base::SStringPrintf(&fontname, "%s, %dpx", |
34 UTF16ToUTF8(actual_family_name).c_str(), pixel_size); | 34 WideToUTF8(actual_family_name).c_str(), pixel_size); |
35 return fontname; | 35 return fontname; |
36 } | 36 } |
37 | 37 |
38 } // namespace | 38 } // namespace |
39 | 39 |
40 FontsPageGtk::FontsPageGtk(Profile* profile) : OptionsPageBase(profile) { | 40 FontsPageGtk::FontsPageGtk(Profile* profile) : OptionsPageBase(profile) { |
41 Init(); | 41 Init(); |
42 } | 42 } |
43 | 43 |
44 FontsPageGtk::~FontsPageGtk() { | 44 FontsPageGtk::~FontsPageGtk() { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 SetFontsFromButton(&fixed_width_name_, | 179 SetFontsFromButton(&fixed_width_name_, |
180 &fixed_width_size_, | 180 &fixed_width_size_, |
181 font_button); | 181 font_button); |
182 } | 182 } |
183 | 183 |
184 void FontsPageGtk::OnDefaultEncodingChanged(GtkWidget* combo_box) { | 184 void FontsPageGtk::OnDefaultEncodingChanged(GtkWidget* combo_box) { |
185 int index = gtk_combo_box_get_active(GTK_COMBO_BOX(combo_box)); | 185 int index = gtk_combo_box_get_active(GTK_COMBO_BOX(combo_box)); |
186 default_encoding_.SetValue(default_encoding_combobox_model_-> | 186 default_encoding_.SetValue(default_encoding_combobox_model_-> |
187 GetEncodingCharsetByIndex(index)); | 187 GetEncodingCharsetByIndex(index)); |
188 } | 188 } |
OLD | NEW |