summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-03 03:28:21 +0000
committerzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-03 03:28:21 +0000
commit15c5308c0936da6a3817fd36df2d29f1aa2ced5e (patch)
treeab98a49b1c1df48821abb891d5738c3ccd52e026
parent068c30e965e6d1f04e9bb999402434719bc41275 (diff)
downloadchromium_src-15c5308c0936da6a3817fd36df2d29f1aa2ced5e.zip
chromium_src-15c5308c0936da6a3817fd36df2d29f1aa2ced5e.tar.gz
chromium_src-15c5308c0936da6a3817fd36df2d29f1aa2ced5e.tar.bz2
Add Chewing integer preferences
BUG=chromium-os:2624 TEST=Open the IME settings window. Add Traditional Chinese. Open the options dialog, and check that the integer prefs are there Review URL: http://codereview.chromium.org/2457001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48806 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd9
-rw-r--r--chrome/browser/chromeos/language_preferences.h17
-rw-r--r--chrome/browser/chromeos/options/language_chewing_config_view.cc41
-rw-r--r--chrome/browser/chromeos/options/language_chewing_config_view.h8
-rw-r--r--chrome/browser/chromeos/preferences.cc15
-rw-r--r--chrome/browser/chromeos/preferences.h1
-rw-r--r--chrome/common/pref_names.cc6
-rw-r--r--chrome/common/pref_names.h2
8 files changed, 96 insertions, 3 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index e6a4b63..19ea2420 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -7568,6 +7568,15 @@ Keep your key file in a safe place. You will need it to create new versions of y
desc="The checkbox label for a Chewing input method preference">
Press Space to select the candidate
</message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_CHEWING_SETTING_MAX_CHI_SYMBOL_LEN"
+ desc="The label for a Chewing input method preference">
+ Maximum Chinese characters in pre-edit buffer, including inputing Zhuyin
+ symbols
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_CHEWING_SETTING_CAND_PER_PAGE"
+ desc="The label for a Chewing input method preference">
+ Number of candidates to display per page
+ </message>
<message name="IDS_OPTIONS_SETTINGS_LANGUAGES_CHEWING_KEYBOARD_TYPE"
desc="The combobox description for the Chewing keyboard type">
diff --git a/chrome/browser/chromeos/language_preferences.h b/chrome/browser/chromeos/language_preferences.h
index d8f0776..6674a7b 100644
--- a/chrome/browser/chromeos/language_preferences.h
+++ b/chrome/browser/chromeos/language_preferences.h
@@ -65,6 +65,21 @@ const struct {
};
const size_t kNumChewingBooleanPrefs = ARRAYSIZE_UNSAFE(kChewingBooleanPrefs);
+const struct {
+ const wchar_t* pref_name; // Chrome preference name.
+ int default_pref_value;
+ int min_pref_value;
+ int max_pref_value;
+ const char* ibus_config_name;
+ int message_id;
+} kChewingIntegerPrefs[] = {
+ { prefs::kLanguageChewingMaxChiSymbolLen, 20, 8, 40, "maxChiSymbolLen",
+ IDS_OPTIONS_SETTINGS_LANGUAGES_CHEWING_SETTING_MAX_CHI_SYMBOL_LEN},
+ { prefs::kLanguageChewingCandPerPage, 10, 8, 10, "candPerPage",
+ IDS_OPTIONS_SETTINGS_LANGUAGES_CHEWING_SETTING_CAND_PER_PAGE},
+};
+const size_t kNumChewingIntegerPrefs = ARRAYSIZE_UNSAFE(kChewingIntegerPrefs);
+
const struct ChewingMultipleChoicePreference {
const wchar_t* pref_name; // Chrome preference name.
const wchar_t* default_pref_value;
@@ -121,7 +136,7 @@ const struct ChewingMultipleChoicePreference {
};
const size_t kNumChewingMultipleChoicePrefs =
arraysize(kChewingMultipleChoicePrefs);
-// TODO(zork): Support candPerPage, hsuSelKeyType, and maxChiSymbolLen
+// TODO(zork): Support hsuSelKeyType
// For Korean input method (ibus-hangul)
const char kHangulSectionName[] = "engine/Hangul";
diff --git a/chrome/browser/chromeos/options/language_chewing_config_view.cc b/chrome/browser/chromeos/options/language_chewing_config_view.cc
index 25c25a8..0941a62 100644
--- a/chrome/browser/chromeos/options/language_chewing_config_view.cc
+++ b/chrome/browser/chromeos/options/language_chewing_config_view.cc
@@ -126,6 +126,11 @@ LanguageChewingConfigView::LanguageChewingConfigView(Profile* profile)
new ChewingComboboxModel(&kChewingMultipleChoicePrefs[i]);
current.combobox = NULL;
}
+ for (size_t i = 0; i < kNumChewingIntegerPrefs; ++i) {
+ chewing_integer_prefs_[i].Init(
+ kChewingIntegerPrefs[i].pref_name, profile->GetPrefs(), this);
+ chewing_integer_sliders_[i] = NULL;
+ }
}
LanguageChewingConfigView::~LanguageChewingConfigView() {
@@ -154,6 +159,17 @@ void LanguageChewingConfigView::ItemChanged(
}
}
+void LanguageChewingConfigView::SliderValueChanged(views::Slider* sender) {
+ size_t pref_id;
+ for (pref_id = 0; pref_id < kNumChewingIntegerPrefs; ++pref_id) {
+ if (chewing_integer_sliders_[pref_id] == sender)
+ break;
+ }
+ DCHECK(pref_id < kNumChewingIntegerPrefs);
+ chewing_integer_prefs_[pref_id].SetValue(sender->value());
+}
+
+
void LanguageChewingConfigView::Layout() {
// Not sure why but this is needed to show contents in the dialog.
contents_->SetBounds(0, 0, width(), height());
@@ -187,7 +203,7 @@ void LanguageChewingConfigView::InitControlLayout() {
column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
GridLayout::USE_PREF, 0, 0);
column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
+ column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0,
GridLayout::USE_PREF, 0, 0);
for (size_t i = 0; i < kNumChewingBooleanPrefs; ++i) {
@@ -201,12 +217,29 @@ void LanguageChewingConfigView::InitControlLayout() {
current.combobox = new ChewingCombobox(current.combobox_model);
current.combobox->set_listener(this);
}
- NotifyPrefChanged();
+ for (size_t i = 0; i < kNumChewingIntegerPrefs; ++i) {
+ chewing_integer_sliders_[i] = new views::Slider(
+ kChewingIntegerPrefs[i].min_pref_value,
+ kChewingIntegerPrefs[i].max_pref_value,
+ 1,
+ static_cast<views::Slider::StyleFlags>(
+ views::Slider::STYLE_DRAW_VALUE |
+ views::Slider::STYLE_UPDATE_ON_RELEASE),
+ this);
+ }
for (size_t i = 0; i < kNumChewingBooleanPrefs; ++i) {
layout->StartRow(0, kColumnSetId);
layout->AddView(chewing_boolean_checkboxes_[i]);
}
+ for (size_t i = 0; i < kNumChewingIntegerPrefs; ++i) {
+ layout->StartRow(0, kColumnSetId);
+ layout->AddView(new views::Label(
+ l10n_util::GetString(kChewingIntegerPrefs[i].message_id)));
+ layout->AddView(chewing_integer_sliders_[i]);
+ }
+ NotifyPrefChanged();
+
// Show the comboboxes.
for (size_t i = 0; i < kNumChewingMultipleChoicePrefs; ++i) {
const ChewingPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i];
@@ -229,6 +262,10 @@ void LanguageChewingConfigView::NotifyPrefChanged() {
const bool checked = chewing_boolean_prefs_[i].GetValue();
chewing_boolean_checkboxes_[i]->SetChecked(checked);
}
+ for (size_t i = 0; i < kNumChewingIntegerPrefs; ++i) {
+ const int value = chewing_integer_prefs_[i].GetValue();
+ chewing_integer_sliders_[i]->SetValue(value);
+ }
for (size_t i = 0; i < kNumChewingMultipleChoicePrefs; ++i) {
ChewingPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i];
const std::wstring value = current.multiple_choice_pref.GetValue();
diff --git a/chrome/browser/chromeos/options/language_chewing_config_view.h b/chrome/browser/chromeos/options/language_chewing_config_view.h
index 6e2e88b..99daa46 100644
--- a/chrome/browser/chromeos/options/language_chewing_config_view.h
+++ b/chrome/browser/chromeos/options/language_chewing_config_view.h
@@ -14,6 +14,7 @@
#include "views/controls/button/checkbox.h"
#include "views/controls/combobox/combobox.h"
#include "views/controls/label.h"
+#include "views/controls/slider/slider.h"
#include "views/window/dialog_delegate.h"
namespace chromeos {
@@ -26,6 +27,7 @@ class ChewingComboboxModel;
class LanguageChewingConfigView : public views::ButtonListener,
public views::Combobox::Listener,
public views::DialogDelegate,
+ public views::SliderListener,
public OptionsPageView {
public:
explicit LanguageChewingConfigView(Profile* profile);
@@ -39,6 +41,9 @@ class LanguageChewingConfigView : public views::ButtonListener,
int prev_index,
int new_index);
+ // views::SliderListener overrides.
+ virtual void SliderValueChanged(views::Slider* sender);
+
// views::DialogDelegate overrides.
virtual bool IsModal() const { return true; }
virtual views::View* GetContentsView() { return this; }
@@ -61,11 +66,14 @@ class LanguageChewingConfigView : public views::ButtonListener,
void NotifyPrefChanged();
BooleanPrefMember chewing_boolean_prefs_[kNumChewingBooleanPrefs];
+ IntegerPrefMember chewing_integer_prefs_[kNumChewingIntegerPrefs];
views::View* contents_;
// Checkboxes for Chewing.
views::Checkbox* chewing_boolean_checkboxes_[kNumChewingBooleanPrefs];
+ views::Slider* chewing_integer_sliders_[kNumChewingIntegerPrefs];
+
struct ChewingPrefAndAssociatedCombobox {
StringPrefMember multiple_choice_pref;
ChewingComboboxModel* combobox_model;
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index ea45ae4..7314803 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -40,6 +40,10 @@ void Preferences::RegisterUserPrefs(PrefService* prefs) {
kChewingMultipleChoicePrefs[i].pref_name,
kChewingMultipleChoicePrefs[i].default_pref_value);
}
+ for (size_t i = 0; i < kNumChewingIntegerPrefs; ++i) {
+ prefs->RegisterIntegerPref(kChewingIntegerPrefs[i].pref_name,
+ kChewingIntegerPrefs[i].default_pref_value);
+ }
prefs->RegisterStringPref(prefs::kLanguageHangulKeyboard,
kHangulKeyboardNameIDPairs[0].keyboard_id);
for (size_t i = 0; i < kNumPinyinBooleanPrefs; ++i) {
@@ -76,6 +80,10 @@ void Preferences::Init(PrefService* prefs) {
language_chewing_multiple_choice_prefs_[i].Init(
kChewingMultipleChoicePrefs[i].pref_name, prefs, this);
}
+ for (size_t i = 0; i < kNumChewingIntegerPrefs; ++i) {
+ language_chewing_integer_prefs_[i].Init(
+ kChewingIntegerPrefs[i].pref_name, prefs, this);
+ }
language_hangul_keyboard_.Init(prefs::kLanguageHangulKeyboard, prefs, this);
for (size_t i = 0; i < kNumPinyinBooleanPrefs; ++i) {
language_pinyin_boolean_prefs_[i].Init(
@@ -154,6 +162,13 @@ void Preferences::NotifyPrefChanged(const std::wstring* pref_name) {
language_chewing_multiple_choice_prefs_[i].GetValue());
}
}
+ for (size_t i = 0; i < kNumChewingIntegerPrefs; ++i) {
+ if (!pref_name || *pref_name == kChewingIntegerPrefs[i].pref_name) {
+ SetLanguageConfigInteger(kChewingSectionName,
+ kChewingIntegerPrefs[i].ibus_config_name,
+ language_chewing_integer_prefs_[i].GetValue());
+ }
+ }
if (!pref_name || *pref_name == prefs::kLanguageHangulKeyboard) {
SetLanguageConfigString(kHangulSectionName, kHangulKeyboardConfigName,
language_hangul_keyboard_.GetValue());
diff --git a/chrome/browser/chromeos/preferences.h b/chrome/browser/chromeos/preferences.h
index 0fc1ea3..e540348 100644
--- a/chrome/browser/chromeos/preferences.h
+++ b/chrome/browser/chromeos/preferences.h
@@ -90,6 +90,7 @@ class Preferences : public NotificationObserver {
BooleanPrefMember language_chewing_boolean_prefs_[kNumChewingBooleanPrefs];
StringPrefMember language_chewing_multiple_choice_prefs_[
kNumChewingMultipleChoicePrefs];
+ IntegerPrefMember language_chewing_integer_prefs_[kNumChewingIntegerPrefs];
StringPrefMember language_hangul_keyboard_;
BooleanPrefMember language_pinyin_boolean_prefs_[kNumPinyinBooleanPrefs];
IntegerPrefMember language_pinyin_int_prefs_[kNumPinyinIntegerPrefs];
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 4c64cf5..aa47bc49 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -226,6 +226,12 @@ const wchar_t kLanguageChewingPhraseChoiceRearward[] =
const wchar_t kLanguageChewingSpaceAsSelection[] =
L"settings.language.chewing_space_as_selection";
+// Integer prefs for ibus-chewing Chinese input method.
+const wchar_t kLanguageChewingMaxChiSymbolLen[] =
+ L"settings.language.chewing_max_chi_symbol_len";
+const wchar_t kLanguageChewingCandPerPage[] =
+ L"settings.language.chewing_cand_per_page";
+
// String prefs for ibus-chewing Chinese input method.
const wchar_t kLanguageChewingKeyboardType[] =
L"settings.language.chewing_keyboard_type";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 0be932b..ec33553 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -84,6 +84,8 @@ extern const wchar_t kLanguageChewingForceLowercaseEnglish[];
extern const wchar_t kLanguageChewingPlainZhuyin[];
extern const wchar_t kLanguageChewingPhraseChoiceRearward[];
extern const wchar_t kLanguageChewingSpaceAsSelection[];
+extern const wchar_t kLanguageChewingMaxChiSymbolLen[];
+extern const wchar_t kLanguageChewingCandPerPage[];
extern const wchar_t kLanguageChewingKeyboardType[];
extern const wchar_t kLanguageChewingSelKeys[];
extern const wchar_t kLanguageHangulKeyboard[];