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" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 | 381 |
382 void LanguageSection::InitContents(GridLayout* layout) { | 382 void LanguageSection::InitContents(GridLayout* layout) { |
383 // Add the customize button. | 383 // Add the customize button. |
384 layout->StartRow(0, single_column_view_set_id()); | 384 layout->StartRow(0, single_column_view_set_id()); |
385 views::NativeButton* customize_languages_button = new views::NativeButton( | 385 views::NativeButton* customize_languages_button = new views::NativeButton( |
386 this, | 386 this, |
387 l10n_util::GetString(IDS_OPTIONS_SETTINGS_LANGUAGES_CUSTOMIZE)); | 387 l10n_util::GetString(IDS_OPTIONS_SETTINGS_LANGUAGES_CUSTOMIZE)); |
388 customize_languages_button->set_tag(kCustomizeLanguagesButton); | 388 customize_languages_button->set_tag(kCustomizeLanguagesButton); |
389 layout->AddView(customize_languages_button, 1, 1, | 389 layout->AddView(customize_languages_button, 1, 1, |
390 GridLayout::LEADING, GridLayout::CENTER); | 390 GridLayout::LEADING, GridLayout::CENTER); |
| 391 layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); |
391 } | 392 } |
392 | 393 |
393 void LanguageSection::ButtonPressed( | 394 void LanguageSection::ButtonPressed( |
394 views::Button* sender, const views::Event& event) { | 395 views::Button* sender, const views::Event& event) { |
395 if (sender->tag() == kCustomizeLanguagesButton) { | 396 if (sender->tag() == kCustomizeLanguagesButton) { |
396 LanguageConfigView::Show(profile(), GetOptionsViewParent()); | 397 LanguageConfigView::Show(profile(), GetOptionsViewParent()); |
397 } | 398 } |
398 } | 399 } |
399 | 400 |
| 401 /////////////////////////////////////////////////////////////////////////////// |
| 402 // AccessibilitySection |
| 403 |
| 404 // Checkbox for specifying if accessibility should be enabled for this profile |
| 405 class AccessibilitySection : public SettingsPageSection, |
| 406 public views::ButtonListener { |
| 407 public: |
| 408 explicit AccessibilitySection(Profile* profile); |
| 409 virtual ~AccessibilitySection() {} |
| 410 |
| 411 protected: |
| 412 // Overridden from views::ButtonListener: |
| 413 virtual void ButtonPressed(views::Button* sender, |
| 414 const views::Event& event); |
| 415 |
| 416 // Overridden from SettingsPageSection: |
| 417 virtual void InitContents(GridLayout* layout); |
| 418 virtual void NotifyPrefChanged(const std::wstring* pref_name); |
| 419 |
| 420 private: |
| 421 // The View that contains the contents of the section. |
| 422 views::View* contents_; |
| 423 |
| 424 // Controls for this section: |
| 425 views::Checkbox* accessibility_checkbox_; |
| 426 |
| 427 // Preferences for this section: |
| 428 BooleanPrefMember accessibility_enabled_; |
| 429 |
| 430 DISALLOW_COPY_AND_ASSIGN(AccessibilitySection); |
| 431 }; |
| 432 |
| 433 AccessibilitySection::AccessibilitySection(Profile* profile) |
| 434 : SettingsPageSection(profile, |
| 435 IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY), |
| 436 accessibility_checkbox_(NULL) { |
| 437 } |
| 438 |
| 439 void AccessibilitySection::InitContents(GridLayout* layout) { |
| 440 accessibility_checkbox_ = new views::Checkbox(l10n_util::GetString( |
| 441 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_DESCRIPTION)); |
| 442 accessibility_checkbox_->set_listener(this); |
| 443 accessibility_checkbox_->SetMultiLine(true); |
| 444 |
| 445 layout->StartRow(0, double_column_view_set_id()); |
| 446 layout->AddView(accessibility_checkbox_); |
| 447 layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); |
| 448 |
| 449 // Init member prefs so we can update the controls if prefs change. |
| 450 accessibility_enabled_.Init(prefs::kAccessibilityEnabled, |
| 451 profile()->GetPrefs(), this); |
| 452 } |
| 453 |
| 454 void AccessibilitySection::ButtonPressed( |
| 455 views::Button* sender, const views::Event& event) { |
| 456 if (sender == accessibility_checkbox_) { |
| 457 bool enabled = accessibility_checkbox_->checked(); |
| 458 // Set the accessibility enabled value in profile/prefs |
| 459 accessibility_enabled_.SetValue(enabled); |
| 460 } |
| 461 } |
| 462 |
| 463 void AccessibilitySection::NotifyPrefChanged(const std::wstring* pref_name) { |
| 464 if (!pref_name || *pref_name == prefs::kAccessibilityEnabled) { |
| 465 bool enabled = accessibility_enabled_.GetValue(); |
| 466 accessibility_checkbox_->SetChecked(enabled); |
| 467 } |
| 468 } |
| 469 |
400 //////////////////////////////////////////////////////////////////////////////// | 470 //////////////////////////////////////////////////////////////////////////////// |
401 // SystemPageView | 471 // SystemPageView |
402 | 472 |
403 //////////////////////////////////////////////////////////////////////////////// | 473 //////////////////////////////////////////////////////////////////////////////// |
404 // SystemPageView, SettingsPageView implementation: | 474 // SystemPageView, SettingsPageView implementation: |
405 | 475 |
406 void SystemPageView::InitControlLayout() { | 476 void SystemPageView::InitControlLayout() { |
407 GridLayout* layout = CreatePanelGridLayout(this); | 477 GridLayout* layout = CreatePanelGridLayout(this); |
408 SetLayoutManager(layout); | 478 SetLayoutManager(layout); |
409 | 479 |
410 int single_column_view_set_id = 0; | 480 int single_column_view_set_id = 0; |
411 ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id); | 481 ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id); |
412 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 482 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |
413 GridLayout::USE_PREF, 0, 0); | 483 GridLayout::USE_PREF, 0, 0); |
414 | 484 |
415 layout->StartRow(0, single_column_view_set_id); | 485 layout->StartRow(0, single_column_view_set_id); |
416 layout->AddView(new DateTimeSection(profile())); | 486 layout->AddView(new DateTimeSection(profile())); |
417 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 487 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
418 layout->StartRow(0, single_column_view_set_id); | 488 layout->StartRow(0, single_column_view_set_id); |
419 layout->AddView(new TouchpadSection(profile())); | 489 layout->AddView(new TouchpadSection(profile())); |
420 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 490 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
421 layout->StartRow(0, single_column_view_set_id); | 491 layout->StartRow(0, single_column_view_set_id); |
422 layout->AddView(new LanguageSection(profile())); | 492 layout->AddView(new LanguageSection(profile())); |
423 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 493 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
| 494 layout->StartRow(0, single_column_view_set_id); |
| 495 layout->AddView(new AccessibilitySection(profile())); |
| 496 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
424 } | 497 } |
425 | 498 |
426 } // namespace chromeos | 499 } // namespace chromeos |
OLD | NEW |