summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--data/com.github.libpinyin.ibus-libpinyin.gschema.xml8
-rw-r--r--setup/shortcuteditor.py1
-rw-r--r--src/PYConfig.cc1
-rw-r--r--src/PYConfig.h2
-rw-r--r--src/PYPBopomofoEngine.cc18
-rw-r--r--src/PYPConfig.cc5
-rw-r--r--src/PYPPinyinEngine.cc18
7 files changed, 49 insertions, 4 deletions
diff --git a/data/com.github.libpinyin.ibus-libpinyin.gschema.xml b/data/com.github.libpinyin.ibus-libpinyin.gschema.xml
index 1f415ea..6f73352 100644
--- a/data/com.github.libpinyin.ibus-libpinyin.gschema.xml
+++ b/data/com.github.libpinyin.ibus-libpinyin.gschema.xml
@@ -137,6 +137,10 @@
<default>'&lt;Control&gt;period'</default>
<summary>Shortcut for Full/Half Punctuation</summary>
</key>
+ <key name="both-switch" type="s">
+ <default>''</default>
+ <summary>Shortcut for Full/Half Both Switch</summary>
+ </key>
<key name="trad-switch" type="s">
<default>'&lt;Control&gt;&lt;Shift&gt;f'</default>
<summary>Shortcut for Simplified/Traditional Chinese Mode</summary>
@@ -299,6 +303,10 @@
<default>'&lt;Control&gt;period'</default>
<summary>Shortcut for Full/Half Punctuation</summary>
</key>
+ <key name="both-switch" type="s">
+ <default>''</default>
+ <summary>Shortcut for Full/Half Both Switch</summary>
+ </key>
<key name="trad-switch" type="s">
<default>'&lt;Control&gt;&lt;Shift&gt;f'</default>
<summary>Shortcut for Simplified/Traditional Chinese Mode</summary>
diff --git a/setup/shortcuteditor.py b/setup/shortcuteditor.py
index a1b61af..a40b84e 100644
--- a/setup/shortcuteditor.py
+++ b/setup/shortcuteditor.py
@@ -46,6 +46,7 @@ accelerators = \
(_("Switch Chinese/English"), "main-switch" , "<Shift>"),
(_("Full/Half Width Letter"), "letter-switch", ""),
(_("Full/Half Width Punct"), "punct-switch", "<Control>period"),
+ (_("Full/Half Width Both Switch"), "both-switch", ""),
(_("Switch Traditional/Simplfied Chinese"), "trad-switch", "<Control><Shift>f")
)
diff --git a/src/PYConfig.cc b/src/PYConfig.cc
index 6d3457a..59ac95d 100644
--- a/src/PYConfig.cc
+++ b/src/PYConfig.cc
@@ -67,6 +67,7 @@ Config::initDefaultValues (void)
m_main_switch = "<Shift>";
m_letter_switch = "";
m_punct_switch = "<Control>period";
+ m_both_switch = "";
m_trad_switch = "<Control><Shift>f";
}
diff --git a/src/PYConfig.h b/src/PYConfig.h
index 9a706ee..4085685 100644
--- a/src/PYConfig.h
+++ b/src/PYConfig.h
@@ -69,6 +69,7 @@ public:
std::string mainSwitch (void) const { return m_main_switch; }
std::string letterSwitch (void) const { return m_letter_switch; }
std::string punctSwitch (void) const { return m_punct_switch; }
+ std::string bothSwitch (void) const { return m_both_switch; }
std::string tradSwitch (void) const { return m_trad_switch; }
std::string openccConfig (void) const { return m_opencc_config; }
@@ -127,6 +128,7 @@ protected:
std::string m_main_switch;
std::string m_letter_switch;
std::string m_punct_switch;
+ std::string m_both_switch;
std::string m_trad_switch;
};
diff --git a/src/PYPBopomofoEngine.cc b/src/PYPBopomofoEngine.cc
index 3621f1b..9838130 100644
--- a/src/PYPBopomofoEngine.cc
+++ b/src/PYPBopomofoEngine.cc
@@ -112,14 +112,28 @@ BopomofoEngine::processAccelKeyEvent (guint keyval, guint keycode,
}
/* Toggle full/half Letter Mode */
- if (BopomofoConfig::instance (). letterSwitch () == accel) {
+ if (BopomofoConfig::instance ().letterSwitch () == accel) {
m_props.toggleModeFull ();
m_prev_pressed_key = keyval;
return TRUE;
}
/* Toggle full/half Punct Mode */
- if (BopomofoConfig::instance (). punctSwitch () == accel) {
+ if (BopomofoConfig::instance ().punctSwitch () == accel) {
+ m_props.toggleModeFullPunct ();
+ m_prev_pressed_key = keyval;
+ return TRUE;
+ }
+
+ /* Toggle both full/half Mode */
+ if (BopomofoConfig::instance ().bothSwitch () == accel) {
+ if (m_props.modeFull () != m_props.modeFullPunct ()) {
+ m_props.toggleModeFull ();
+ m_prev_pressed_key = keyval;
+ return TRUE;
+ }
+
+ m_props.toggleModeFull ();
m_props.toggleModeFullPunct ();
m_prev_pressed_key = keyval;
return TRUE;
diff --git a/src/PYPConfig.cc b/src/PYPConfig.cc
index 0f9700f..12d90c4 100644
--- a/src/PYPConfig.cc
+++ b/src/PYPConfig.cc
@@ -63,6 +63,7 @@ const gchar * const CONFIG_CLEAR_USER_DATA = "clear-user-data";
const gchar * const CONFIG_MAIN_SWITCH = "main-switch";
const gchar * const CONFIG_LETTER_SWITCH = "letter-switch";
const gchar * const CONFIG_PUNCT_SWITCH = "punct-switch";
+const gchar * const CONFIG_BOTH_SWITCH = "both-switch";
const gchar * const CONFIG_TRAD_SWITCH = "trad-switch";
const pinyin_option_t PINYIN_DEFAULT_OPTION =
@@ -126,6 +127,7 @@ LibPinyinConfig::initDefaultValues (void)
m_main_switch = "<Shift>";
m_letter_switch = "";
m_punct_switch = "<Control>period";
+ m_both_switch = "";
m_trad_switch = "<Control><Shift>f";
}
@@ -219,6 +221,7 @@ LibPinyinConfig::readDefaultValues (void)
m_main_switch = read (CONFIG_MAIN_SWITCH, "<Shift>");
m_letter_switch = read (CONFIG_LETTER_SWITCH, "");
m_punct_switch = read (CONFIG_PUNCT_SWITCH, "<Control>period");
+ m_both_switch = read (CONFIG_BOTH_SWITCH, "");
m_trad_switch = read (CONFIG_TRAD_SWITCH, "<Control><Shift>f");
/* fuzzy pinyin */
@@ -289,6 +292,8 @@ LibPinyinConfig::valueChanged (const std::string &schema_id,
m_letter_switch = normalizeGVariant (value, std::string (""));
} else if (CONFIG_PUNCT_SWITCH == name) {
m_punct_switch = normalizeGVariant (value, std::string ("<Control>period"));
+ } else if (CONFIG_BOTH_SWITCH == name) {
+ m_both_switch = normalizeGVariant (value, std::string (""));
} else if (CONFIG_TRAD_SWITCH == name) {
m_trad_switch = normalizeGVariant (value, std::string ("<Control><Shift>f"));
}
diff --git a/src/PYPPinyinEngine.cc b/src/PYPPinyinEngine.cc
index efb518e..8c241d5 100644
--- a/src/PYPPinyinEngine.cc
+++ b/src/PYPPinyinEngine.cc
@@ -197,14 +197,28 @@ PinyinEngine::processAccelKeyEvent (guint keyval, guint keycode,
}
/* Toggle full/half Letter Mode */
- if (PinyinConfig::instance (). letterSwitch () == accel) {
+ if (PinyinConfig::instance ().letterSwitch () == accel) {
m_props.toggleModeFull ();
m_prev_pressed_key = keyval;
return TRUE;
}
/* Toggle full/half Punct Mode */
- if (PinyinConfig::instance (). punctSwitch () == accel) {
+ if (PinyinConfig::instance ().punctSwitch () == accel) {
+ m_props.toggleModeFullPunct ();
+ m_prev_pressed_key = keyval;
+ return TRUE;
+ }
+
+ /* Toggle both full/half Mode */
+ if (PinyinConfig::instance ().bothSwitch () == accel) {
+ if (m_props.modeFull () != m_props.modeFullPunct ()) {
+ m_props.toggleModeFull ();
+ m_prev_pressed_key = keyval;
+ return TRUE;
+ }
+
+ m_props.toggleModeFull ();
m_props.toggleModeFullPunct ();
m_prev_pressed_key = keyval;
return TRUE;