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/chromeos/options/language_mozc_config_view.h" | 5 #include "chrome/browser/chromeos/options/language_mozc_config_view.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/chromeos/cros/cros_library.h" | 9 #include "chrome/browser/chromeos/cros/cros_library.h" |
10 #include "chrome/browser/chromeos/options/language_config_util.h" | 10 #include "chrome/browser/chromeos/options/language_config_util.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 contents_->SetBounds(0, 0, width(), height()); | 115 contents_->SetBounds(0, 0, width(), height()); |
116 } | 116 } |
117 | 117 |
118 int LanguageMozcConfigView::GetDialogButtons() const { | 118 int LanguageMozcConfigView::GetDialogButtons() const { |
119 return MessageBoxFlags::DIALOGBUTTON_OK; | 119 return MessageBoxFlags::DIALOGBUTTON_OK; |
120 } | 120 } |
121 | 121 |
122 std::wstring LanguageMozcConfigView::GetDialogButtonLabel( | 122 std::wstring LanguageMozcConfigView::GetDialogButtonLabel( |
123 MessageBoxFlags::DialogButton button) const { | 123 MessageBoxFlags::DialogButton button) const { |
124 if (button == MessageBoxFlags::DIALOGBUTTON_OK) { | 124 if (button == MessageBoxFlags::DIALOGBUTTON_OK) { |
125 return l10n_util::GetString(IDS_OK); | 125 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_OK)); |
126 } | 126 } |
127 return L""; | 127 return L""; |
128 } | 128 } |
129 | 129 |
130 std::wstring LanguageMozcConfigView::GetWindowTitle() const { | 130 std::wstring LanguageMozcConfigView::GetWindowTitle() const { |
131 return l10n_util::GetString( | 131 return UTF16ToWide(l10n_util::GetStringUTF16( |
132 IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SETTINGS_TITLE); | 132 IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SETTINGS_TITLE)); |
133 } | 133 } |
134 | 134 |
135 gfx::Size LanguageMozcConfigView::GetPreferredSize() { | 135 gfx::Size LanguageMozcConfigView::GetPreferredSize() { |
136 // TODO(satorux): Create our own localized content size once the UI is done. | 136 // TODO(satorux): Create our own localized content size once the UI is done. |
137 gfx::Size preferred_size = views::Window::GetLocalizedContentsSize( | 137 gfx::Size preferred_size = views::Window::GetLocalizedContentsSize( |
138 IDS_LANGUAGES_INPUT_DIALOG_WIDTH_CHARS, | 138 IDS_LANGUAGES_INPUT_DIALOG_WIDTH_CHARS, |
139 IDS_LANGUAGES_INPUT_DIALOG_HEIGHT_LINES); | 139 IDS_LANGUAGES_INPUT_DIALOG_HEIGHT_LINES); |
140 // TODO(mazda): Remove the manual adjustment. | 140 // TODO(mazda): Remove the manual adjustment. |
141 // The padding is needed for accommodating all the controls in the dialog. | 141 // The padding is needed for accommodating all the controls in the dialog. |
142 const int kHeightPadding = 80; | 142 const int kHeightPadding = 80; |
(...skipping 16 matching lines...) Expand all Loading... |
159 const int kColumnSetId = 0; | 159 const int kColumnSetId = 0; |
160 ColumnSet* column_set = layout->AddColumnSet(kColumnSetId); | 160 ColumnSet* column_set = layout->AddColumnSet(kColumnSetId); |
161 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, | 161 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, |
162 GridLayout::USE_PREF, 0, 0); | 162 GridLayout::USE_PREF, 0, 0); |
163 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); | 163 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); |
164 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 164 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |
165 GridLayout::USE_PREF, 0, 0); | 165 GridLayout::USE_PREF, 0, 0); |
166 | 166 |
167 for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { | 167 for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { |
168 MozcPrefAndAssociatedCheckbox& current = prefs_and_checkboxes_[i]; | 168 MozcPrefAndAssociatedCheckbox& current = prefs_and_checkboxes_[i]; |
169 current.checkbox = new views::Checkbox( | 169 current.checkbox = new views::Checkbox(UTF16ToWide( |
170 l10n_util::GetString(language_prefs::kMozcBooleanPrefs[i].message_id)); | 170 l10n_util::GetStringUTF16( |
| 171 language_prefs::kMozcBooleanPrefs[i].message_id))); |
171 current.checkbox->set_listener(this); | 172 current.checkbox->set_listener(this); |
172 current.checkbox->set_tag(i); | 173 current.checkbox->set_tag(i); |
173 } | 174 } |
174 for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { | 175 for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { |
175 MozcPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i]; | 176 MozcPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i]; |
176 current.combobox = new LanguageCombobox(current.combobox_model); | 177 current.combobox = new LanguageCombobox(current.combobox_model); |
177 current.combobox->set_listener(this); | 178 current.combobox->set_listener(this); |
178 } | 179 } |
179 for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { | 180 for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { |
180 MozcPrefAndAssociatedSlider& current = prefs_and_sliders_[i]; | 181 MozcPrefAndAssociatedSlider& current = prefs_and_sliders_[i]; |
181 current.slider = new views::Slider( | 182 current.slider = new views::Slider( |
182 language_prefs::kMozcIntegerPrefs[i].min_pref_value, | 183 language_prefs::kMozcIntegerPrefs[i].min_pref_value, |
183 language_prefs::kMozcIntegerPrefs[i].max_pref_value, | 184 language_prefs::kMozcIntegerPrefs[i].max_pref_value, |
184 1, | 185 1, |
185 static_cast<views::Slider::StyleFlags>( | 186 static_cast<views::Slider::StyleFlags>( |
186 views::Slider::STYLE_DRAW_VALUE | | 187 views::Slider::STYLE_DRAW_VALUE | |
187 views::Slider::STYLE_UPDATE_ON_RELEASE), | 188 views::Slider::STYLE_UPDATE_ON_RELEASE), |
188 this); | 189 this); |
189 } | 190 } |
190 NotifyPrefChanged(); // Sync the comboboxes with current Chrome prefs. | 191 NotifyPrefChanged(); // Sync the comboboxes with current Chrome prefs. |
191 | 192 |
192 reset_to_defaults_button_ = new views::NativeButton( | 193 reset_to_defaults_button_ = new views::NativeButton( |
193 this, l10n_util::GetString( | 194 this, UTF16ToWide(l10n_util::GetStringUTF16( |
194 IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_RESET_TO_DEFAULTS_BUTTON)); | 195 IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_RESET_TO_DEFAULTS_BUTTON))); |
195 reset_to_defaults_button_->set_tag(kResetToDefaultsButton); | 196 reset_to_defaults_button_->set_tag(kResetToDefaultsButton); |
196 layout->StartRow(0, kColumnSetId); | 197 layout->StartRow(0, kColumnSetId); |
197 layout->AddView(reset_to_defaults_button_); | 198 layout->AddView(reset_to_defaults_button_); |
198 | 199 |
199 // Show the checkboxes. | 200 // Show the checkboxes. |
200 for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { | 201 for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { |
201 const MozcPrefAndAssociatedCheckbox& current = prefs_and_checkboxes_[i]; | 202 const MozcPrefAndAssociatedCheckbox& current = prefs_and_checkboxes_[i]; |
202 layout->StartRow(0, kColumnSetId); | 203 layout->StartRow(0, kColumnSetId); |
203 layout->AddView(current.checkbox, 3, 1); | 204 layout->AddView(current.checkbox, 3, 1); |
204 } | 205 } |
205 // Show the comboboxes. | 206 // Show the comboboxes. |
206 for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { | 207 for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { |
207 const MozcPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i]; | 208 const MozcPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i]; |
208 layout->StartRow(0, kColumnSetId); | 209 layout->StartRow(0, kColumnSetId); |
209 layout->AddView(new views::Label(current.combobox_model->GetLabel())); | 210 layout->AddView(new views::Label(current.combobox_model->GetLabel())); |
210 layout->AddView(current.combobox); | 211 layout->AddView(current.combobox); |
211 } | 212 } |
212 for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { | 213 for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { |
213 const MozcPrefAndAssociatedSlider& current = prefs_and_sliders_[i]; | 214 const MozcPrefAndAssociatedSlider& current = prefs_and_sliders_[i]; |
214 layout->StartRow(0, kColumnSetId); | 215 layout->StartRow(0, kColumnSetId); |
215 layout->AddView(new views::Label( | 216 layout->AddView(new views::Label( |
216 l10n_util::GetString( | 217 UTF16ToWide(l10n_util::GetStringUTF16( |
217 language_prefs::kMozcIntegerPrefs[i].message_id))); | 218 language_prefs::kMozcIntegerPrefs[i].message_id)))); |
218 layout->AddView(current.slider); | 219 layout->AddView(current.slider); |
219 } | 220 } |
220 NotifyPrefChanged(); // Sync the slider with current Chrome prefs. | 221 NotifyPrefChanged(); // Sync the slider with current Chrome prefs. |
221 } | 222 } |
222 | 223 |
223 void LanguageMozcConfigView::Observe(NotificationType type, | 224 void LanguageMozcConfigView::Observe(NotificationType type, |
224 const NotificationSource& source, | 225 const NotificationSource& source, |
225 const NotificationDetails& details) { | 226 const NotificationDetails& details) { |
226 if (type == NotificationType::PREF_CHANGED) { | 227 if (type == NotificationType::PREF_CHANGED) { |
227 NotifyPrefChanged(); | 228 NotifyPrefChanged(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 } | 265 } |
265 for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { | 266 for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { |
266 prefs_and_sliders_[i].integer_pref.SetValue( | 267 prefs_and_sliders_[i].integer_pref.SetValue( |
267 language_prefs::kMozcIntegerPrefs[i].default_pref_value); | 268 language_prefs::kMozcIntegerPrefs[i].default_pref_value); |
268 } | 269 } |
269 // Reflect the preference changes to the controls. | 270 // Reflect the preference changes to the controls. |
270 NotifyPrefChanged(); | 271 NotifyPrefChanged(); |
271 } | 272 } |
272 | 273 |
273 } // namespace chromeos | 274 } // namespace chromeos |
OLD | NEW |