2006-08-20 Alex Roitman <shura@gramps-project.org>

* src/Config/_GrampsConfigKeys.py: Regenerate file.
	* src/GrampsCfg.py (add_behavior_panel): Use new key.
	* data/gramps.schemas.in: Add default-source key.



svn: r7222
This commit is contained in:
Alex Roitman 2006-08-21 05:32:07 +00:00
parent 5e8834f131
commit 71a9697282
5 changed files with 65 additions and 26 deletions

View File

@ -1,3 +1,8 @@
2006-08-20 Alex Roitman <shura@gramps-project.org>
* src/Config/_GrampsConfigKeys.py: Regenerate file.
* src/GrampsCfg.py (add_behavior_panel): Use new key.
* data/gramps.schemas.in: Add default-source key.
2006-08-20 Don Allingham <don@gramps-project.org> 2006-08-20 Don Allingham <don@gramps-project.org>
* src/GrampsDb/_ReadGedcom.py: fix CHAN parsing for family * src/GrampsDb/_ReadGedcom.py: fix CHAN parsing for family

View File

@ -3,6 +3,18 @@
<gconfschemafile> <gconfschemafile>
<schemalist> <schemalist>
<schema>
<key>/schemas/apps/gramps/preferences/default-source</key>
<applyto>/apps/gramps/preferences/default-source</applyto>
<owner>gramps</owner>
<type>bool</type>
<default>0</default>
<locale name="C">
<short>Create default source on import</short>
<long>If True, a new source will be created and every record without source reference will be referenced to this source</long>
</locale>
</schema>
<schema> <schema>
<key>/schemas/apps/gramps/preferences/relation-shade</key> <key>/schemas/apps/gramps/preferences/relation-shade</key>
<applyto>/apps/gramps/preferences/relation-shade</applyto> <applyto>/apps/gramps/preferences/relation-shade</applyto>

View File

@ -20,6 +20,7 @@
# $Id$ # $Id$
DEFAULT_SOURCE = ('preferences','default-source', 0)
RELATION_SHADE = ('preferences','relation-shade', 0) RELATION_SHADE = ('preferences','relation-shade', 0)
ONLINE_MAPS = ('preferences','online-maps', 0) ONLINE_MAPS = ('preferences','online-maps', 0)
FAMILY_DETAILS = ('preferences','family-details', 0) FAMILY_DETAILS = ('preferences','family-details', 0)
@ -75,6 +76,7 @@ WEBSITE_DIRECTORY = ('paths','website-directory', 2)
default_value = { default_value = {
DEFAULT_SOURCE : False,
RELATION_SHADE : True, RELATION_SHADE : True,
ONLINE_MAPS : False, ONLINE_MAPS : False,
FAMILY_DETAILS : True, FAMILY_DETAILS : True,
@ -96,7 +98,7 @@ default_value = {
FILTER : False, FILTER : False,
FPREFIX : 'F%04d', FPREFIX : 'F%04d',
EPREFIX : 'E%04d', EPREFIX : 'E%04d',
RPREFIX : 'E%04d', RPREFIX : 'R%04d',
IPREFIX : 'I%04d', IPREFIX : 'I%04d',
OPREFIX : 'O%04d', OPREFIX : 'O%04d',
PPREFIX : 'P%04d', PPREFIX : 'P%04d',
@ -107,7 +109,7 @@ default_value = {
RECENT_FILE : '', RECENT_FILE : '',
RECENT_IMPORT_DIR : '', RECENT_IMPORT_DIR : '',
RECENT_EXPORT_DIR : '', RECENT_EXPORT_DIR : '',
NAME_FORMAT : 0, NAME_FORMAT : 1,
REPORT_DIRECTORY : './', REPORT_DIRECTORY : './',
RESEARCHER_ADDR : '', RESEARCHER_ADDR : '',
RESEARCHER_CITY : '', RESEARCHER_CITY : '',

View File

@ -480,11 +480,18 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
table.set_col_spacings(6) table.set_col_spacings(6)
table.set_row_spacings(6) table.set_row_spacings(6)
self.add_checkbox(table, _('Automatically load last database'), 0, Config.AUTOLOAD) self.add_checkbox(table, _('Automatically load last database'),
self.add_checkbox(table, _('Enable spelling checker'), 1, Config.SPELLCHECK) 0, Config.AUTOLOAD)
self.add_checkbox(table, _('Display Tip of the Day'), 2, Config.USE_TIPS) self.add_checkbox(table, _('Add default source on import'),
self.add_checkbox(table, _('Download maps online'), 3, Config.ONLINE_MAPS) 1, Config.DEFAULT_SOURCE)
self.add_checkbox(table, _('Use shading in Relationship View'), 4, Config.RELATION_SHADE) self.add_checkbox(table, _('Enable spelling checker'),
2, Config.SPELLCHECK)
self.add_checkbox(table, _('Display Tip of the Day'),
3, Config.USE_TIPS)
self.add_checkbox(table, _('Download maps online'),
4, Config.ONLINE_MAPS)
self.add_checkbox(table, _('Use shading in Relationship View'),
5, Config.RELATION_SHADE)
return table return table

View File

@ -69,6 +69,9 @@ from QuestionDialog import ErrorDialog, WarningDialog
from _GrampsDbBase import EVENT_KEY from _GrampsDbBase import EVENT_KEY
from BasicUtils import UpdateCallback from BasicUtils import UpdateCallback
# FIXME: This needs soon to become a preference setting
use_def_src = True
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Address/Place constants # Address/Place constants
@ -235,7 +238,9 @@ def import2(database, filename, callback, codeset, use_trans):
use_trans = False use_trans = False
try: try:
t = time.time()
close = g.parse_gedcom_file(use_trans) close = g.parse_gedcom_file(use_trans)
print time.time() - t
except IOError,msg: except IOError,msg:
errmsg = _("%s could not be opened\n") % filename errmsg = _("%s could not be opened\n") % filename
ErrorDialog(errmsg,str(msg)) ErrorDialog(errmsg,str(msg))
@ -509,6 +514,7 @@ class GedcomParser(UpdateCallback):
self.added = set() self.added = set()
self.gedmap = GedcomInfoDB() self.gedmap = GedcomInfoDB()
self.gedsource = self.gedmap.get_from_source_tag('GEDCOM 5.5') self.gedsource = self.gedmap.get_from_source_tag('GEDCOM 5.5')
if use_def_src:
self.def_src = RelLib.Source() self.def_src = RelLib.Source()
fname = os.path.basename(filename).split('\\')[-1] fname = os.path.basename(filename).split('\\')[-1]
self.def_src.set_title(_("Import from %s") % unicode(fname)) self.def_src.set_title(_("Import from %s") % unicode(fname))
@ -842,6 +848,7 @@ class GedcomParser(UpdateCallback):
try: try:
self.parse_header() self.parse_header()
self.parse_submitter() self.parse_submitter()
if use_def_src:
self.db.add_source(self.def_src,self.trans) self.db.add_source(self.def_src,self.trans)
self.parse_record() self.parse_record()
self.parse_trailer() self.parse_trailer()
@ -888,6 +895,7 @@ class GedcomParser(UpdateCallback):
if self.level_is_finished(matches,level): if self.level_is_finished(matches,level):
break break
elif matches[1] == TOKEN_NAME: elif matches[1] == TOKEN_NAME:
if use_def_src:
self.def_src.set_author(matches[2]) self.def_src.set_author(matches[2])
elif matches[1] == TOKEN_ADDR: elif matches[1] == TOKEN_ADDR:
self.ignore_sub_junk(level+1) self.ignore_sub_junk(level+1)
@ -1308,7 +1316,7 @@ class GedcomParser(UpdateCallback):
self.db.commit_person(child, self.trans) self.db.commit_person(child, self.trans)
# add default reference if no reference exists # add default reference if no reference exists
if len(self.family.get_source_references()) == 0: if use_def_src and len(self.family.get_source_references()) == 0:
sref = RelLib.SourceRef() sref = RelLib.SourceRef()
sref.set_reference_handle(self.def_src.handle) sref.set_reference_handle(self.def_src.handle)
self.family.add_source_reference(sref) self.family.add_source_reference(sref)
@ -1546,7 +1554,7 @@ class GedcomParser(UpdateCallback):
# Add the default reference if no source has found # Add the default reference if no source has found
if len(self.media.get_source_references()) == 0: if use_def_src and len(self.media.get_source_references()) == 0:
sref = RelLib.SourceRef() sref = RelLib.SourceRef()
sref.set_reference_handle(self.def_src.handle) sref.set_reference_handle(self.def_src.handle)
self.media.add_source_reference(sref) self.media.add_source_reference(sref)
@ -1617,8 +1625,7 @@ class GedcomParser(UpdateCallback):
func(matches, state) func(matches, state)
# Add the default reference if no source has found # Add the default reference if no source has found
if use_def_src and len(self.person.get_source_references()) == 0:
if len(self.person.get_source_references()) == 0:
sref = RelLib.SourceRef() sref = RelLib.SourceRef()
sref.set_reference_handle(self.def_src.handle) sref.set_reference_handle(self.def_src.handle)
self.person.add_source_reference(sref) self.person.add_source_reference(sref)
@ -2141,17 +2148,20 @@ class GedcomParser(UpdateCallback):
elif matches[1] == TOKEN_NAME: elif matches[1] == TOKEN_NAME:
pass pass
elif matches[1] == TOKEN_VERS: elif matches[1] == TOKEN_VERS:
if use_def_src:
self.def_src.set_data_item('Generated by',"%s %s" % self.def_src.set_data_item('Generated by',"%s %s" %
(genby,matches[2])) (genby,matches[2]))
pass
elif matches[1] == TOKEN_FILE: elif matches[1] == TOKEN_FILE:
if use_def_src:
filename = os.path.basename(matches[2]).split('\\')[-1] filename = os.path.basename(matches[2]).split('\\')[-1]
self.def_src.set_title(_("Import from %s") % filename) self.def_src.set_title(_("Import from %s") % filename)
elif matches[1] == TOKEN_COPR: elif matches[1] == TOKEN_COPR:
if use_def_src:
self.def_src.set_publication_info(matches[2]) self.def_src.set_publication_info(matches[2])
elif matches[1] == TOKEN_SUBM: elif matches[1] == TOKEN_SUBM:
self.parse_subm(2) self.parse_subm(2)
elif matches[1] in (TOKEN_CORP, TOKEN_DATA, TOKEN_SUBN, TOKEN_LANG, TOKEN_TIME): elif matches[1] in (TOKEN_CORP, TOKEN_DATA, TOKEN_SUBN,
TOKEN_LANG, TOKEN_TIME):
self.ignore_sub_junk(2) self.ignore_sub_junk(2)
elif matches[1] == TOKEN_DEST: elif matches[1] == TOKEN_DEST:
if genby == "GRAMPS": if genby == "GRAMPS":
@ -2172,8 +2182,10 @@ class GedcomParser(UpdateCallback):
elif matches[1] == TOKEN_DATE: elif matches[1] == TOKEN_DATE:
date = self.parse_date(2) date = self.parse_date(2)
date.date = matches[2] date.date = matches[2]
if use_def_src:
self.def_src.set_data_item('Creation date',matches[2]) self.def_src.set_data_item('Creation date',matches[2])
elif matches[1] == TOKEN_NOTE: elif matches[1] == TOKEN_NOTE:
if use_def_src:
note = self.parse_note(matches,self.def_src,2,'') note = self.parse_note(matches,self.def_src,2,'')
elif matches[1] == TOKEN_UNKNOWN: elif matches[1] == TOKEN_UNKNOWN:
self.ignore_sub_junk(2) self.ignore_sub_junk(2)
@ -2187,6 +2199,7 @@ class GedcomParser(UpdateCallback):
if self.level_is_finished(matches, level): if self.level_is_finished(matches, level):
break break
elif matches[1] == TOKEN_NAME: elif matches[1] == TOKEN_NAME:
if use_def_src:
self.def_src.set_author(matches[2]) self.def_src.set_author(matches[2])
else: else:
self.ignore_sub_junk(2) self.ignore_sub_junk(2)