summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/generated_resources.grd40
-rw-r--r--chrome/browser/chromeos/language_preferences.h48
-rw-r--r--chrome/browser/chromeos/options/language_chewing_config_view.cc42
-rw-r--r--chrome/browser/chromeos/options/language_chewing_config_view.h9
-rw-r--r--chrome/browser/chromeos/options/language_config_util.h28
-rw-r--r--chrome/browser/chromeos/options/language_mozc_config_view.cc13
-rw-r--r--chrome/browser/chromeos/options/language_mozc_config_view.h3
-rw-r--r--chrome/browser/chromeos/options/language_pinyin_config_view.cc33
-rw-r--r--chrome/browser/chromeos/options/language_pinyin_config_view.h17
-rw-r--r--chrome/browser/chromeos/preferences.cc29
-rw-r--r--chrome/browser/chromeos/preferences.h2
-rw-r--r--chrome/common/pref_names.cc3
-rw-r--r--chrome/common/pref_names.h1
13 files changed, 221 insertions, 47 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index d87fbbe..138d931 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -7710,6 +7710,20 @@ Keep your key file in a safe place. You will need it to create new versions of y
desc="The combobox value for the Chewing selection keys">
1234qweras
</message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_CHEWING_HSU_SEL_KEY_TYPE"
+ desc="The combobox description for the Hsu selection key type">
+ Hsu's keyboard selection keys
+ </message>
+ <message translateable="false"
+ name="IDS_OPTIONS_SETTINGS_LANGUAGES_CHEWING_HSU_SEL_KEY_TYPE_1"
+ desc="The combobox value for the Hsu selection key type">
+ asdfjkl789
+ </message>
+ <message translateable="false"
+ name="IDS_OPTIONS_SETTINGS_LANGUAGES_CHEWING_HSU_SEL_KEY_TYPE_2"
+ desc="The combobox value for the Hsu selection key type">
+ asdfzxcv89
+ </message>
<message name="IDS_OPTIONS_SETTINGS_LANGUAGES_HANGUL_SETTINGS_TITLE"
desc="The title for the Hangul input settings dialog">
@@ -7783,6 +7797,32 @@ Keep your key file in a safe place. You will need it to create new versions of y
desc="The checkbox label for a Pinyin input method preference">
Display candidates in Traditional Chinese
</message>
+
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_DOUBLE_SCHEMA"
+ desc="The combobox description for the double Pinyin schema">
+ Double Pinyin schema
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_DOUBLE_SCHEMA_MSPY"
+ desc="The combobox value for the double Pinyin schema (might be non-translateable?)">
+ MSPY
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_DOUBLE_SCHEMA_ZRM"
+ desc="The combobox value for the double Pinyin schema (might be non-translateable?)">
+ ZRM
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_DOUBLE_SCHEMA_ABC"
+ desc="The combobox value for the double Pinyin schema (might be non-translateable?)">
+ ABC
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_DOUBLE_SCHEMA_ZGPY"
+ desc="The combobox value for the double Pinyin schema (might be non-translateable?)">
+ ZGPY
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_DOUBLE_SCHEMA_PYJJ"
+ desc="The combobox value for the double Pinyin schema (might be non-translateable?)">
+ PYJJ
+ </message>
+
<message name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SETTINGS_TITLE"
desc="The title for the Mozc Japanese input settings dialog">
Japanese Input Settings
diff --git a/chrome/browser/chromeos/language_preferences.h b/chrome/browser/chromeos/language_preferences.h
index b4b567d..61f3598 100644
--- a/chrome/browser/chromeos/language_preferences.h
+++ b/chrome/browser/chromeos/language_preferences.h
@@ -12,14 +12,15 @@
// Section and config names for the IBus configuration daemon.
namespace chromeos {
+template <typename DataType>
struct LanguageMultipleChoicePreference {
const wchar_t* pref_name; // Chrome preference name.
- const wchar_t* default_pref_value;
+ DataType default_pref_value;
const char* ibus_config_name;
// Currently we have 10 combobox items at most.
- static const size_t kMaxItems = 10;
+ static const size_t kMaxItems = 11;
struct {
- const char* ibus_config_value;
+ DataType ibus_config_value;
int item_message_id; // Resource grd ID for the combobox item.
} values_and_ids[kMaxItems];
int label_message_id; // Resource grd ID for the label.
@@ -93,9 +94,10 @@ const struct {
};
const size_t kNumChewingIntegerPrefs = ARRAYSIZE_UNSAFE(kChewingIntegerPrefs);
-const LanguageMultipleChoicePreference kChewingMultipleChoicePrefs[] = {
+const LanguageMultipleChoicePreference<const char*>
+ kChewingMultipleChoicePrefs[] = {
{ prefs::kLanguageChewingKeyboardType,
- L"default",
+ "default",
"KBType",
{{ "default",
IDS_OPTIONS_SETTINGS_LANGUAGES_CHEWING_KEYBOARD_TYPE_DEFAULT },
@@ -114,7 +116,7 @@ const LanguageMultipleChoicePreference kChewingMultipleChoicePrefs[] = {
IDS_OPTIONS_SETTINGS_LANGUAGES_CHEWING_KEYBOARD_TYPE,
},
{ prefs::kLanguageChewingSelKeys,
- L"1234567890",
+ "1234567890",
"selKeys",
{{ "1234567890",
IDS_OPTIONS_SETTINGS_LANGUAGES_CHEWING_SEL_KEYS_1234567890 },
@@ -137,7 +139,15 @@ const LanguageMultipleChoicePreference kChewingMultipleChoicePrefs[] = {
};
const size_t kNumChewingMultipleChoicePrefs =
arraysize(kChewingMultipleChoicePrefs);
-// TODO(zork): Support hsuSelKeyType
+
+const LanguageMultipleChoicePreference<int> kChewingHsuSelKeyType = {
+ prefs::kLanguageChewingHsuSelKeyType,
+ 1,
+ "hsuSelKeyType",
+ {{ 1, IDS_OPTIONS_SETTINGS_LANGUAGES_CHEWING_HSU_SEL_KEY_TYPE_1 },
+ { 2, IDS_OPTIONS_SETTINGS_LANGUAGES_CHEWING_HSU_SEL_KEY_TYPE_2 }},
+ IDS_OPTIONS_SETTINGS_LANGUAGES_CHEWING_HSU_SEL_KEY_TYPE,
+};
// For Korean input method (ibus-hangul)
const char kHangulSectionName[] = "engine/Hangul";
@@ -199,13 +209,24 @@ const struct {
const size_t kNumPinyinBooleanPrefs = ARRAYSIZE_UNSAFE(kPinyinBooleanPrefs);
// TODO(yusukes): Support HalfWidthPuncts and IncompletePinyin prefs if needed.
+const LanguageMultipleChoicePreference<int> kPinyinDoublePinyinSchema = {
+ prefs::kLanguagePinyinDoublePinyinSchema,
+ 0,
+ "DoublePinyinSchema",
+ {{ 0, IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_DOUBLE_SCHEMA_MSPY},
+ { 1, IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_DOUBLE_SCHEMA_ZRM},
+ { 2, IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_DOUBLE_SCHEMA_ABC},
+ { 3, IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_DOUBLE_SCHEMA_ZGPY},
+ { 4, IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_DOUBLE_SCHEMA_PYJJ}},
+ IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_DOUBLE_SCHEMA,
+};
+
const struct {
const wchar_t* pref_name; // Chrome preference name.
int default_pref_value;
const char* ibus_config_name;
// TODO(yusukes): Add message_id if needed.
} kPinyinIntegerPrefs[] = {
- { prefs::kLanguagePinyinDoublePinyinSchema, 0, "DoublePinyinSchema" },
// TODO(yusukes): the type of lookup_table_page_size on ibus should be uint.
{ prefs::kLanguagePinyinLookupTablePageSize, 5, "LookupTablePageSize" },
};
@@ -214,16 +235,17 @@ const size_t kNumPinyinIntegerPrefs = ARRAYSIZE_UNSAFE(kPinyinIntegerPrefs);
// For Japanese input method (ibus-mozc)
const char kMozcSectionName[] = "engine/Mozc";
-const LanguageMultipleChoicePreference kMozcMultipleChoicePrefs[] = {
+const LanguageMultipleChoicePreference<const char*>
+ kMozcMultipleChoicePrefs[] = {
{ prefs::kLanguageMozcPreeditMethod,
- L"ROMAN",
+ "ROMAN",
"preedit_method",
{{ "ROMAN", IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PREEDIT_METHOD_ROMAN },
{ "KANA", IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PREEDIT_METHOD_KANA }},
IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PREEDIT_METHOD,
},
{ prefs::kLanguageMozcSessionKeymap,
- L"MSIME",
+ "MSIME",
"session_keymap",
{{ "ATOK", IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SESSION_KEYMAP_ATOK },
{ "MSIME", IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SESSION_KEYMAP_MSIME },
@@ -232,7 +254,7 @@ const LanguageMultipleChoicePreference kMozcMultipleChoicePrefs[] = {
IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SESSION_KEYMAP,
},
{ prefs::kLanguageMozcPunctuationMethod,
- L"KUTEN_TOTEN",
+ "KUTEN_TOTEN",
"punctuation_method",
{{ "KUTEN_TOUTEN",
IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PUNCTUATION_METHOD_KUTEN_TOUTEN },
@@ -245,7 +267,7 @@ const LanguageMultipleChoicePreference kMozcMultipleChoicePrefs[] = {
IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PUNCTUATION_METHOD,
},
{ prefs::kLanguageMozcSymbolMethod,
- L"CORNER_BRACKET_MIDDLE_DOT",
+ "CORNER_BRACKET_MIDDLE_DOT",
"symbol_method",
{{ "CORNER_BRACKET_MIDDLE_DOT",
IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SYMBOL_CORNER_BRACKET_MIDDLE_DOT },
diff --git a/chrome/browser/chromeos/options/language_chewing_config_view.cc b/chrome/browser/chromeos/options/language_chewing_config_view.cc
index 7dc3afc..3a32c7b 100644
--- a/chrome/browser/chromeos/options/language_chewing_config_view.cc
+++ b/chrome/browser/chromeos/options/language_chewing_config_view.cc
@@ -36,9 +36,16 @@ LanguageChewingConfigView::LanguageChewingConfigView(Profile* profile)
current.multiple_choice_pref.Init(
kChewingMultipleChoicePrefs[i].pref_name, profile->GetPrefs(), this);
current.combobox_model =
- new LanguageComboboxModel(&kChewingMultipleChoicePrefs[i]);
+ new LanguageComboboxModel<const char*>(&kChewingMultipleChoicePrefs[i]);
current.combobox = NULL;
}
+
+ hsu_sel_key_type_.multiple_choice_pref.Init(
+ kChewingHsuSelKeyType.pref_name, profile->GetPrefs(), this);
+ hsu_sel_key_type_.combobox_model =
+ new LanguageComboboxModel<int>(&kChewingHsuSelKeyType);
+ hsu_sel_key_type_.combobox = NULL;
+
for (size_t i = 0; i < kNumChewingIntegerPrefs; ++i) {
chewing_integer_prefs_[i].Init(
kChewingIntegerPrefs[i].pref_name, profile->GetPrefs(), this);
@@ -63,13 +70,20 @@ void LanguageChewingConfigView::ItemChanged(
ChewingPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i];
if (current.combobox == sender) {
const std::wstring config_value =
- current.combobox_model->GetConfigValueAt(new_index);
+ UTF8ToWide(current.combobox_model->GetConfigValueAt(new_index));
LOG(INFO) << "Changing Chewing pref to " << config_value;
// Update the Chrome pref.
current.multiple_choice_pref.SetValue(config_value);
break;
}
}
+ if (hsu_sel_key_type_.combobox == sender) {
+ const int config_value =
+ hsu_sel_key_type_.combobox_model->GetConfigValueAt(new_index);
+ LOG(INFO) << "Changing Chewing pref to " << config_value;
+ // Update the Chrome pref.
+ hsu_sel_key_type_.multiple_choice_pref.SetValue(config_value);
+ }
}
void LanguageChewingConfigView::SliderValueChanged(views::Slider* sender) {
@@ -130,6 +144,10 @@ void LanguageChewingConfigView::InitControlLayout() {
current.combobox = new LanguageCombobox(current.combobox_model);
current.combobox->set_listener(this);
}
+ hsu_sel_key_type_.combobox =
+ new LanguageCombobox(hsu_sel_key_type_.combobox_model);
+ hsu_sel_key_type_.combobox->set_listener(this);
+
for (size_t i = 0; i < kNumChewingIntegerPrefs; ++i) {
chewing_integer_sliders_[i] = new views::Slider(
kChewingIntegerPrefs[i].min_pref_value,
@@ -160,6 +178,10 @@ void LanguageChewingConfigView::InitControlLayout() {
layout->AddView(new views::Label(current.combobox_model->GetLabel()));
layout->AddView(current.combobox);
}
+ layout->StartRow(0, kColumnSetId);
+ layout->AddView(
+ new views::Label(hsu_sel_key_type_.combobox_model->GetLabel()));
+ layout->AddView(hsu_sel_key_type_.combobox);
}
void LanguageChewingConfigView::Observe(NotificationType type,
@@ -182,10 +204,18 @@ void LanguageChewingConfigView::NotifyPrefChanged() {
for (size_t i = 0; i < kNumChewingMultipleChoicePrefs; ++i) {
ChewingPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i];
const std::wstring value = current.multiple_choice_pref.GetValue();
- const int combo_index =
- current.combobox_model->GetIndexFromConfigValue(value);
- if (combo_index >= 0) {
- current.combobox->SetSelectedItem(combo_index);
+ for (int i = 0; i < current.combobox_model->num_items(); ++i) {
+ if (UTF8ToWide(current.combobox_model->GetConfigValueAt(i)) == value) {
+ current.combobox->SetSelectedItem(i);
+ break;
+ }
+ }
+ }
+ const int value = hsu_sel_key_type_.multiple_choice_pref.GetValue();
+ for (int i = 0; i < hsu_sel_key_type_.combobox_model->num_items(); ++i) {
+ if (hsu_sel_key_type_.combobox_model->GetConfigValueAt(i) == value) {
+ hsu_sel_key_type_.combobox->SetSelectedItem(i);
+ break;
}
}
}
diff --git a/chrome/browser/chromeos/options/language_chewing_config_view.h b/chrome/browser/chromeos/options/language_chewing_config_view.h
index 82700db..cf12b7a 100644
--- a/chrome/browser/chromeos/options/language_chewing_config_view.h
+++ b/chrome/browser/chromeos/options/language_chewing_config_view.h
@@ -20,6 +20,7 @@
namespace chromeos {
class LanguageCombobox;
+template <typename DataType>
class LanguageComboboxModel;
// A dialog box for showing Traditional Chinese (Chewing) input method
@@ -76,10 +77,16 @@ class LanguageChewingConfigView : public views::ButtonListener,
struct ChewingPrefAndAssociatedCombobox {
StringPrefMember multiple_choice_pref;
- LanguageComboboxModel* combobox_model;
+ LanguageComboboxModel<const char*>* combobox_model;
LanguageCombobox* combobox;
} prefs_and_comboboxes_[kNumChewingMultipleChoicePrefs];
+ struct HsuSelKeyTypePrefAndAssociatedCombobox {
+ IntegerPrefMember multiple_choice_pref;
+ LanguageComboboxModel<int>* combobox_model;
+ LanguageCombobox* combobox;
+ } hsu_sel_key_type_;
+
DISALLOW_COPY_AND_ASSIGN(LanguageChewingConfigView);
};
diff --git a/chrome/browser/chromeos/options/language_config_util.h b/chrome/browser/chromeos/options/language_config_util.h
index 38092a7..455593c 100644
--- a/chrome/browser/chromeos/options/language_config_util.h
+++ b/chrome/browser/chromeos/options/language_config_util.h
@@ -11,15 +11,17 @@
namespace chromeos {
// The combobox model for Language input method prefs.
+template <typename DataType>
class LanguageComboboxModel : public ComboboxModel {
public:
explicit LanguageComboboxModel(
- const LanguageMultipleChoicePreference* pref_data)
+ const LanguageMultipleChoicePreference<DataType>* pref_data)
: pref_data_(pref_data), num_items_(0) {
// Check how many items are defined in the |pref_data->values_and_ids|
// array.
- for (size_t i = 0; i < LanguageMultipleChoicePreference::kMaxItems; ++i) {
- if ((pref_data_->values_and_ids)[i].ibus_config_value == NULL) {
+ for (size_t i = 0;
+ i < LanguageMultipleChoicePreference<DataType>::kMaxItems; ++i) {
+ if ((pref_data_->values_and_ids)[i].item_message_id == 0) {
break;
}
++num_items_;
@@ -50,28 +52,20 @@ class LanguageComboboxModel : public ComboboxModel {
// Gets a config value for the ibus configuration daemon (e.g. "KUTEN_TOUTEN",
// "KUTEN_PERIOD", ..) for an item at zero-origin |index|. This function is
// NOT part of the ComboboxModel interface.
- std::wstring GetConfigValueAt(int index) const {
+ DataType GetConfigValueAt(int index) const {
if (index < 0 || index >= num_items_) {
LOG(ERROR) << "Index is out of bounds: " << index;
- return L"";
+ return (pref_data_->values_and_ids)[0].ibus_config_value;
}
- return UTF8ToWide((pref_data_->values_and_ids)[index].ibus_config_value);
+ return (pref_data_->values_and_ids)[index].ibus_config_value;
}
- // Gets an index (>= 0) of an item such that GetConfigValueAt(index) is equal
- // to the |config_value|. Returns -1 if such item is not found. This function
- // is NOT part of the ComboboxModel interface.
- int GetIndexFromConfigValue(const std::wstring& config_value) const {
- for (int i = 0; i < num_items_; ++i) {
- if (GetConfigValueAt(i) == config_value) {
- return i;
- }
- }
- return -1;
+ int num_items() {
+ return num_items_;
}
private:
- const LanguageMultipleChoicePreference* pref_data_;
+ const LanguageMultipleChoicePreference<DataType>* pref_data_;
int num_items_;
DISALLOW_COPY_AND_ASSIGN(LanguageComboboxModel);
diff --git a/chrome/browser/chromeos/options/language_mozc_config_view.cc b/chrome/browser/chromeos/options/language_mozc_config_view.cc
index 64c7510..ac9b4d4 100644
--- a/chrome/browser/chromeos/options/language_mozc_config_view.cc
+++ b/chrome/browser/chromeos/options/language_mozc_config_view.cc
@@ -28,7 +28,7 @@ LanguageMozcConfigView::LanguageMozcConfigView(Profile* profile)
current.multiple_choice_pref.Init(
kMozcMultipleChoicePrefs[i].pref_name, profile->GetPrefs(), this);
current.combobox_model =
- new LanguageComboboxModel(&kMozcMultipleChoicePrefs[i]);
+ new LanguageComboboxModel<const char*>(&kMozcMultipleChoicePrefs[i]);
current.combobox = NULL;
}
}
@@ -45,7 +45,7 @@ void LanguageMozcConfigView::ItemChanged(
MozcPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i];
if (current.combobox == sender) {
const std::wstring config_value =
- current.combobox_model->GetConfigValueAt(new_index);
+ UTF8ToWide(current.combobox_model->GetConfigValueAt(new_index));
LOG(INFO) << "Changing Mozc pref to " << config_value;
// Update the Chrome pref.
current.multiple_choice_pref.SetValue(config_value);
@@ -121,10 +121,11 @@ void LanguageMozcConfigView::NotifyPrefChanged() {
for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) {
MozcPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i];
const std::wstring value = current.multiple_choice_pref.GetValue();
- const int combo_index =
- current.combobox_model->GetIndexFromConfigValue(value);
- if (combo_index >= 0) {
- current.combobox->SetSelectedItem(combo_index);
+ for (int i = 0; i < current.combobox_model->num_items(); ++i) {
+ if (UTF8ToWide(current.combobox_model->GetConfigValueAt(i)) == value) {
+ current.combobox->SetSelectedItem(i);
+ break;
+ }
}
}
}
diff --git a/chrome/browser/chromeos/options/language_mozc_config_view.h b/chrome/browser/chromeos/options/language_mozc_config_view.h
index 6bf89fd..94df39c 100644
--- a/chrome/browser/chromeos/options/language_mozc_config_view.h
+++ b/chrome/browser/chromeos/options/language_mozc_config_view.h
@@ -19,6 +19,7 @@
namespace chromeos {
class LanguageCombobox;
+template <typename DataType>
class LanguageComboboxModel;
// A dialog box for showing Mozc (Japanese input method) preferences.
@@ -59,7 +60,7 @@ class LanguageMozcConfigView : public views::Combobox::Listener,
struct MozcPrefAndAssociatedCombobox {
StringPrefMember multiple_choice_pref;
- LanguageComboboxModel* combobox_model;
+ LanguageComboboxModel<const char*>* combobox_model;
LanguageCombobox* combobox;
} prefs_and_comboboxes_[kNumMozcMultipleChoicePrefs];
diff --git a/chrome/browser/chromeos/options/language_pinyin_config_view.cc b/chrome/browser/chromeos/options/language_pinyin_config_view.cc
index f14e2bb..9cd4b58 100644
--- a/chrome/browser/chromeos/options/language_pinyin_config_view.cc
+++ b/chrome/browser/chromeos/options/language_pinyin_config_view.cc
@@ -11,6 +11,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/language_library.h"
+#include "chrome/browser/chromeos/options/language_config_util.h"
#include "chrome/browser/chromeos/preferences.h"
#include "chrome/browser/profile.h"
#include "grit/generated_resources.h"
@@ -30,6 +31,12 @@ LanguagePinyinConfigView::LanguagePinyinConfigView(Profile* profile)
kPinyinBooleanPrefs[i].pref_name, profile->GetPrefs(), this);
pinyin_boolean_checkboxes_[i] = NULL;
}
+
+ double_pinyin_schema_.multiple_choice_pref.Init(
+ kPinyinDoublePinyinSchema.pref_name, profile->GetPrefs(), this);
+ double_pinyin_schema_.combobox_model =
+ new LanguageComboboxModel<int>(&kPinyinDoublePinyinSchema);
+ double_pinyin_schema_.combobox = NULL;
}
LanguagePinyinConfigView::~LanguagePinyinConfigView() {
@@ -43,6 +50,17 @@ void LanguagePinyinConfigView::ButtonPressed(
pinyin_boolean_prefs_[pref_id].SetValue(checkbox->checked());
}
+void LanguagePinyinConfigView::ItemChanged(
+ views::Combobox* sender, int prev_index, int new_index) {
+ if (double_pinyin_schema_.combobox == sender) {
+ const int config_value =
+ double_pinyin_schema_.combobox_model->GetConfigValueAt(new_index);
+ LOG(INFO) << "Changing Pinyin pref to " << config_value;
+ // Update the Chrome pref.
+ double_pinyin_schema_.multiple_choice_pref.SetValue(config_value);
+ }
+}
+
void LanguagePinyinConfigView::Layout() {
// Not sure why but this is needed to show contents in the dialog.
contents_->SetBounds(0, 0, width(), height());
@@ -86,11 +104,19 @@ void LanguagePinyinConfigView::InitControlLayout() {
pinyin_boolean_checkboxes_[i]->set_listener(this);
pinyin_boolean_checkboxes_[i]->set_tag(i);
}
+ double_pinyin_schema_.combobox =
+ new LanguageCombobox(double_pinyin_schema_.combobox_model);
+ double_pinyin_schema_.combobox->set_listener(this);
+
NotifyPrefChanged();
for (size_t i = 0; i < kNumPinyinBooleanPrefs; ++i) {
layout->StartRow(0, kColumnSetId);
layout->AddView(pinyin_boolean_checkboxes_[i]);
}
+ layout->StartRow(0, kColumnSetId);
+ layout->AddView(
+ new views::Label(double_pinyin_schema_.combobox_model->GetLabel()));
+ layout->AddView(double_pinyin_schema_.combobox);
}
void LanguagePinyinConfigView::Observe(NotificationType type,
@@ -106,6 +132,13 @@ void LanguagePinyinConfigView::NotifyPrefChanged() {
const bool checked = pinyin_boolean_prefs_[i].GetValue();
pinyin_boolean_checkboxes_[i]->SetChecked(checked);
}
+ const int value = double_pinyin_schema_.multiple_choice_pref.GetValue();
+ for (int i = 0; i < double_pinyin_schema_.combobox_model->num_items(); ++i) {
+ if (double_pinyin_schema_.combobox_model->GetConfigValueAt(i) == value) {
+ double_pinyin_schema_.combobox->SetSelectedItem(i);
+ break;
+ }
+ }
}
} // namespace chromeos
diff --git a/chrome/browser/chromeos/options/language_pinyin_config_view.h b/chrome/browser/chromeos/options/language_pinyin_config_view.h
index 76e0cd9..18f4414 100644
--- a/chrome/browser/chromeos/options/language_pinyin_config_view.h
+++ b/chrome/browser/chromeos/options/language_pinyin_config_view.h
@@ -12,14 +12,20 @@
#include "chrome/browser/pref_member.h"
#include "chrome/browser/views/options/options_page_view.h"
#include "views/controls/button/checkbox.h"
+#include "views/controls/combobox/combobox.h"
#include "views/controls/label.h"
#include "views/window/dialog_delegate.h"
namespace chromeos {
+class LanguageCombobox;
+template <typename DataType>
+class LanguageComboboxModel;
+
// A dialog box for showing Traditional Chinese (Pinyin) input method
// preferences.
class LanguagePinyinConfigView : public views::ButtonListener,
+ public views::Combobox::Listener,
public views::DialogDelegate,
public OptionsPageView {
public:
@@ -29,6 +35,11 @@ class LanguagePinyinConfigView : public views::ButtonListener,
// views::ButtonListener overrides.
virtual void ButtonPressed(views::Button* sender, const views::Event& event);
+ // views::Combobox::Listener overrides.
+ virtual void ItemChanged(views::Combobox* sender,
+ int prev_index,
+ int new_index);
+
// views::DialogDelegate overrides.
virtual bool IsModal() const { return true; }
virtual views::View* GetContentsView() { return this; }
@@ -57,6 +68,12 @@ class LanguagePinyinConfigView : public views::ButtonListener,
// A checkboxes for Pinyin.
views::Checkbox* pinyin_boolean_checkboxes_[kNumPinyinBooleanPrefs];
+ struct DoublePinyinSchemaPrefAndAssociatedCombobox {
+ IntegerPrefMember multiple_choice_pref;
+ LanguageComboboxModel<int>* combobox_model;
+ LanguageCombobox* combobox;
+ } double_pinyin_schema_;
+
DISALLOW_COPY_AND_ASSIGN(LanguagePinyinConfigView);
};
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index 7314803..702aa4b 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -38,8 +38,11 @@ void Preferences::RegisterUserPrefs(PrefService* prefs) {
for (size_t i = 0; i < kNumChewingMultipleChoicePrefs; ++i) {
prefs->RegisterStringPref(
kChewingMultipleChoicePrefs[i].pref_name,
- kChewingMultipleChoicePrefs[i].default_pref_value);
+ UTF8ToWide(kChewingMultipleChoicePrefs[i].default_pref_value));
}
+ prefs->RegisterIntegerPref(kChewingHsuSelKeyType.pref_name,
+ kChewingHsuSelKeyType.default_pref_value);
+
for (size_t i = 0; i < kNumChewingIntegerPrefs; ++i) {
prefs->RegisterIntegerPref(kChewingIntegerPrefs[i].pref_name,
kChewingIntegerPrefs[i].default_pref_value);
@@ -54,9 +57,13 @@ void Preferences::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterIntegerPref(kPinyinIntegerPrefs[i].pref_name,
kPinyinIntegerPrefs[i].default_pref_value);
}
+ prefs->RegisterIntegerPref(kPinyinDoublePinyinSchema.pref_name,
+ kPinyinDoublePinyinSchema.default_pref_value);
+
for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) {
- prefs->RegisterStringPref(kMozcMultipleChoicePrefs[i].pref_name,
- kMozcMultipleChoicePrefs[i].default_pref_value);
+ prefs->RegisterStringPref(
+ kMozcMultipleChoicePrefs[i].pref_name,
+ UTF8ToWide(kMozcMultipleChoicePrefs[i].default_pref_value));
}
}
@@ -80,6 +87,8 @@ void Preferences::Init(PrefService* prefs) {
language_chewing_multiple_choice_prefs_[i].Init(
kChewingMultipleChoicePrefs[i].pref_name, prefs, this);
}
+ language_chewing_hsu_sel_key_type_.Init(
+ kChewingHsuSelKeyType.pref_name, prefs, this);
for (size_t i = 0; i < kNumChewingIntegerPrefs; ++i) {
language_chewing_integer_prefs_[i].Init(
kChewingIntegerPrefs[i].pref_name, prefs, this);
@@ -93,6 +102,8 @@ void Preferences::Init(PrefService* prefs) {
language_pinyin_int_prefs_[i].Init(
kPinyinIntegerPrefs[i].pref_name, prefs, this);
}
+ language_pinyin_double_pinyin_schema_.Init(
+ kPinyinDoublePinyinSchema.pref_name, prefs, this);
for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) {
language_mozc_multiple_choice_prefs_[i].Init(
kMozcMultipleChoicePrefs[i].pref_name, prefs, this);
@@ -162,6 +173,12 @@ void Preferences::NotifyPrefChanged(const std::wstring* pref_name) {
language_chewing_multiple_choice_prefs_[i].GetValue());
}
}
+ if (!pref_name || *pref_name == kChewingHsuSelKeyType.pref_name) {
+ SetLanguageConfigInteger(
+ kChewingSectionName,
+ kChewingHsuSelKeyType.ibus_config_name,
+ language_chewing_hsu_sel_key_type_.GetValue());
+ }
for (size_t i = 0; i < kNumChewingIntegerPrefs; ++i) {
if (!pref_name || *pref_name == kChewingIntegerPrefs[i].pref_name) {
SetLanguageConfigInteger(kChewingSectionName,
@@ -187,6 +204,12 @@ void Preferences::NotifyPrefChanged(const std::wstring* pref_name) {
language_pinyin_int_prefs_[i].GetValue());
}
}
+ if (!pref_name || *pref_name == kPinyinDoublePinyinSchema.pref_name) {
+ SetLanguageConfigInteger(
+ kPinyinSectionName,
+ kPinyinDoublePinyinSchema.ibus_config_name,
+ language_pinyin_double_pinyin_schema_.GetValue());
+ }
for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) {
if (!pref_name || *pref_name == kMozcMultipleChoicePrefs[i].pref_name) {
SetLanguageConfigString(
diff --git a/chrome/browser/chromeos/preferences.h b/chrome/browser/chromeos/preferences.h
index e540348..90ade43 100644
--- a/chrome/browser/chromeos/preferences.h
+++ b/chrome/browser/chromeos/preferences.h
@@ -90,10 +90,12 @@ class Preferences : public NotificationObserver {
BooleanPrefMember language_chewing_boolean_prefs_[kNumChewingBooleanPrefs];
StringPrefMember language_chewing_multiple_choice_prefs_[
kNumChewingMultipleChoicePrefs];
+ IntegerPrefMember language_chewing_hsu_sel_key_type_;
IntegerPrefMember language_chewing_integer_prefs_[kNumChewingIntegerPrefs];
StringPrefMember language_hangul_keyboard_;
BooleanPrefMember language_pinyin_boolean_prefs_[kNumPinyinBooleanPrefs];
IntegerPrefMember language_pinyin_int_prefs_[kNumPinyinIntegerPrefs];
+ IntegerPrefMember language_pinyin_double_pinyin_schema_;
StringPrefMember language_mozc_multiple_choice_prefs_[
kNumMozcMultipleChoicePrefs];
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index d0fd292..1b784ed 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -238,6 +238,9 @@ const wchar_t kLanguageChewingKeyboardType[] =
const wchar_t kLanguageChewingSelKeys[] =
L"settings.language.chewing_sel_keys";
+const wchar_t kLanguageChewingHsuSelKeyType[] =
+ L"settings.language.chewing_hsu_sel_key_type";
+
// A string pref which determines the keyboard layout for Hangul input method.
const wchar_t kLanguageHangulKeyboard[] = L"settings.language.hangul_keyboard";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 084ab3f..cd306c7 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -88,6 +88,7 @@ extern const wchar_t kLanguageChewingMaxChiSymbolLen[];
extern const wchar_t kLanguageChewingCandPerPage[];
extern const wchar_t kLanguageChewingKeyboardType[];
extern const wchar_t kLanguageChewingSelKeys[];
+extern const wchar_t kLanguageChewingHsuSelKeyType[];
extern const wchar_t kLanguageHangulKeyboard[];
extern const wchar_t kLanguagePinyinCorrectPinyin[];
extern const wchar_t kLanguagePinyinFuzzyPinyin[];