Font selection added. Preference saving/loading improved.
[jben2_gui.git] / dialog_preferences.py
blob6c4fdb53a26070900596215c56b941718b75671b
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 # Project: J-Ben, Python front-end
5 # File: dialog_preferences.py
6 # Author: Paul Goins
7 # Created on: 28 Nov 2008
9 import gtk
10 import os
12 from widget_storedsize import StoredSizeDialog
13 from tab_prefskanjidict import TabPrefsKanjiDict
14 from tab_prefsfonts import TabPrefsFonts
15 from tab_prefskanjitest import TabPrefsKanjiTest
16 from tab_prefsother import TabPrefsOther
18 class DialogPreferences(StoredSizeDialog):
19 def __init__(self, parent):
20 StoredSizeDialog.__init__(self, "gui.preferences.size", -1, -1,
21 _("Preferences Editor"), parent)
22 self.set_border_width(5)
24 self.tab_kanjidict = TabPrefsKanjiDict()
25 self.tab_fonts = TabPrefsFonts()
26 self.tab_kanjitest = TabPrefsKanjiTest()
27 self.tab_other = None
28 tabs = gtk.Notebook()
29 tabs.append_page(self.tab_kanjidict, gtk.Label(_("Kanji Dictionary")))
30 tabs.append_page(self.tab_fonts, gtk.Label(_("Fonts")))
31 tabs.append_page(self.tab_kanjitest, gtk.Label(_("Kanji test")))
32 self.tab_kanjitest.set_sensitive(False)
34 # Not sure what the os.name is under windows; the below is temporary.
35 if os.name == "nt":
36 self.tab_other = TabPrefsOther()
37 tabs.append_page(self.tab_other, gtk.Label("Other"))
38 self.tab_other.set_sensitive(False)
40 self.vbox.set_spacing(5)
41 self.vbox.pack_start(tabs)
42 self.vbox.show_all()
44 self.ok_button = gtk.Button(stock = gtk.STOCK_OK)
45 self.ok_button.connect("clicked", self.on_ok_clicked)
46 self.cancel_button = gtk.Button(stock = gtk.STOCK_CANCEL)
47 self.cancel_button.connect("clicked", self.on_cancel_clicked)
49 self.action_area.pack_start(self.cancel_button)
50 self.action_area.pack_start(self.ok_button)
51 self.action_area.show_all()
53 self.set_has_separator(False)
55 # Needed: Update function. Updates selected options depending on
56 # currently stored preferences.
57 ##self.update();
59 def on_cancel_clicked(self, widget):
60 print "DialogPreferences.on_cancel_clicked"
61 self.response(gtk.RESPONSE_CANCEL)
63 def on_ok_clicked(self, widget):
64 print "DialogPreferences.on_ok_clicked"
65 self.update_prefs()
66 self.response(gtk.RESPONSE_OK)
68 def update_prefs(self):
69 self.tab_kanjidict.update_prefs()
70 self.tab_fonts.update_prefs()
71 self.tab_kanjitest.update_prefs()
72 if self.tab_other:
73 self.tab_other.update_prefs()
76 # /* Other Options */
77 # chkMobile.set_active(prefs->GetSetting("config_save_target") == "mobile");