Reorg of source more-or-less done. Also replaced singletons with global references.
[jben2_gui.git] / jben / jben / gui / dict_manager.py
blob0c383d21b37ae504dfc66b8d830f692ed2e27ea8
1 x#!/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 # Project: J-Ben, Python front-end
5 # File: dict_manager.py
6 # Author: Paul Goins
7 # Created on: 1 Nov 2009
9 from __future__ import absolute_import
11 import gtk
12 from jben import global_refs
15 """
16 Layout:
18 """
21 class TabPrefsKanjiDict(gtk.VBox):
22 def __init__(self):
23 gtk.VBox.__init__(self)
25 self.chkEdict = gtk.CheckButton(
26 _("EDICT (recommended)"))
27 #self.chkEdict2 = gtk.CheckButton(
28 # _("EDICT2"))
29 self.chkJMdict = gtk.CheckButton(
30 _("JMdict (slow, multilingual)"))
31 self.chkJMdict_e = gtk.CheckButton(
32 _("JMdict_e (English/Japanese only)"))
33 self.chkKanjidic = gtk.CheckButton(
34 _("KANJIDIC (recommended)"))
35 self.chkKanjd212 = gtk.CheckButton(
36 _("KANJID212"))
37 self.chkKanjidic2 = gtk.CheckButton(
38 _("KANJIDIC2 (slow)"))
40 self.pack_start(self.chkEdict, expand=False)
41 self.pack_start(self.chkEdict, expand=False)
42 self.pack_start(self.chkEdict, expand=False)
43 self.pack_start(self.chkEdict, expand=False)
44 self.pack_start(self.chkEdict, expand=False)
45 self.pack_start(self.chkEdict, expand=False)
46 self.pack_start(self.chkEdict, expand=False)
48 self.update_gui()
50 def update_gui(self):
51 # This function -does- fudge things a little, but the average user
52 # should not notice.
53 prefs = global_refs.prefs
54 self.chkReadings.set_active(
55 prefs.get("kdict.render.kunyomi", False))
56 self.chkMeanings.set_active(
57 prefs.get("kdict.render.meaning", False))
58 self.chkHighImp.set_active(
59 prefs.get("kdict.render.stroke_count", False))
60 self.chkMultiRad.set_active(
61 prefs.get("kdict.render.radical_list", False))
62 self.chkDict.set_active(
63 prefs.get("kdict.render.dictionaries", False))
64 self.chkVocabCrossRef.set_active(
65 prefs.get("kdict.render.vocab_cross_ref", False))
66 self.chkLowImp.set_active(
67 prefs.get("kdict.render.cross_ref", False))
68 self.chkSodStatic.set_active(
69 prefs.get("kdict.render.kanjicafe_sodas", False))
70 self.chkSodAnim.set_active(
71 prefs.get("kdict.render.kanjicafe_sods", False))
73 # Dicts
74 for key, obj in self.dict_buttons:
75 obj.set_active(prefs.get(key, False))
77 def update_prefs(self):
78 prefs = global_refs.prefs
79 b = self.chkReadings.get_active()
80 prefs["kdict.render.kunyomi"] = b
81 prefs["kdict.render.onyomi"] = b
82 prefs["kdict.render.nanori"] = b
83 b = self.chkMeanings.get_active()
84 prefs["kdict.render.meaning"] = b
85 b = self.chkHighImp.get_active()
86 prefs["kdict.render.stroke_count"] = b
87 prefs["kdict.render.jlpt_level"] = b
88 prefs["kdict.render.jouyou_grade"] = b
89 prefs["kdict.render.frequency"] = b
90 b = self.chkMultiRad.get_active()
91 prefs["kdict.render.radical_list"] = b
92 b = self.chkDict.get_active()
93 prefs["kdict.render.dictionaries"] = b
94 b = self.chkVocabCrossRef.get_active()
95 prefs["kdict.render.vocab_cross_ref"] = b
96 b = self.chkLowImp.get_active()
97 prefs["kdict.render.cross_ref"] = b
98 prefs["kdict.render.jis-208"] = b
99 prefs["kdict.render.jis-212"] = b
100 prefs["kdict.render.jis-213"] = b
101 prefs["kdict.render.nelson_radical"] = b
102 prefs["kdict.render.kangxi_radical"] = b
103 prefs["kdict.render.korean"] = b
104 prefs["kdict.render.korean_roman"] = b
105 prefs["kdict.render.pinyin_roman"] = b
106 prefs["kdict.render.radical_name"] = b
107 prefs["kdict.render.unicode"] = b
108 b = self.chkSodStatic.get_active()
109 prefs["kdict.render.kanjicafe_sodas"] = b
110 b = self.chkSodAnim.get_active()
111 prefs["kdict.render.kanjicafe_sods"] = b
113 # Dicts
114 for key, obj in self.dict_buttons:
115 prefs[key] = obj.get_active()