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/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/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 IntegerPrefMember xkb_auto_repeat_interval_pref_; | 396 IntegerPrefMember xkb_auto_repeat_interval_pref_; |
397 views::Slider* xkb_auto_repeat_interval_slider_; | 397 views::Slider* xkb_auto_repeat_interval_slider_; |
398 | 398 |
399 DISALLOW_COPY_AND_ASSIGN(LanguageSection); | 399 DISALLOW_COPY_AND_ASSIGN(LanguageSection); |
400 }; | 400 }; |
401 | 401 |
402 LanguageSection::LanguageSection(Profile* profile) | 402 LanguageSection::LanguageSection(Profile* profile) |
403 : SettingsPageSection(profile, | 403 : SettingsPageSection(profile, |
404 IDS_OPTIONS_SETTINGS_SECTION_TITLE_LANGUAGE), | 404 IDS_OPTIONS_SETTINGS_SECTION_TITLE_LANGUAGE), |
405 xkb_modifier_combobox_(NULL), | 405 xkb_modifier_combobox_(NULL), |
406 xkb_modifier_combobox_model_(&kXkbModifierMultipleChoicePrefs), | 406 xkb_modifier_combobox_model_( |
| 407 &language_prefs::kXkbModifierMultipleChoicePrefs), |
407 xkb_auto_repeat_delay_slider_(NULL), | 408 xkb_auto_repeat_delay_slider_(NULL), |
408 xkb_auto_repeat_interval_slider_(NULL) { | 409 xkb_auto_repeat_interval_slider_(NULL) { |
409 xkb_remap_search_key_pref_.Init( | 410 xkb_remap_search_key_pref_.Init( |
410 prefs::kLanguageXkbRemapSearchKeyTo, profile->GetPrefs(), this); | 411 prefs::kLanguageXkbRemapSearchKeyTo, profile->GetPrefs(), this); |
411 xkb_remap_control_key_pref_.Init( | 412 xkb_remap_control_key_pref_.Init( |
412 prefs::kLanguageXkbRemapControlKeyTo, profile->GetPrefs(), this); | 413 prefs::kLanguageXkbRemapControlKeyTo, profile->GetPrefs(), this); |
413 xkb_remap_alt_key_pref_.Init( | 414 xkb_remap_alt_key_pref_.Init( |
414 prefs::kLanguageXkbRemapAltKeyTo, profile->GetPrefs(), this); | 415 prefs::kLanguageXkbRemapAltKeyTo, profile->GetPrefs(), this); |
415 xkb_auto_repeat_pref_.Init( | 416 xkb_auto_repeat_pref_.Init( |
416 prefs::kLanguageXkbAutoRepeatEnabled, profile->GetPrefs(), this); | 417 prefs::kLanguageXkbAutoRepeatEnabled, profile->GetPrefs(), this); |
417 xkb_auto_repeat_delay_pref_.Init( | 418 xkb_auto_repeat_delay_pref_.Init( |
418 kXkbAutoRepeatDelayPref.pref_name, profile->GetPrefs(), this); | 419 language_prefs::kXkbAutoRepeatDelayPref.pref_name, |
| 420 profile->GetPrefs(), this); |
419 xkb_auto_repeat_interval_pref_.Init( | 421 xkb_auto_repeat_interval_pref_.Init( |
420 kXkbAutoRepeatIntervalPref.pref_name, profile->GetPrefs(), this); | 422 language_prefs::kXkbAutoRepeatIntervalPref.pref_name, |
| 423 profile->GetPrefs(), this); |
421 } | 424 } |
422 | 425 |
423 void LanguageSection::InitContents(GridLayout* layout) { | 426 void LanguageSection::InitContents(GridLayout* layout) { |
424 // Add the customize button and XKB combobox. | 427 // Add the customize button and XKB combobox. |
425 layout->StartRow(0, double_column_view_set_id()); | 428 layout->StartRow(0, double_column_view_set_id()); |
426 views::NativeButton* customize_languages_button = new views::NativeButton( | 429 views::NativeButton* customize_languages_button = new views::NativeButton( |
427 this, | 430 this, |
428 l10n_util::GetString(IDS_OPTIONS_SETTINGS_LANGUAGES_CUSTOMIZE)); | 431 l10n_util::GetString(IDS_OPTIONS_SETTINGS_LANGUAGES_CUSTOMIZE)); |
429 customize_languages_button->set_tag(kCustomizeLanguagesButton); | 432 customize_languages_button->set_tag(kCustomizeLanguagesButton); |
430 | 433 |
431 xkb_modifier_combobox_ = new views::Combobox(&xkb_modifier_combobox_model_); | 434 xkb_modifier_combobox_ = new views::Combobox(&xkb_modifier_combobox_model_); |
432 xkb_modifier_combobox_->set_listener(this); | 435 xkb_modifier_combobox_->set_listener(this); |
433 | 436 |
434 xkb_auto_repeat_checkbox_ = new views::Checkbox(l10n_util::GetString( | 437 xkb_auto_repeat_checkbox_ = new views::Checkbox(l10n_util::GetString( |
435 IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_REPEAT_ENABLED)); | 438 IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_REPEAT_ENABLED)); |
436 xkb_auto_repeat_checkbox_->set_tag(kEnableAutoRepeatButton); | 439 xkb_auto_repeat_checkbox_->set_tag(kEnableAutoRepeatButton); |
437 xkb_auto_repeat_checkbox_->set_listener(this); | 440 xkb_auto_repeat_checkbox_->set_listener(this); |
438 | 441 |
439 xkb_auto_repeat_delay_slider_ = new views::Slider( | 442 xkb_auto_repeat_delay_slider_ = new views::Slider( |
440 kXkbAutoRepeatDelayPref.min_pref_value, | 443 language_prefs::kXkbAutoRepeatDelayPref.min_pref_value, |
441 kXkbAutoRepeatDelayPref.max_pref_value, | 444 language_prefs::kXkbAutoRepeatDelayPref.max_pref_value, |
442 1, | 445 1, |
443 static_cast<views::Slider::StyleFlags>( | 446 static_cast<views::Slider::StyleFlags>( |
444 views::Slider::STYLE_UPDATE_ON_RELEASE), | 447 views::Slider::STYLE_UPDATE_ON_RELEASE), |
445 this); | 448 this); |
446 xkb_auto_repeat_interval_slider_ = new views::Slider( | 449 xkb_auto_repeat_interval_slider_ = new views::Slider( |
447 kXkbAutoRepeatIntervalPref.min_pref_value, | 450 language_prefs::kXkbAutoRepeatIntervalPref.min_pref_value, |
448 kXkbAutoRepeatIntervalPref.max_pref_value, | 451 language_prefs::kXkbAutoRepeatIntervalPref.max_pref_value, |
449 1, | 452 1, |
450 static_cast<views::Slider::StyleFlags>( | 453 static_cast<views::Slider::StyleFlags>( |
451 views::Slider::STYLE_UPDATE_ON_RELEASE), | 454 views::Slider::STYLE_UPDATE_ON_RELEASE), |
452 this); | 455 this); |
453 | 456 |
454 // Initialize the combobox to what's saved in user preferences. Otherwise, | 457 // Initialize the combobox to what's saved in user preferences. Otherwise, |
455 // ItemChanged() will be called with |new_index| == 0. | 458 // ItemChanged() will be called with |new_index| == 0. |
456 NotifyPrefChanged(NULL); | 459 NotifyPrefChanged(NULL); |
457 | 460 |
458 layout->AddView(customize_languages_button, 1, 1, | 461 layout->AddView(customize_languages_button, 1, 1, |
459 GridLayout::LEADING, GridLayout::CENTER); | 462 GridLayout::LEADING, GridLayout::CENTER); |
460 layout->AddView(xkb_modifier_combobox_); | 463 layout->AddView(xkb_modifier_combobox_); |
461 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 464 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
462 layout->StartRow(0, single_column_view_set_id()); | 465 layout->StartRow(0, single_column_view_set_id()); |
463 layout->AddView(xkb_auto_repeat_checkbox_); | 466 layout->AddView(xkb_auto_repeat_checkbox_); |
464 | 467 |
465 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 468 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
466 layout->StartRow(0, quad_column_view_set_id()); | 469 layout->StartRow(0, quad_column_view_set_id()); |
467 layout->AddView(new views::Label( | 470 layout->AddView(new views::Label( |
468 l10n_util::GetString(kXkbAutoRepeatDelayPref.message_id)), | 471 l10n_util::GetString( |
| 472 language_prefs::kXkbAutoRepeatDelayPref.message_id)), |
469 1, 1, GridLayout::LEADING, GridLayout::CENTER); | 473 1, 1, GridLayout::LEADING, GridLayout::CENTER); |
470 layout->AddView(new views::Label( | 474 layout->AddView(new views::Label( |
471 l10n_util::GetString( | 475 l10n_util::GetString( |
472 IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_REPEAT_DELAY_SHORT))); | 476 IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_REPEAT_DELAY_SHORT))); |
473 layout->AddView(xkb_auto_repeat_delay_slider_); | 477 layout->AddView(xkb_auto_repeat_delay_slider_); |
474 layout->AddView(new views::Label( | 478 layout->AddView(new views::Label( |
475 l10n_util::GetString( | 479 l10n_util::GetString( |
476 IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_REPEAT_DELAY_LONG))); | 480 IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_REPEAT_DELAY_LONG))); |
477 | 481 |
478 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 482 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
479 layout->StartRow(0, quad_column_view_set_id()); | 483 layout->StartRow(0, quad_column_view_set_id()); |
480 layout->AddView(new views::Label( | 484 layout->AddView(new views::Label( |
481 l10n_util::GetString(kXkbAutoRepeatIntervalPref.message_id)), | 485 l10n_util::GetString( |
| 486 language_prefs::kXkbAutoRepeatIntervalPref.message_id)), |
482 1, 1, GridLayout::LEADING, GridLayout::CENTER); | 487 1, 1, GridLayout::LEADING, GridLayout::CENTER); |
483 layout->AddView(new views::Label( | 488 layout->AddView(new views::Label( |
484 l10n_util::GetString( | 489 l10n_util::GetString( |
485 IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_REPEAT_SPEED_FAST))); | 490 IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_REPEAT_SPEED_FAST))); |
486 layout->AddView(xkb_auto_repeat_interval_slider_); | 491 layout->AddView(xkb_auto_repeat_interval_slider_); |
487 layout->AddView(new views::Label( | 492 layout->AddView(new views::Label( |
488 l10n_util::GetString( | 493 l10n_util::GetString( |
489 IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_REPEAT_SPEED_SLOW))); | 494 IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_REPEAT_SPEED_SLOW))); |
490 | 495 |
491 layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); | 496 layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); |
(...skipping 10 matching lines...) Expand all Loading... |
502 } | 507 } |
503 | 508 |
504 void LanguageSection::ItemChanged(views::Combobox* sender, | 509 void LanguageSection::ItemChanged(views::Combobox* sender, |
505 int prev_index, | 510 int prev_index, |
506 int new_index) { | 511 int new_index) { |
507 LOG(INFO) << "Changing XKB modofier pref to " << new_index; | 512 LOG(INFO) << "Changing XKB modofier pref to " << new_index; |
508 switch (new_index) { | 513 switch (new_index) { |
509 default: | 514 default: |
510 LOG(ERROR) << "Unexpected mapping: " << new_index; | 515 LOG(ERROR) << "Unexpected mapping: " << new_index; |
511 /* fall through */ | 516 /* fall through */ |
512 case kNoRemap: | 517 case language_prefs::kNoRemap: |
513 xkb_remap_search_key_pref_.SetValue(kSearchKey); | 518 xkb_remap_search_key_pref_.SetValue(kSearchKey); |
514 xkb_remap_control_key_pref_.SetValue(kLeftControlKey); | 519 xkb_remap_control_key_pref_.SetValue(kLeftControlKey); |
515 xkb_remap_alt_key_pref_.SetValue(kLeftAltKey); | 520 xkb_remap_alt_key_pref_.SetValue(kLeftAltKey); |
516 break; | 521 break; |
517 case kSwapCtrlAndAlt: | 522 case language_prefs::kSwapCtrlAndAlt: |
518 xkb_remap_search_key_pref_.SetValue(kSearchKey); | 523 xkb_remap_search_key_pref_.SetValue(kSearchKey); |
519 xkb_remap_control_key_pref_.SetValue(kLeftAltKey); | 524 xkb_remap_control_key_pref_.SetValue(kLeftAltKey); |
520 xkb_remap_alt_key_pref_.SetValue(kLeftControlKey); | 525 xkb_remap_alt_key_pref_.SetValue(kLeftControlKey); |
521 break; | 526 break; |
522 case kSwapSearchAndCtrl: | 527 case language_prefs::kSwapSearchAndCtrl: |
523 xkb_remap_search_key_pref_.SetValue(kLeftControlKey); | 528 xkb_remap_search_key_pref_.SetValue(kLeftControlKey); |
524 xkb_remap_control_key_pref_.SetValue(kSearchKey); | 529 xkb_remap_control_key_pref_.SetValue(kSearchKey); |
525 xkb_remap_alt_key_pref_.SetValue(kLeftAltKey); | 530 xkb_remap_alt_key_pref_.SetValue(kLeftAltKey); |
526 break; | 531 break; |
527 } | 532 } |
528 } | 533 } |
529 | 534 |
530 void LanguageSection::SliderValueChanged(views::Slider* sender) { | 535 void LanguageSection::SliderValueChanged(views::Slider* sender) { |
531 if (xkb_auto_repeat_delay_slider_ == sender) { | 536 if (xkb_auto_repeat_delay_slider_ == sender) { |
532 xkb_auto_repeat_delay_pref_.SetValue(sender->value()); | 537 xkb_auto_repeat_delay_pref_.SetValue(sender->value()); |
533 } else if (xkb_auto_repeat_interval_slider_ == sender) { | 538 } else if (xkb_auto_repeat_interval_slider_ == sender) { |
534 xkb_auto_repeat_interval_pref_.SetValue(sender->value()); | 539 xkb_auto_repeat_interval_pref_.SetValue(sender->value()); |
535 } | 540 } |
536 } | 541 } |
537 | 542 |
538 void LanguageSection::NotifyPrefChanged(const std::string* pref_name) { | 543 void LanguageSection::NotifyPrefChanged(const std::string* pref_name) { |
539 if (!pref_name || (*pref_name == prefs::kLanguageXkbRemapSearchKeyTo || | 544 if (!pref_name || (*pref_name == prefs::kLanguageXkbRemapSearchKeyTo || |
540 *pref_name == prefs::kLanguageXkbRemapControlKeyTo || | 545 *pref_name == prefs::kLanguageXkbRemapControlKeyTo || |
541 *pref_name == prefs::kLanguageXkbRemapAltKeyTo)) { | 546 *pref_name == prefs::kLanguageXkbRemapAltKeyTo)) { |
542 const int search_remap = xkb_remap_search_key_pref_.GetValue(); | 547 const int search_remap = xkb_remap_search_key_pref_.GetValue(); |
543 const int control_remap = xkb_remap_control_key_pref_.GetValue(); | 548 const int control_remap = xkb_remap_control_key_pref_.GetValue(); |
544 const int alt_remap = xkb_remap_alt_key_pref_.GetValue(); | 549 const int alt_remap = xkb_remap_alt_key_pref_.GetValue(); |
545 if ((search_remap == kSearchKey) && | 550 if ((search_remap == kSearchKey) && |
546 (control_remap == kLeftControlKey) && | 551 (control_remap == kLeftControlKey) && |
547 (alt_remap == kLeftAltKey)) { | 552 (alt_remap == kLeftAltKey)) { |
548 xkb_modifier_combobox_->SetSelectedItem(kNoRemap); | 553 xkb_modifier_combobox_->SetSelectedItem(language_prefs::kNoRemap); |
549 } else if ((search_remap == kLeftControlKey) && | 554 } else if ((search_remap == kLeftControlKey) && |
550 (control_remap == kSearchKey) && | 555 (control_remap == kSearchKey) && |
551 (alt_remap == kLeftAltKey)) { | 556 (alt_remap == kLeftAltKey)) { |
552 xkb_modifier_combobox_->SetSelectedItem(kSwapSearchAndCtrl); | 557 xkb_modifier_combobox_->SetSelectedItem( |
| 558 language_prefs::kSwapSearchAndCtrl); |
553 } else if ((search_remap == kSearchKey) && | 559 } else if ((search_remap == kSearchKey) && |
554 (control_remap == kLeftAltKey) && | 560 (control_remap == kLeftAltKey) && |
555 (alt_remap == kLeftControlKey)) { | 561 (alt_remap == kLeftControlKey)) { |
556 xkb_modifier_combobox_->SetSelectedItem(kSwapCtrlAndAlt); | 562 xkb_modifier_combobox_->SetSelectedItem(language_prefs::kSwapCtrlAndAlt); |
557 } else { | 563 } else { |
558 LOG(ERROR) << "Unexpected mapping. The prefs are updated by DOMUI?"; | 564 LOG(ERROR) << "Unexpected mapping. The prefs are updated by DOMUI?"; |
559 xkb_modifier_combobox_->SetSelectedItem(kNoRemap); | 565 xkb_modifier_combobox_->SetSelectedItem(language_prefs::kNoRemap); |
560 } | 566 } |
561 } | 567 } |
562 if (!pref_name || *pref_name == prefs::kLanguageXkbAutoRepeatEnabled) { | 568 if (!pref_name || *pref_name == prefs::kLanguageXkbAutoRepeatEnabled) { |
563 const bool enabled = xkb_auto_repeat_pref_.GetValue(); | 569 const bool enabled = xkb_auto_repeat_pref_.GetValue(); |
564 xkb_auto_repeat_checkbox_->SetChecked(enabled); | 570 xkb_auto_repeat_checkbox_->SetChecked(enabled); |
565 } | 571 } |
566 if (!pref_name || *pref_name == kXkbAutoRepeatDelayPref.pref_name) { | 572 if (!pref_name || |
| 573 *pref_name == language_prefs::kXkbAutoRepeatDelayPref.pref_name) { |
567 const int delay_value = xkb_auto_repeat_delay_pref_.GetValue(); | 574 const int delay_value = xkb_auto_repeat_delay_pref_.GetValue(); |
568 xkb_auto_repeat_delay_slider_->SetValue(delay_value); | 575 xkb_auto_repeat_delay_slider_->SetValue(delay_value); |
569 } | 576 } |
570 if (!pref_name || *pref_name == kXkbAutoRepeatIntervalPref.pref_name) { | 577 if (!pref_name || |
| 578 *pref_name == language_prefs::kXkbAutoRepeatIntervalPref.pref_name) { |
571 const int interval_value = xkb_auto_repeat_interval_pref_.GetValue(); | 579 const int interval_value = xkb_auto_repeat_interval_pref_.GetValue(); |
572 xkb_auto_repeat_interval_slider_->SetValue(interval_value); | 580 xkb_auto_repeat_interval_slider_->SetValue(interval_value); |
573 } | 581 } |
574 } | 582 } |
575 | 583 |
576 /////////////////////////////////////////////////////////////////////////////// | 584 /////////////////////////////////////////////////////////////////////////////// |
577 // AccessibilitySection | 585 // AccessibilitySection |
578 | 586 |
579 // Checkbox for specifying if accessibility should be enabled for this profile | 587 // Checkbox for specifying if accessibility should be enabled for this profile |
580 class AccessibilitySection : public SettingsPageSection, | 588 class AccessibilitySection : public SettingsPageSection, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 673 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
666 layout->StartRow(0, single_column_view_set_id); | 674 layout->StartRow(0, single_column_view_set_id); |
667 layout->AddView(new LanguageSection(profile())); | 675 layout->AddView(new LanguageSection(profile())); |
668 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 676 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
669 layout->StartRow(0, single_column_view_set_id); | 677 layout->StartRow(0, single_column_view_set_id); |
670 layout->AddView(new AccessibilitySection(profile())); | 678 layout->AddView(new AccessibilitySection(profile())); |
671 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 679 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
672 } | 680 } |
673 | 681 |
674 } // namespace chromeos | 682 } // namespace chromeos |
OLD | NEW |