1 /* vim:set et ts=4 sts=4:
3 * ibus-pinyin - The Chinese PinYin engine for IBus
5 * Copyright (c) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "PYPinyinProperties.h"
28 #define _(text) (dgettext (GETTEXT_PACKAGE, text))
30 PinyinProperties::PinyinProperties (Config & config)
32 m_mode_chinese (m_config.initChinese ()),
33 m_mode_full (m_config.initFull ()),
34 m_mode_full_punct (m_config.initFullPunct ()),
35 m_mode_simp (m_config.initSimpChinese ()),
36 m_prop_chinese ("mode.chinese",
40 PKGDATADIR"/icons/chinese.svg" :
41 PKGDATADIR"/icons/english.svg",
42 StaticText (_("Chinese"))),
43 m_prop_full ("mode.full",
45 StaticText (m_mode_full ? "Aa" : "Aa"),
47 PKGDATADIR"/icons/full.svg" :
48 PKGDATADIR"/icons/half.svg",
49 StaticText (_("Full/Half width"))),
50 m_prop_full_punct ("mode.full_punct",
52 StaticText (m_mode_full_punct ? ",。" : ",."),
54 PKGDATADIR"/icons/full-punct.svg" :
55 PKGDATADIR"/icons/half-punct.svg",
56 StaticText (_("Full/Half width punctuation"))),
57 m_prop_simp ( "mode.simp",
59 StaticText (m_mode_simp ? "简" : "繁"),
61 PKGDATADIR"/icons/simp-chinese.svg" :
62 PKGDATADIR"/icons/trad-chinese.svg",
63 StaticText (_("Simplfied/Traditional Chinese"))),
64 m_prop_setup ("setup",
66 StaticText (_("Preferences")),
68 StaticText (_("Preferences")))
70 m_props.append (m_prop_chinese);
71 m_props.append (m_prop_full);
72 m_props.append (m_prop_full_punct);
73 m_props.append (m_prop_simp);
74 m_props.append (m_prop_setup);
79 PinyinProperties::toggleModeChinese (void)
81 m_mode_chinese = ! m_mode_chinese;
82 m_prop_chinese.setLabel (m_mode_chinese ? "CN" : "EN");
83 m_prop_chinese.setIcon (m_mode_chinese ?
84 PKGDATADIR"/icons/chinese.svg" :
85 PKGDATADIR"/icons/english.svg");
86 updateProperty (m_prop_chinese);
88 m_prop_full_punct.setSensitive (m_mode_chinese);
89 updateProperty (m_prop_full_punct);
93 PinyinProperties::toggleModeFull (void)
95 m_mode_full = !m_mode_full;
96 m_prop_full.setLabel (m_mode_full ? "Aa" : "Aa");
97 m_prop_full.setIcon (m_mode_full ?
98 PKGDATADIR"/icons/full.svg" :
99 PKGDATADIR"/icons/half.svg");
100 updateProperty (m_prop_full);
104 PinyinProperties::toggleModeFullPunct (void)
106 m_mode_full_punct = !m_mode_full_punct;
107 m_prop_full_punct.setLabel (m_mode_full_punct ? ",。" : ",.");
108 m_prop_full_punct.setIcon (m_mode_full_punct ?
109 PKGDATADIR"/icons/full-punct.svg" :
110 PKGDATADIR"/icons/half-punct.svg");
111 updateProperty (m_prop_full_punct);
115 PinyinProperties::toggleModeSimp (void)
117 m_mode_simp = ! m_mode_simp;
118 m_prop_simp.setLabel (m_mode_simp ? "简" : "繁");
119 m_prop_simp.setIcon (m_mode_simp ?
120 PKGDATADIR"/icons/simp-chinese.svg" :
121 PKGDATADIR"/icons/trad-chinese.svg");
122 updateProperty (m_prop_simp);
126 PinyinProperties::reset (void)
128 if (modeChinese () != m_config.initChinese ()) {
129 toggleModeChinese ();
131 if (modeFull () != m_config.initFull ()) {
134 if (modeFullPunct () != m_config.initFullPunct ()) {
135 toggleModeFullPunct ();
137 if (modeSimp () != m_config.initSimpChinese ()) {
143 PinyinProperties::propertyActivate (const gchar *prop_name, guint prop_state) {
144 const static std::string mode_chinese ("mode.chinese");
145 const static std::string mode_full ("mode.full");
146 const static std::string mode_full_punct ("mode.full_punct");
147 const static std::string mode_simp ("mode.simp");
149 if (mode_chinese == prop_name) {
150 toggleModeChinese ();
153 else if (mode_full == prop_name) {
157 else if (mode_full_punct == prop_name) {
158 toggleModeFullPunct ();
161 else if (mode_simp == prop_name) {