OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/system_page_view.h" | 5 #include "chrome/browser/chromeos/options/system_page_view.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "app/combobox_model.h" | 10 #include "app/combobox_model.h" |
11 #include "base/stl_util-inl.h" | 11 #include "base/stl_util-inl.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/chromeos/cros/cros_library.h" | 13 #include "chrome/browser/chromeos/cros/cros_library.h" |
14 #include "chrome/browser/chromeos/cros/system_library.h" | 14 #include "chrome/browser/chromeos/cros/system_library.h" |
| 15 #include "chrome/browser/chromeos/options/language_config_util.h" |
15 #include "chrome/browser/chromeos/options/language_config_view.h" | 16 #include "chrome/browser/chromeos/options/language_config_view.h" |
16 #include "chrome/browser/chromeos/options/options_window_view.h" | 17 #include "chrome/browser/chromeos/options/options_window_view.h" |
17 #include "chrome/browser/pref_member.h" | 18 #include "chrome/browser/pref_member.h" |
18 #include "chrome/browser/profile.h" | 19 #include "chrome/browser/profile.h" |
19 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
20 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
21 #include "unicode/timezone.h" | 22 #include "unicode/timezone.h" |
22 #include "views/controls/button/checkbox.h" | 23 #include "views/controls/button/checkbox.h" |
23 #include "views/controls/button/native_button.h" | 24 #include "views/controls/button/native_button.h" |
24 #include "views/controls/combobox/combobox.h" | 25 #include "views/controls/combobox/combobox.h" |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 double value = sensitivity_.GetValue(); | 343 double value = sensitivity_.GetValue(); |
343 sensitivity_slider_->SetValue(value); | 344 sensitivity_slider_->SetValue(value); |
344 } | 345 } |
345 } | 346 } |
346 | 347 |
347 //////////////////////////////////////////////////////////////////////////////// | 348 //////////////////////////////////////////////////////////////////////////////// |
348 // LanguageSection | 349 // LanguageSection |
349 | 350 |
350 // TextInput section for text input settings. | 351 // TextInput section for text input settings. |
351 class LanguageSection : public SettingsPageSection, | 352 class LanguageSection : public SettingsPageSection, |
352 public views::ButtonListener { | 353 public views::ButtonListener, |
| 354 public views::Combobox::Listener { |
353 public: | 355 public: |
354 explicit LanguageSection(Profile* profile); | 356 explicit LanguageSection(Profile* profile); |
355 virtual ~LanguageSection() {} | 357 virtual ~LanguageSection() {} |
356 | 358 |
357 private: | 359 private: |
358 enum ButtonTag { | 360 enum ButtonTag { |
359 kCustomizeLanguagesButton, | 361 kCustomizeLanguagesButton, |
360 }; | 362 }; |
361 // Overridden from SettingsPageSection: | 363 // Overridden from SettingsPageSection: |
362 virtual void InitContents(GridLayout* layout); | 364 virtual void InitContents(GridLayout* layout); |
| 365 void NotifyPrefChanged(const std::wstring* pref_name); |
363 | 366 |
364 // Overridden from views::ButtonListener: | 367 // Overridden from views::ButtonListener: |
365 virtual void ButtonPressed(views::Button* sender, | 368 virtual void ButtonPressed(views::Button* sender, |
366 const views::Event& event); | 369 const views::Event& event); |
367 | 370 |
| 371 // Overridden from views::Combobox::Listener: |
| 372 virtual void ItemChanged(views::Combobox* sender, |
| 373 int prev_index, |
| 374 int new_index); |
| 375 |
| 376 IntegerPrefMember xkb_pref_; |
| 377 views::Combobox* xkb_modifier_combobox_; |
| 378 chromeos::LanguageComboboxModel<int> xkb_modifier_combobox_model_; |
| 379 |
368 DISALLOW_COPY_AND_ASSIGN(LanguageSection); | 380 DISALLOW_COPY_AND_ASSIGN(LanguageSection); |
369 }; | 381 }; |
370 | 382 |
371 LanguageSection::LanguageSection(Profile* profile) | 383 LanguageSection::LanguageSection(Profile* profile) |
372 : SettingsPageSection(profile, | 384 : SettingsPageSection(profile, |
373 IDS_OPTIONS_SETTINGS_SECTION_TITLE_LANGUAGE) { | 385 IDS_OPTIONS_SETTINGS_SECTION_TITLE_LANGUAGE), |
| 386 xkb_modifier_combobox_(NULL), |
| 387 xkb_modifier_combobox_model_(&kXkbModifierMultipleChoicePrefs) { |
| 388 xkb_pref_.Init(prefs::kLanguageXkbModifierRemap, profile->GetPrefs(), this); |
374 } | 389 } |
375 | 390 |
376 void LanguageSection::InitContents(GridLayout* layout) { | 391 void LanguageSection::InitContents(GridLayout* layout) { |
377 // Add the customize button. | 392 // Add the customize button and XKB combobox. |
378 layout->StartRow(0, single_column_view_set_id()); | 393 layout->StartRow(0, double_column_view_set_id()); |
379 views::NativeButton* customize_languages_button = new views::NativeButton( | 394 views::NativeButton* customize_languages_button = new views::NativeButton( |
380 this, | 395 this, |
381 l10n_util::GetString(IDS_OPTIONS_SETTINGS_LANGUAGES_CUSTOMIZE)); | 396 l10n_util::GetString(IDS_OPTIONS_SETTINGS_LANGUAGES_CUSTOMIZE)); |
382 customize_languages_button->set_tag(kCustomizeLanguagesButton); | 397 customize_languages_button->set_tag(kCustomizeLanguagesButton); |
383 layout->AddView(customize_languages_button, 1, 1, | 398 layout->AddView(customize_languages_button, 1, 1, |
384 GridLayout::LEADING, GridLayout::CENTER); | 399 GridLayout::LEADING, GridLayout::CENTER); |
| 400 |
| 401 xkb_modifier_combobox_ = new views::Combobox(&xkb_modifier_combobox_model_); |
| 402 xkb_modifier_combobox_->set_listener(this); |
| 403 // Initialize the combobox to what's saved in user preferences. Otherwise, |
| 404 // ItemChanged() will be called with |new_index| == 0. |
| 405 NotifyPrefChanged(NULL); |
| 406 |
| 407 layout->AddView(xkb_modifier_combobox_); |
385 layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); | 408 layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); |
386 } | 409 } |
387 | 410 |
388 void LanguageSection::ButtonPressed( | 411 void LanguageSection::ButtonPressed( |
389 views::Button* sender, const views::Event& event) { | 412 views::Button* sender, const views::Event& event) { |
390 if (sender->tag() == kCustomizeLanguagesButton) { | 413 if (sender->tag() == kCustomizeLanguagesButton) { |
391 LanguageConfigView::Show(profile(), GetOptionsViewParent()); | 414 LanguageConfigView::Show(profile(), GetOptionsViewParent()); |
392 } | 415 } |
393 } | 416 } |
394 | 417 |
| 418 void LanguageSection::ItemChanged(views::Combobox* sender, |
| 419 int prev_index, |
| 420 int new_index) { |
| 421 LOG(INFO) << "Changing XKB modofier pref to " << new_index; |
| 422 xkb_pref_.SetValue(new_index); |
| 423 } |
| 424 |
| 425 void LanguageSection::NotifyPrefChanged(const std::wstring* pref_name) { |
| 426 if (!pref_name || *pref_name == prefs::kLanguageXkbModifierRemap) { |
| 427 const int id = xkb_pref_.GetValue(); |
| 428 if (id >= 0) { |
| 429 xkb_modifier_combobox_->SetSelectedItem(id); |
| 430 } |
| 431 } |
| 432 } |
| 433 |
395 /////////////////////////////////////////////////////////////////////////////// | 434 /////////////////////////////////////////////////////////////////////////////// |
396 // AccessibilitySection | 435 // AccessibilitySection |
397 | 436 |
398 // Checkbox for specifying if accessibility should be enabled for this profile | 437 // Checkbox for specifying if accessibility should be enabled for this profile |
399 class AccessibilitySection : public SettingsPageSection, | 438 class AccessibilitySection : public SettingsPageSection, |
400 public views::ButtonListener { | 439 public views::ButtonListener { |
401 public: | 440 public: |
402 explicit AccessibilitySection(Profile* profile); | 441 explicit AccessibilitySection(Profile* profile); |
403 virtual ~AccessibilitySection() {} | 442 virtual ~AccessibilitySection() {} |
404 | 443 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 523 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
485 layout->StartRow(0, single_column_view_set_id); | 524 layout->StartRow(0, single_column_view_set_id); |
486 layout->AddView(new LanguageSection(profile())); | 525 layout->AddView(new LanguageSection(profile())); |
487 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 526 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
488 layout->StartRow(0, single_column_view_set_id); | 527 layout->StartRow(0, single_column_view_set_id); |
489 layout->AddView(new AccessibilitySection(profile())); | 528 layout->AddView(new AccessibilitySection(profile())); |
490 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 529 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
491 } | 530 } |
492 | 531 |
493 } // namespace chromeos | 532 } // namespace chromeos |
OLD | NEW |