2 # -*- coding: utf-8 -*-
4 # Project: J-Ben, Python front-end
5 # File: tab_prefskanjidict.py
7 # Created on: 28 Nov 2008
10 from preferences
import options
13 class TabPrefsKanjiDict(gtk
.VBox
):
15 gtk
.VBox
.__init
__(self
)
17 self
.chkReadings
= gtk
.CheckButton(
18 _("Include on-yomi, kun-yomi and nanori (name) readings"))
19 self
.chkMeanings
= gtk
.CheckButton(
20 _("Include English meanings"))
21 self
.chkHighImp
= gtk
.CheckButton(
22 _("Include stroke count, Jouyou grade and newspaper "
24 self
.chkMultiRad
= gtk
.CheckButton(
25 _("Include radical component list"))
26 self
.chkDict
= gtk
.CheckButton(
27 _("Include dictionary reference codes"))
28 self
.chkVocabCrossRef
= gtk
.CheckButton(
29 _("Show vocab from your study list which use the kanji"))
30 self
.chkLowImp
= gtk
.CheckButton(
31 _("Other information "
32 "(Radical #'s, Korean and Pinyin romanization)"))
33 self
.chkSodStatic
= gtk
.CheckButton(
34 _("Use stroke order diagrams if present"))
35 self
.chkSodAnim
= gtk
.CheckButton(
36 _("Use animated stroke order diagrams if present (tests only)"))
38 # I use the same names used in KANJIDIC2 for the various dictionary
40 self
.dict_buttons
= []
41 self
.dict_buttons
.append(
42 ("kdict.render.dcode.halpern_njecd",
44 _('"New Japanese-English Character Dictionary" '
45 'by Jack Halpern.'))))
46 self
.dict_buttons
.append(
47 ("kdict.render.dcode.nelson_c",
49 _('"Modern Reader\'s Japanese-English Character Dictionary" '
50 'by Andrew Nelson'))))
51 self
.dict_buttons
.append(
52 ("kdict.render.dcode.nelson_n",
54 _('"The New Nelson Japanese-English Character Dictionary" '
56 self
.dict_buttons
.append(
57 ("kdict.render.dcode.busy_people",
59 _('"Japanese for Busy People" by AJLT'))))
60 self
.dict_buttons
.append(
61 ("kdict.render.dcode.crowley",
63 _('"The Kanji Way to Japanese Language Power" '
65 self
.dict_buttons
.append(
66 ("kdict.render.dcode.kodansha_compact",
68 _('"Kodansha Compact Kanji Guide"'))))
69 self
.dict_buttons
.append(
70 ("kdict.render.dcode.henshall3",
72 _('"A Guide To Reading and Writing Japanese" '
73 'by Ken Henshall et al.'))))
74 self
.dict_buttons
.append(
75 ("kdict.render.dcode.kanji_in_context",
77 _('"Kanji in Context" by Nishiguchi and Kono'))))
78 self
.dict_buttons
.append(
79 ("kdict.render.dcode.halpern_kkld",
81 _('"Kanji Learner\'s Dictionary" by Jack Halpern'))))
82 self
.dict_buttons
.append(
83 ("kdict.render.dcode.oneill_kk",
85 _('"Essential Kanji" by P.G. O\'Neill'))))
86 self
.dict_buttons
.append(
87 ("kdict.render.qcode.deroo",
89 _('"2001 Kanji" by Father Joseph De Roo'))))
90 self
.dict_buttons
.append(
91 ("kdict.render.dcode.sakade",
93 _('"A Guide To Reading and Writing Japanese" '
94 'by Florence Sakade'))))
95 self
.dict_buttons
.append(
96 ("kdict.render.dcode.tutt_cards",
98 _('"Tuttle Kanji Cards" by Alexander Kask'))))
99 self
.dict_buttons
.append(
100 ("kdict.render.dcode.jf_cards",
102 _('"Japanese Kanji Flashcards" by Hodges and Okazaki'))))
103 self
.dict_buttons
.append(
104 ("kdict.render.qcode.skip",
106 _('SKIP codes used by Halpern dictionaries'))))
107 self
.dict_buttons
.append(
108 ("kdict.render.qcode.sh_desc",
110 _('"Kanji Dictionary" by Spahn & Hadamitzky'))))
111 self
.dict_buttons
.append(
112 ("kdict.render.dcode.sh_kk",
114 _('"Kanji & Kana" by Spahn & Hadamitzky'))))
115 self
.dict_buttons
.append(
116 ("kdict.render.qcode.four_corner",
118 _('Four Corner code (various dictionaries)'))))
119 self
.dict_buttons
.append(
120 ("kdict.render.dcode.moro",
122 _('"Morohashi Daikanwajiten"'))))
123 self
.dict_buttons
.append(
124 ("kdict.render.dcode.henshall",
126 _('"A Guide to Remembering Japanese Characters" '
127 'by Kenneth G. Henshall'))))
128 self
.dict_buttons
.append(
129 ("kdict.render.dcode.gakken",
131 _('Gakken Kanji Dictionary '
132 '("A New Dictionary of Kanji Usage")'))))
133 self
.dict_buttons
.append(
134 ("kdict.render.dcode.heisig",
136 _('"Remembering The Kanji" by James Heisig'))))
137 self
.dict_buttons
.append(
138 ("kdict.render.dcode.oneill_names",
140 _('"Japanese Names" by P.G. O\'Neill'))))
141 self
.dict_buttons
.append(
142 ("kdict.render.dcode.maniette",
144 _("Codes from Yves Maniette's French version of Heisig"))))
146 main_opts
= gtk
.VBox()
147 dicts_outer
= gtk
.VBox()
148 other_opts
= gtk
.VBox()
150 main_opts
.pack_start(self
.chkReadings
, expand
= False)
151 main_opts
.pack_start(self
.chkMeanings
, expand
= False)
152 main_opts
.pack_start(self
.chkHighImp
, expand
= False)
153 main_opts
.pack_start(self
.chkMultiRad
, expand
= False)
155 self
.dicts_inner
= gtk
.VBox()
156 for key
, obj
in self
.dict_buttons
:
157 self
.dicts_inner
.pack_start(obj
, expand
= False)
158 self
.dicts_inner
.set_sensitive(False)
160 dicts_scrollwindow
= gtk
.ScrolledWindow()
161 dicts_scrollwindow
.set_policy(gtk
.POLICY_AUTOMATIC
,
162 gtk
.POLICY_AUTOMATIC
)
163 # GTKmm ScrolledWindow worked with just an add;
164 # pyGTK required add_with_viewport... why the diff?
165 dicts_scrollwindow
.add_with_viewport(self
.dicts_inner
)
167 dicts_outer
.pack_start(self
.chkDict
, expand
= False)
168 dicts_outer
.pack_start(dicts_scrollwindow
)
170 other_opts
.pack_start(self
.chkVocabCrossRef
, expand
= False)
171 other_opts
.pack_start(self
.chkLowImp
, expand
= False)
172 other_opts
.pack_start(self
.chkSodStatic
, expand
= False)
173 other_opts
.pack_start(self
.chkSodAnim
, expand
= False)
175 self
.pack_start(main_opts
, expand
= False)
176 self
.pack_start(dicts_outer
)
177 self
.pack_start(other_opts
, expand
= False)
179 self
.chkDict
.connect("toggled", self
.on_dictionary_toggle
)
183 def on_dictionary_toggle(self
, widget
):
184 self
.dicts_inner
.set_sensitive(widget
.get_active())
186 def update_gui(self
):
187 # This function -does- fudge things a little, but the average user
189 self
.chkReadings
.set_active(
190 options
.get("kdict.render.kunyomi", False))
191 self
.chkMeanings
.set_active(
192 options
.get("kdict.render.meaning", False))
193 self
.chkHighImp
.set_active(
194 options
.get("kdict.render.stroke_count", False))
195 self
.chkMultiRad
.set_active(
196 options
.get("kdict.render.radical_list", False))
197 self
.chkDict
.set_active(
198 options
.get("kdict.render.dictionaries", False))
199 self
.chkVocabCrossRef
.set_active(
200 options
.get("kdict.render.vocab_cross_ref", False))
201 self
.chkLowImp
.set_active(
202 options
.get("kdict.render.cross_ref", False))
203 self
.chkSodStatic
.set_active(
204 options
.get("kdict.render.kanjicafe_sodas", False))
205 self
.chkSodAnim
.set_active(
206 options
.get("kdict.render.kanjicafe_sods", False))
209 for key
, obj
in self
.dict_buttons
:
210 obj
.set_active(options
.get(key
, False))
212 def update_prefs(self
):
213 b
= self
.chkReadings
.get_active()
214 options
["kdict.render.kunyomi"] = b
215 options
["kdict.render.onyomi"] = b
216 options
["kdict.render.nanori"] = b
217 b
= self
.chkMeanings
.get_active()
218 options
["kdict.render.meaning"] = b
219 b
= self
.chkHighImp
.get_active()
220 options
["kdict.render.stroke_count"] = b
221 options
["kdict.render.jlpt_level"] = b
222 options
["kdict.render.jouyou_grade"] = b
223 options
["kdict.render.frequency"] = b
224 b
= self
.chkMultiRad
.get_active()
225 options
["kdict.render.radical_list"] = b
226 b
= self
.chkDict
.get_active()
227 options
["kdict.render.dictionaries"] = b
228 b
= self
.chkVocabCrossRef
.get_active()
229 options
["kdict.render.vocab_cross_ref"] = b
230 b
= self
.chkLowImp
.get_active()
231 options
["kdict.render.cross_ref"] = b
232 options
["kdict.render.jis-208"] = b
233 options
["kdict.render.jis-212"] = b
234 options
["kdict.render.jis-213"] = b
235 options
["kdict.render.nelson_radical"] = b
236 options
["kdict.render.kangxi_radical"] = b
237 options
["kdict.render.korean"] = b
238 options
["kdict.render.korean_roman"] = b
239 options
["kdict.render.pinyin_roman"] = b
240 options
["kdict.render.radical_name"] = b
241 options
["kdict.render.unicode"] = b
242 b
= self
.chkSodStatic
.get_active()
243 options
["kdict.render.kanjicafe_sodas"] = b
244 b
= self
.chkSodAnim
.get_active()
245 options
["kdict.render.kanjicafe_sods"] = b
248 for key
, obj
in self
.dict_buttons
:
249 options
[key
] = obj
.get_active()