svn: r6439
This commit is contained in:
parent
d65456847d
commit
4d1b7b53dd
@ -24,26 +24,40 @@ from xml.parsers.expat import ExpatError, ParserCreate
|
|||||||
class SchemaHandler:
|
class SchemaHandler:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.list = []
|
||||||
|
self.clean()
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
self.tlist = []
|
self.tlist = []
|
||||||
self.type = ""
|
self.type = ""
|
||||||
self.default = ""
|
self.default = ""
|
||||||
self.key = ""
|
self.key = ""
|
||||||
|
self.include = False
|
||||||
self.short = ""
|
self.short = ""
|
||||||
self.list = []
|
self.long = ""
|
||||||
|
|
||||||
def startElement(self,tag,attrs):
|
def startElement(self,tag,attrs):
|
||||||
self.tlist = []
|
pass
|
||||||
|
|
||||||
def endElement(self,tag):
|
def endElement(self,tag):
|
||||||
data = ''.join(self.tlist)
|
data = ''.join(self.tlist).strip()
|
||||||
if tag == "type":
|
if tag == "type":
|
||||||
self.type = data
|
self.type = data
|
||||||
elif tag == "default":
|
elif tag == "default":
|
||||||
self.default = data
|
self.default = data
|
||||||
|
elif tag == "include":
|
||||||
|
self.include = int(data)
|
||||||
|
elif tag == "short":
|
||||||
|
self.short = data
|
||||||
|
elif tag == "long":
|
||||||
|
self.long = data.replace('\n','')
|
||||||
elif tag == "applyto":
|
elif tag == "applyto":
|
||||||
self.key = data
|
self.key = data
|
||||||
elif tag == "schema":
|
elif tag == "schema":
|
||||||
self.list.append((self.key, self.type, self.default))
|
self.list.append((self.key, self.type, self.default,
|
||||||
|
self.long, self.short, self.include))
|
||||||
|
self.clean()
|
||||||
|
self.tlist = []
|
||||||
|
|
||||||
def characters(self, data):
|
def characters(self, data):
|
||||||
self.tlist.append(data)
|
self.tlist.append(data)
|
||||||
@ -66,35 +80,70 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
type_map = { 'bool' : 0, 'int' : 1 , 'string' : 2 }
|
type_map = { 'bool' : 0, 'int' : 1 , 'string' : 2 }
|
||||||
|
|
||||||
print copy
|
|
||||||
|
|
||||||
parser = SchemaHandler()
|
parser = SchemaHandler()
|
||||||
parser.parse(sys.argv[1])
|
parser.parse(sys.argv[1])
|
||||||
for (key, key_type, default) in parser.list:
|
|
||||||
|
f = open("_GrampsConfigKeys","w")
|
||||||
|
|
||||||
|
for (key, key_type, default, long, short, include) in parser.list:
|
||||||
data = key.split('/')
|
data = key.split('/')
|
||||||
category = data[3]
|
category = data[3]
|
||||||
token = data[4]
|
token = data[4]
|
||||||
|
tkey = token.upper().replace('-','_')
|
||||||
|
tmap = type_map[key_type]
|
||||||
|
|
||||||
print "%-20s = ('%s','%s', %d)" % (token.upper().replace('-','_'),
|
f.write("%-20s = ('%s','%s', %d)\n" % (tkey,
|
||||||
category,
|
category,
|
||||||
token,
|
token,
|
||||||
type_map[key_type])
|
tmap))
|
||||||
|
|
||||||
print '\n\ndefault_value = {'
|
f.write('\n\ndefault_value = {\n')
|
||||||
for (key, key_type, default) in parser.list:
|
for (key, key_type, default, long, short, include) in parser.list:
|
||||||
data = key.split('/')
|
data = key.split('/')
|
||||||
category = data[3]
|
category = data[3]
|
||||||
token = data[4]
|
token = data[4]
|
||||||
tkey = token.upper().replace('-','_')
|
tkey = token.upper().replace('-','_')
|
||||||
if key_type == 'bool':
|
if key_type == 'bool':
|
||||||
if default == "1":
|
if default == "1":
|
||||||
print " %-20s : True," % tkey
|
f.write(" %-20s : True,\n" % tkey)
|
||||||
else:
|
else:
|
||||||
print " %-20s : False," % tkey
|
f.write(" %-20s : False,\n" % tkey)
|
||||||
elif key_type == "int":
|
elif key_type == "int":
|
||||||
print " %-20s : %s," % (tkey,default)
|
f.write(" %-20s : %s,\n" % (tkey,default))
|
||||||
else:
|
else:
|
||||||
print " %-20s : '%s'," % (tkey,default)
|
f.write(" %-20s : '%s',\n" % (tkey,default))
|
||||||
|
|
||||||
print '}'
|
f.write('}\n')
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
f = open("schema.xml.in","w")
|
||||||
|
|
||||||
|
f.write('<gconfschemafile>\n')
|
||||||
|
f.write(' <schemalist>\n')
|
||||||
|
for (key, key_type, default, long, short, include) in parser.list:
|
||||||
|
f.write(' <schema>\n')
|
||||||
|
f.write(' <key>/schemas%s</key>\n' % key)
|
||||||
|
f.write(' <applyto>/schemas%s</applyto>\n' % key)
|
||||||
|
f.write(' <owner>gramps</owner>\n')
|
||||||
|
f.write(' <type>%s</owner>\n' % type)
|
||||||
|
f.write(' <default>%s</default>\n' % default)
|
||||||
|
f.write(' <locale name="C">\n')
|
||||||
|
f.write(' <short>%s</short>\n' % short)
|
||||||
|
f.write(' <long>%s</long>\n' % long)
|
||||||
|
f.write(' </locale>\n')
|
||||||
|
f.write(' </schema>\n')
|
||||||
|
f.write(' </schemalist>\n')
|
||||||
|
f.write('</gconfschemafile>\n')
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
f = open("ConfigInterface.py","w")
|
||||||
|
for (key, key_type, default, long, short, include) in parser.list:
|
||||||
|
if not include:
|
||||||
|
continue
|
||||||
|
data = key.split('/')
|
||||||
|
category = data[3]
|
||||||
|
token = data[4]
|
||||||
|
tkey = token.upper().replace('-','_')
|
||||||
|
if key_type == "bool":
|
||||||
|
f.write("GrampsConfigCheckBox(_('%s'),Config.%s)\n" % (short,tkey))
|
||||||
|
f.close()
|
||||||
|
434
src/GrampsCfg.py
434
src/GrampsCfg.py
@ -25,7 +25,6 @@
|
|||||||
# Standard python modules
|
# Standard python modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import os
|
|
||||||
import sets
|
import sets
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
@ -34,7 +33,6 @@ from gettext import gettext as _
|
|||||||
# GTK/Gnome modules
|
# GTK/Gnome modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gobject
|
|
||||||
import gtk
|
import gtk
|
||||||
import gtk.glade
|
import gtk.glade
|
||||||
|
|
||||||
@ -44,20 +42,16 @@ import gtk.glade
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import Config
|
import Config
|
||||||
import RelLib
|
|
||||||
import const
|
|
||||||
import DateHandler
|
import DateHandler
|
||||||
import GrampsDisplay
|
import GrampsDisplay
|
||||||
import QuestionDialog
|
import ManagedWindow
|
||||||
|
from GrampsWidgets import *
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Constants
|
# Constants
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
INDEX = "i"
|
|
||||||
OBJECT = "o"
|
|
||||||
DATA = "d"
|
|
||||||
|
|
||||||
_surname_styles = [
|
_surname_styles = [
|
||||||
_("Father's surname"),
|
_("Father's surname"),
|
||||||
@ -66,61 +60,14 @@ _surname_styles = [
|
|||||||
_("Icelandic style"),
|
_("Icelandic style"),
|
||||||
]
|
]
|
||||||
|
|
||||||
panellist = [
|
|
||||||
(_("Display"),
|
|
||||||
[( _("General"), 3),
|
|
||||||
( _("Dates"), 4),
|
|
||||||
( _("Toolbar and Statusbar"), 2)]),
|
|
||||||
(_("Database"),
|
|
||||||
[( _("General"), 1),
|
|
||||||
( _("GRAMPS IDs"), 6),
|
|
||||||
( _("Researcher Information"), 5)]),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# Not exactly gconf keys, but the functions directly dependent on them
|
|
||||||
|
|
||||||
def set_calendar_date_format():
|
def set_calendar_date_format():
|
||||||
format_list = DateHandler.get_date_formats()
|
format_list = DateHandler.get_date_formats()
|
||||||
DateHandler.set_format(Config.get_date_format(format_list))
|
DateHandler.set_format(Config.get_date_format(format_list))
|
||||||
|
|
||||||
def _update_calendar_date_format(active,dlist):
|
|
||||||
Config.save_date_format(active,dlist)
|
|
||||||
DateHandler.set_format(active)
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# make_path -
|
|
||||||
# Creates a directory if it does not already exist. Assumes that the
|
|
||||||
# parent directory already exits
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
def make_path(path):
|
|
||||||
if not os.path.isdir(path):
|
|
||||||
os.mkdir(path)
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
def loadConfig():
|
|
||||||
"""
|
|
||||||
Load preferences on startup. Not much to do, since all the prefs
|
|
||||||
are in gconf and can be retrieved any time.
|
|
||||||
"""
|
|
||||||
make_path(const.home_dir)
|
|
||||||
make_path(os.path.join(const.home_dir,"filters"))
|
|
||||||
make_path(os.path.join(const.home_dir,"plugins"))
|
|
||||||
make_path(os.path.join(const.home_dir,"templates"))
|
|
||||||
make_path(os.path.join(const.home_dir,"thumb"))
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
def get_researcher():
|
def get_researcher():
|
||||||
|
import RelLib
|
||||||
|
|
||||||
n = Config.get(Config.RESEARCHER_NAME)
|
n = Config.get(Config.RESEARCHER_NAME)
|
||||||
a = Config.get(Config.RESEARCHER_ADDR)
|
a = Config.get(Config.RESEARCHER_ADDR)
|
||||||
c = Config.get(Config.RESEARCHER_CITY)
|
c = Config.get(Config.RESEARCHER_CITY)
|
||||||
@ -134,258 +81,185 @@ def get_researcher():
|
|||||||
owner.set(n,a,c,s,ct,p,ph,e)
|
owner.set(n,a,c,s,ct,p,ph,e)
|
||||||
return owner
|
return owner
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class GrampsPreferences:
|
class GrampsPreferences(ManagedWindow.ManagedWindow):
|
||||||
def __init__(self,db):
|
def __init__(self, uistate):
|
||||||
self.built = 0
|
|
||||||
self.db = db
|
|
||||||
self.top = gtk.glade.XML(const.gladeFile,"preferences","gramps")
|
|
||||||
|
|
||||||
self.top.get_widget('button6').connect('clicked',self.on_close_clicked)
|
ManagedWindow.ManagedWindow.__init__(self, uistate, [], GrampsPreferences)
|
||||||
self.top.get_widget('button7').connect('clicked',self.help_clicked)
|
|
||||||
|
|
||||||
self.window = self.top.get_widget("preferences")
|
tlabel = gtk.Label()
|
||||||
self.window.connect('delete_event',self.on_close_clicked)
|
self.set_window(gtk.Dialog(_('Preferences'),
|
||||||
self.tree = self.top.get_widget("tree")
|
flags=gtk.DIALOG_NO_SEPARATOR,
|
||||||
self.image = self.top.get_widget('image')
|
buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)),
|
||||||
self.image.set_from_file(os.path.join(const.image_dir,'splash.jpg'))
|
tlabel, _('Preferences'), None)
|
||||||
|
|
||||||
self.store = gtk.TreeStore(gobject.TYPE_STRING)
|
panel = gtk.Notebook()
|
||||||
self.selection = self.tree.get_selection()
|
self.window.vbox.pack_start(tlabel, padding=12)
|
||||||
self.selection.connect('changed',self.select)
|
self.window.vbox.add(panel)
|
||||||
col = gtk.TreeViewColumn('',gtk.CellRendererText(),text=0)
|
self.window.connect('response',self.done)
|
||||||
self.tree.append_column(col)
|
panel.append_page(self.add_researcher_panel(),
|
||||||
self.tree.set_model(self.store)
|
MarkupLabel("<b>%s</b>" % _('Researcher')))
|
||||||
self.panel = self.top.get_widget("panel")
|
panel.append_page(self.add_formats_panel(),
|
||||||
|
MarkupLabel("<b>%s</b>" % _('Formats')))
|
||||||
|
panel.append_page(self.add_behavior_panel(),
|
||||||
|
MarkupLabel("<b>%s</b>" % _('Behavior')))
|
||||||
|
panel.append_page(self.add_prefix_panel(),
|
||||||
|
MarkupLabel("<b>%s</b>" % _('ID Prefixes')))
|
||||||
|
panel.append_page(self.add_advanced_panel(),
|
||||||
|
MarkupLabel("<b>%s</b>" % _('Advanced')))
|
||||||
|
|
||||||
self.imap = {}
|
self.window.show_all()
|
||||||
self.build_tree()
|
self.show()
|
||||||
self.build()
|
|
||||||
self.built = 1
|
|
||||||
self.window.show()
|
|
||||||
|
|
||||||
def build_tree(self):
|
def done(self, obj, value):
|
||||||
prev = None
|
self.close()
|
||||||
ilist = []
|
|
||||||
for (name,lst) in panellist:
|
|
||||||
node = self.store.insert_after(None, prev)
|
|
||||||
self.store.set(node,0,name)
|
|
||||||
next = None
|
|
||||||
for (subname,tab) in lst:
|
|
||||||
next = self.store.insert_after(node,next)
|
|
||||||
ilist.append((next,tab))
|
|
||||||
self.store.set(next,0,subname)
|
|
||||||
for next,tab in ilist:
|
|
||||||
path = self.store.get_path(next)
|
|
||||||
self.imap[path] = tab
|
|
||||||
|
|
||||||
def build(self):
|
def add_researcher_panel(self):
|
||||||
|
table = gtk.Table(3,8)
|
||||||
|
table.set_border_width(12)
|
||||||
|
table.set_col_spacings(6)
|
||||||
|
table.set_row_spacings(6)
|
||||||
|
self.add_entry(table, _('Name'), 0, Config.RESEARCHER_NAME)
|
||||||
|
self.add_entry(table, _('Address'), 1, Config.RESEARCHER_ADDR)
|
||||||
|
self.add_entry(table, _('City'), 2, Config.RESEARCHER_CITY)
|
||||||
|
self.add_entry(table, _('State/Province'), 3, Config.RESEARCHER_STATE)
|
||||||
|
self.add_entry(table, _('Country'), 4, Config.RESEARCHER_COUNTRY)
|
||||||
|
self.add_entry(table, _('ZIP/Postal Code'), 5, Config.RESEARCHER_POSTAL)
|
||||||
|
self.add_entry(table, _('Phone'), 6, Config.RESEARCHER_PHONE)
|
||||||
|
self.add_entry(table, _('Email'), 7, Config.RESEARCHER_EMAIL)
|
||||||
|
return table
|
||||||
|
|
||||||
auto = self.top.get_widget("autoload")
|
def add_prefix_panel(self):
|
||||||
auto.set_active(Config.get(Config.AUTOLOAD))
|
table = gtk.Table(3,8)
|
||||||
auto.connect('toggled',
|
table.set_border_width(12)
|
||||||
lambda obj: Config.set(Config.AUTOLOAD,obj.get_active()))
|
table.set_col_spacings(6)
|
||||||
|
table.set_row_spacings(6)
|
||||||
|
self.add_entry(table, _('Person'), 0, Config.IPREFIX)
|
||||||
|
self.add_entry(table, _('Family'), 1, Config.FPREFIX)
|
||||||
|
self.add_entry(table, _('Place'), 2, Config.PPREFIX)
|
||||||
|
self.add_entry(table, _('Source'), 3, Config.SPREFIX)
|
||||||
|
self.add_entry(table, _('Media Object'), 4, Config.OPREFIX)
|
||||||
|
self.add_entry(table, _('Event'), 5, Config.EPREFIX)
|
||||||
|
self.add_entry(table, _('Repository'), 6, Config.RPREFIX)
|
||||||
|
return table
|
||||||
|
|
||||||
spell = self.top.get_widget("spellcheck")
|
def add_advanced_panel(self):
|
||||||
spell.set_active(Config.get(Config.SPELLCHECK))
|
table = gtk.Table(3,8)
|
||||||
spell.connect('toggled',
|
table.set_border_width(12)
|
||||||
lambda obj: Config.set(Config.SPELLCHECK))
|
table.set_col_spacings(6)
|
||||||
|
table.set_row_spacings(6)
|
||||||
|
self.add_checkbox(table, _('Warn when adding parents to a child'),
|
||||||
|
0, Config.FAMILY_WARN)
|
||||||
|
|
||||||
lds = self.top.get_widget("uselds")
|
self.add_checkbox(table, _('Suppress warning when cancelling with changed data'),
|
||||||
lds.set_active(Config.get(Config.USE_LDS))
|
1, Config.DONT_ASK)
|
||||||
lds.connect('toggled',
|
|
||||||
lambda obj: Config.set(Config.USE_LDS,obj.get_active()))
|
|
||||||
|
|
||||||
self.ipr = self.top.get_widget("iprefix")
|
self.add_checkbox(table, _('Show plugin status dialog on plugin load error'),
|
||||||
self.ipr.set_text(Config.get(Config.IPREFIX))
|
2, Config.POP_PLUGIN_STATUS)
|
||||||
self.opr = self.top.get_widget("oprefix")
|
|
||||||
self.opr.set_text(Config.get(Config.OPREFIX))
|
|
||||||
self.fpr = self.top.get_widget("fprefix")
|
|
||||||
self.fpr.set_text(Config.get(Config.FPREFIX))
|
|
||||||
self.spr = self.top.get_widget("sprefix")
|
|
||||||
self.spr.set_text(Config.get(Config.SPREFIX))
|
|
||||||
self.ppr = self.top.get_widget("pprefix")
|
|
||||||
self.ppr.set_text(Config.get(Config.PPREFIX))
|
|
||||||
|
|
||||||
sb2 = self.top.get_widget("stat2")
|
return table
|
||||||
sb3 = self.top.get_widget("stat3")
|
|
||||||
if Config.get(Config.STATUSBAR) == 0 or Config.get(Config.STATUSBAR) == 1:
|
def add_formats_panel(self):
|
||||||
sb2.set_active(1)
|
table = gtk.Table(3,8)
|
||||||
|
table.set_border_width(12)
|
||||||
|
table.set_col_spacings(6)
|
||||||
|
table.set_row_spacings(6)
|
||||||
|
|
||||||
|
obox = gtk.combo_box_new_text()
|
||||||
|
formats = DateHandler.get_date_formats()
|
||||||
|
for item in formats:
|
||||||
|
obox.append_text(item)
|
||||||
|
|
||||||
|
active = Config.get(Config.DATE_FORMAT)
|
||||||
|
if active >= len(formats):
|
||||||
|
active = 0
|
||||||
|
obox.set_active(active)
|
||||||
|
obox.connect('changed',
|
||||||
|
lambda obj: Config.set(Config.DATE_FORMAT, obj.get_active()))
|
||||||
|
|
||||||
|
lwidget = BasicLabel("%s: " % _('Date format'))
|
||||||
|
table.attach(lwidget, 0, 1, 0, 1, yoptions=0)
|
||||||
|
table.attach(obox, 1, 3, 0, 1, yoptions=0)
|
||||||
|
|
||||||
|
obox = gtk.combo_box_new_text()
|
||||||
|
formats = _surname_styles
|
||||||
|
for item in formats:
|
||||||
|
obox.append_text(item)
|
||||||
|
obox.set_active(Config.get(Config.SURNAME_GUESSING))
|
||||||
|
obox.connect('changed',
|
||||||
|
lambda obj: Config.set(Config.SURNAME_GUESSING, obj.get_active()))
|
||||||
|
|
||||||
|
lwidget = BasicLabel("%s: " % _('Surname Guessing'))
|
||||||
|
table.attach(lwidget, 0, 1, 1, 2, yoptions=0)
|
||||||
|
table.attach(obox, 1, 3, 1, 2, yoptions=0)
|
||||||
|
|
||||||
|
obox = gtk.combo_box_new_text()
|
||||||
|
formats = [_("Active person's name and ID"),
|
||||||
|
_("Relationship to home person")]
|
||||||
|
|
||||||
|
for item in formats:
|
||||||
|
obox.append_text(item)
|
||||||
|
active = Config.get(Config.STATUSBAR)
|
||||||
|
if active < 2:
|
||||||
|
obox.set_active(0)
|
||||||
else:
|
else:
|
||||||
sb3.set_active(1)
|
obox.set_active(1)
|
||||||
sb2.connect('toggled',
|
obox.connect('changed',
|
||||||
lambda obj: Config.set(Config.STATUSBAR,(2-obj.get_active())))
|
lambda obj: Config.set(Config.STATUSBAR, 2*obj.get_active()))
|
||||||
|
|
||||||
toolbarmenu = self.top.get_widget("tooloptmenu")
|
lwidget = BasicLabel("%s: " % _('Status bar'))
|
||||||
toolbarmenu.set_active(Config.get(Config.TOOLBAR)+1)
|
table.attach(lwidget, 0, 1, 2, 3, yoptions=0)
|
||||||
toolbarmenu.connect('changed',
|
table.attach(obox, 1, 3, 2, 3, yoptions=0)
|
||||||
lambda obj: Config.set(Config.TOOLBAR,obj.get_active()-1))
|
|
||||||
|
|
||||||
pvbutton = self.top.get_widget('pvbutton')
|
return table
|
||||||
fvbutton = self.top.get_widget('fvbutton')
|
|
||||||
if Config.get(Config.DEFAULT_VIEW) == 0:
|
|
||||||
pvbutton.set_active(1)
|
|
||||||
else:
|
|
||||||
fvbutton.set_active(1)
|
|
||||||
fvbutton.connect('toggled',
|
|
||||||
lambda obj: Config.set(Config.DEFAULT_VIEW,(obj.get_active())))
|
|
||||||
|
|
||||||
usetips = self.top.get_widget('usetips')
|
# status bar
|
||||||
usetips.set_active(Config.get(Config.USE_TIPS))
|
|
||||||
usetips.connect('toggled',
|
|
||||||
lambda obj: Config.set(Config.USE_TIPS,obj.get_active()))
|
|
||||||
|
|
||||||
lastnamegen_obj = self.top.get_widget("lastnamegen")
|
def add_behavior_panel(self):
|
||||||
cell = gtk.CellRendererText()
|
table = gtk.Table(3,8)
|
||||||
lastnamegen_obj.pack_start(cell,True)
|
table.set_border_width(12)
|
||||||
lastnamegen_obj.add_attribute(cell,'text',0)
|
table.set_col_spacings(6)
|
||||||
|
table.set_row_spacings(6)
|
||||||
|
|
||||||
store = gtk.ListStore(str)
|
self.add_checkbox(table, _('Automatically load last database'), 0, Config.AUTOLOAD)
|
||||||
for name in _surname_styles:
|
self.add_checkbox(table, _('Enable spelling checker'), 1, Config.SPELLCHECK)
|
||||||
store.append(row=[name])
|
self.add_checkbox(table, _('Display Tip of the Day'), 2, Config.USE_TIPS)
|
||||||
lastnamegen_obj.set_model(store)
|
|
||||||
guess = Config.get(Config.SURNAME_GUESSING)
|
|
||||||
if guess not in _surname_styles:
|
|
||||||
guess = Config.default_value[Config.SURNAME_GUESSING]
|
|
||||||
|
|
||||||
lastnamegen_obj.set_active(guess)
|
return table
|
||||||
lastnamegen_obj.connect("changed",
|
|
||||||
lambda obj:
|
|
||||||
Config.set(Config.SURNAME_GUESSING,obj.get_active())
|
|
||||||
)
|
|
||||||
|
|
||||||
date_option = self.top.get_widget("date_format")
|
def add_checkbox(self, table, label, index, constant):
|
||||||
dlist = DateHandler.get_date_formats()
|
checkbox = gtk.CheckButton(label)
|
||||||
date_option.pack_start(cell,True)
|
checkbox.set_active(Config.get(constant))
|
||||||
date_option.add_attribute(cell,'text',0)
|
checkbox.connect('toggled',self.update_checkbox, constant)
|
||||||
|
table.attach(checkbox, 1, 3, index, index+1, yoptions=0)
|
||||||
|
|
||||||
store = gtk.ListStore(str)
|
def add_entry(self, table, label, index, constant):
|
||||||
for item in dlist:
|
lwidget = BasicLabel("%s: " % label)
|
||||||
store.append(row=[item])
|
entry = gtk.Entry()
|
||||||
|
entry.set_text(Config.get(constant))
|
||||||
|
entry.connect('changed', self.update_entry, constant)
|
||||||
|
table.attach(lwidget, 0, 1, index, index+1, yoptions=0)
|
||||||
|
table.attach(entry, 1, 3, index, index+1, yoptions=0)
|
||||||
|
|
||||||
date_option.set_model(store)
|
def update_entry(self, obj, constant):
|
||||||
try:
|
Config.set(constant, unicode(obj.get_text()))
|
||||||
# Technically, a selected format might be out of range
|
|
||||||
# for this locale's format list.
|
|
||||||
date_option.set_active(Config.get_date_format(dlist))
|
|
||||||
except:
|
|
||||||
date_option.set_active(0)
|
|
||||||
|
|
||||||
date_option.connect("changed",
|
def update_checkbox(self, obj, constant):
|
||||||
lambda obj:
|
Config.set(constant, obj.get_active())
|
||||||
_update_calendar_date_format(obj.get_active(),dlist)
|
|
||||||
)
|
|
||||||
|
|
||||||
resname = self.top.get_widget("resname")
|
def build_menu_names(self,obj):
|
||||||
resname.set_text(Config.get(Config.RESEARCHER_NAME))
|
return (_('Preferences'),None)
|
||||||
resname.connect('changed',
|
|
||||||
lambda obj: Config.set(Config.RESEARCHER_NAME,obj.get_text()))
|
|
||||||
resaddr = self.top.get_widget("resaddr")
|
|
||||||
resaddr.set_text(Config.get(Config.RESEARCHER_ADDR))
|
|
||||||
resaddr.connect('changed',
|
|
||||||
lambda obj: Config.set(Config.RESEARCHER_ADDR,obj.get_text()))
|
|
||||||
rescity = self.top.get_widget("rescity")
|
|
||||||
rescity.set_text(Config.get(Config.RESEARCHER_CITY))
|
|
||||||
rescity.connect('changed',
|
|
||||||
lambda obj: Config.set(Config.RESEARCHER_CITY,obj.get_text()))
|
|
||||||
resstate = self.top.get_widget("resstate")
|
|
||||||
resstate.set_text(Config.get(Config.RESEARCHER_STATE))
|
|
||||||
resstate.connect('changed',
|
|
||||||
lambda obj: Config.set(Config.RESEARCHER_STATE,obj.get_text()))
|
|
||||||
rescountry = self.top.get_widget("rescountry")
|
|
||||||
rescountry.set_text(Config.get(Config.RESEARCHER_COUNTRY))
|
|
||||||
rescountry.connect('changed',
|
|
||||||
lambda obj: Config.set(Config.RESEARCHER_COUNTRY,obj.get_text()))
|
|
||||||
respostal = self.top.get_widget("respostal")
|
|
||||||
respostal.set_text(Config.get(Config.RESEARCHER_POSTAL))
|
|
||||||
respostal.connect('changed',
|
|
||||||
lambda obj: Config.set(Config.RESEARCHER_POSTAL,obj.get_text()))
|
|
||||||
resphone = self.top.get_widget("resphone")
|
|
||||||
resphone.set_text(Config.get(Config.RESEARCHER_PHONE))
|
|
||||||
resphone.connect('changed',
|
|
||||||
lambda obj: Config.set(Config.RESEARCHER_PHONE,obj.get_text()))
|
|
||||||
resemail = self.top.get_widget("resemail")
|
|
||||||
resemail.set_text(Config.get(Config.RESEARCHER_EMAIL))
|
|
||||||
resemail.connect('changed',
|
|
||||||
lambda obj: Config.set(Config.RESEARCHER_EMAIL,obj.get_text()))
|
|
||||||
|
|
||||||
def save_prefix(self):
|
def build_window_key(self,obj):
|
||||||
""" Validate the GRAMPS ID definitions to be usable"""
|
return id(GrampsPreferences)
|
||||||
ip = self.ipr.get_text()
|
|
||||||
op = self.opr.get_text()
|
|
||||||
fp = self.fpr.get_text()
|
|
||||||
sp = self.spr.get_text()
|
|
||||||
pp = self.ppr.get_text()
|
|
||||||
|
|
||||||
# Do validation to the GRAMPS-ID format strings
|
|
||||||
invalid_chars = sets.Set("# \t\n\r")
|
|
||||||
prefixes = [ip,op,fp,sp,pp]
|
|
||||||
testnums = [1,234,567890]
|
|
||||||
testresult = {} # used to test that IDs for different objects will be different
|
|
||||||
formaterror = False # true if formatstring is invalid
|
|
||||||
incompatible = False # true if ID string is possibly not GEDCOM compatible
|
|
||||||
for p in prefixes:
|
|
||||||
if invalid_chars & sets.Set(p):
|
|
||||||
incompatible = True
|
|
||||||
for n in testnums:
|
|
||||||
try:
|
|
||||||
testresult[p % n] = 1
|
|
||||||
except:
|
|
||||||
formaterror = True
|
|
||||||
|
|
||||||
idexampletext = _('Example for valid IDs are:\n'+
|
if __name__ == "__main__":
|
||||||
'I%d which will be displayed as I123 or\n'+
|
GrampsPreferences(None,None)
|
||||||
'S%06d which will be displayed as S000123.')
|
gtk.main()
|
||||||
if formaterror:
|
|
||||||
QuestionDialog.ErrorDialog( _("Invalid GRAMPS ID prefix"),
|
|
||||||
_("The GRAMPS ID prefix is invalid.\n")+
|
|
||||||
idexampletext,
|
|
||||||
self.window)
|
|
||||||
return False
|
|
||||||
elif incompatible:
|
|
||||||
QuestionDialog.OkDialog( _("Incompatible GRAMPS ID prefix"),
|
|
||||||
_("The GRAMPS ID prefix is in an unusual format and may"+
|
|
||||||
" cause problems when exporting the database to GEDCOM format.\n")+
|
|
||||||
idexampletext,
|
|
||||||
self.window)
|
|
||||||
elif len(testresult) != len(prefixes)*len(testnums):
|
|
||||||
QuestionDialog.ErrorDialog( _("Unsuited GRAMPS ID prefix"),
|
|
||||||
_("The GRAMPS ID prefix is unsuited because it does not"+
|
|
||||||
" distinguish between different objects.\n")+
|
|
||||||
idexampletext,
|
|
||||||
self.window)
|
|
||||||
return False
|
|
||||||
|
|
||||||
Config.set(Config.IPREFIX,ip)
|
|
||||||
Config.set(Config.OPREFIX,op)
|
|
||||||
Config.set(Config.FPREFIX,fp)
|
|
||||||
Config.set(Config.SPREFIX,sp)
|
|
||||||
Config.set(Config.PPREFIX,pp)
|
|
||||||
return True
|
|
||||||
|
|
||||||
def select(self,obj):
|
|
||||||
store,node = self.selection.get_selected()
|
|
||||||
if node:
|
|
||||||
path = store.get_path(node)
|
|
||||||
if node and self.imap.has_key(path):
|
|
||||||
self.panel.set_current_page(self.imap[path])
|
|
||||||
|
|
||||||
def help_clicked(self,obj):
|
|
||||||
GrampsDisplay.help('gramps-prefs')
|
|
||||||
|
|
||||||
def on_close_clicked(self,obj=None,dummy=None):
|
|
||||||
if not self.save_prefix():
|
|
||||||
return False
|
|
||||||
self.window.destroy()
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# Create the property box, and set the elements off the current values
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
def display_preferences_box(db):
|
|
||||||
GrampsPreferences(db)
|
|
||||||
|
@ -1423,20 +1423,23 @@ class GrampsParser:
|
|||||||
else:
|
else:
|
||||||
self.person.add_event_ref(ref)
|
self.person.add_event_ref(ref)
|
||||||
|
|
||||||
## # FIXME: re-enable when event types are fixed.
|
# FIXME: re-enable when event types are fixed.
|
||||||
## if self.event.get_description() == "" and \
|
|
||||||
## self.event.get_type()[0] != RelLib.Event.CUSTOM:
|
if self.event.get_description() == "" and \
|
||||||
## if self.family:
|
self.event.get_type() != RelLib.EventType.CUSTOM:
|
||||||
## text = _event_family_str % {
|
if self.family:
|
||||||
## 'event_name' : Utils.family_events[self.event.get_type()[0]],
|
text = _event_family_str % {
|
||||||
## 'family' : Utils.family_name(self.family,self.db),
|
'event_name' : str(self.event.get_type()),
|
||||||
## }
|
'family' : Utils.family_name(self.family,self.db),
|
||||||
## else:
|
}
|
||||||
## text = _event_person_str % {
|
elif self.person:
|
||||||
## 'event_name' : Utils.personal_events[self.event.get_type()[0]],
|
text = _event_person_str % {
|
||||||
## 'person' : NameDisplay.displayer.display(self.person),
|
'event_name' : str(self.event.get_type()),
|
||||||
## }
|
'person' : NameDisplay.displayer.display(self.person),
|
||||||
## self.event.set_description(text)
|
}
|
||||||
|
else:
|
||||||
|
text = u''
|
||||||
|
self.event.set_description(text)
|
||||||
|
|
||||||
self.db.commit_event(self.event,self.trans,self.change)
|
self.db.commit_event(self.event,self.trans,self.change)
|
||||||
self.event = None
|
self.event = None
|
||||||
|
@ -424,7 +424,7 @@ class ViewManager:
|
|||||||
GrampsDisplay.url( const.url_mailinglist)
|
GrampsDisplay.url( const.url_mailinglist)
|
||||||
|
|
||||||
def preferences_activate(self, obj):
|
def preferences_activate(self, obj):
|
||||||
GrampsCfg.display_preferences_box(self.state.db)
|
GrampsCfg.GrampsPreferences(self.uistate)
|
||||||
|
|
||||||
def report_bug_activate(self, obj):
|
def report_bug_activate(self, obj):
|
||||||
import GrampsDisplay
|
import GrampsDisplay
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gtk
|
import gtk
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
log = logging.getLogger(".")
|
log = logging.getLogger(".")
|
||||||
|
|
||||||
@ -101,6 +102,19 @@ def register_stock_icons ():
|
|||||||
icon_set = gtk.IconSet (pixbuf)
|
icon_set = gtk.IconSet (pixbuf)
|
||||||
factory.add (data[0], icon_set)
|
factory.add (data[0], icon_set)
|
||||||
|
|
||||||
|
|
||||||
|
def build_user_paths():
|
||||||
|
user_paths = [const.home_dir,
|
||||||
|
os.path.join(const.home_dir,"filters"),
|
||||||
|
os.path.join(const.home_dir,"plugins"),
|
||||||
|
os.path.join(const.home_dir,"templates"),
|
||||||
|
os.path.join(const.home_dir,"thumb")]
|
||||||
|
|
||||||
|
for path in user_paths:
|
||||||
|
if not os.path.isdir(path):
|
||||||
|
os.mkdir(path)
|
||||||
|
|
||||||
|
|
||||||
class Gramps:
|
class Gramps:
|
||||||
"""
|
"""
|
||||||
Main class corresponding to a running gramps process.
|
Main class corresponding to a running gramps process.
|
||||||
@ -111,7 +125,7 @@ class Gramps:
|
|||||||
|
|
||||||
def __init__(self,args):
|
def __init__(self,args):
|
||||||
try:
|
try:
|
||||||
GrampsCfg.loadConfig()
|
build_user_paths()
|
||||||
self.welcome()
|
self.welcome()
|
||||||
except OSError, msg:
|
except OSError, msg:
|
||||||
ErrorDialog(_("Configuration error"),str(msg))
|
ErrorDialog(_("Configuration error"),str(msg))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user