From bb8a154b5697d1ec9382199884107b3d28efb285 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Mon, 21 Jul 2003 00:09:12 +0000 Subject: [PATCH] * src/plugins/ReadGedcom.py: handle sources attached to a person (not to an event), handle the PAF/FTW _MARNM extension. * src/plugins/WriteGedcom.py: Allow for multi-line PAGE information for as source. * src/gramps.glade: parent relationship editor has an indicator to mark the parents as the preferred parents for reporting and display * src/ChooseParents.py: parent relationship editor has an indicator to mark the parents as the preferred parents for reporting and display svn: r1905 --- gramps2/src/ChooseParents.py | 32 ++++++++++++++- gramps2/src/Sources.py | 8 +++- gramps2/src/gramps.glade | 51 ++++++++++++++++++++++-- gramps2/src/plugins/ReadGedcom.py | 47 ++++++++++++++++------ gramps2/src/plugins/WriteGedcom.py | 2 +- gramps2/src/srcsel.glade | 62 ++++++++++++++++++------------ 6 files changed, 159 insertions(+), 43 deletions(-) diff --git a/gramps2/src/ChooseParents.py b/gramps2/src/ChooseParents.py index d4afc8437..431ba8b02 100644 --- a/gramps2/src/ChooseParents.py +++ b/gramps2/src/ChooseParents.py @@ -515,6 +515,18 @@ class ModifyParents: else: self.mother_rel.set_sensitive(0) + self.pref = self.glade.get_widget('preferred') + if len(self.person.getParentList()) > 1: + self.glade.get_widget('pref_label').show() + self.pref.show() + if family == self.person.getParentList()[0]: + self.pref.set_active(1) + else: + self.pref.set_active(0) + + self.top.show() + + def quit(self,obj): self.top.destroy() @@ -525,11 +537,29 @@ class ModifyParents: """ mother_rel = const.childRelations[self.mother_rel.get_text()] father_rel = const.childRelations[self.father_rel.get_text()] + mod = 0 Utils.destroy_passed_object(self.top) if mother_rel != self.orig_mrel or father_rel != self.orig_frel: self.person.removeAltFamily(self.family) self.person.addAltFamily(self.family,mother_rel,father_rel) - self.family_update(None) + mod = 1 Utils.modified() + if len(self.person.getParentList()): + make_pref = self.pref.get_active() + + plist = self.person.getParentList() + if make_pref: + if self.family != plist[0]: + self.person.setMainParents(self.family) + Utils.modified() + mod = 1 + else: + if self.family == plist[0]: + self.person.setMainParents(plist[0]) + Utils.modified() + mod = 1 + + if mod: + self.family_update(None) diff --git a/gramps2/src/Sources.py b/gramps2/src/Sources.py index c31e4bf65..d73d474d5 100644 --- a/gramps2/src/Sources.py +++ b/gramps2/src/Sources.py @@ -275,7 +275,8 @@ class SourceEditor: def draw(self,sel = None): self.title_menu.list.remove_items(self.list) if self.source_ref: - self.get_widget("spage").set_text(self.source_ref.getPage()) + spage = self.get_widget("spage") + spage.get_buffer().set_text(self.source_ref.getPage()) date = self.source_ref.getDate() if date: self.get_widget("sdate").set_text(date.getDate()) @@ -324,7 +325,6 @@ class SourceEditor: if self.active_source != self.source_ref.getBase(): self.source_ref.setBase(self.active_source) - page = self.get_widget("spage").get_text() date = self.get_widget("sdate").get_text() conf = self.get_widget("conf").get_menu().get_active().get_data('a') @@ -336,6 +336,10 @@ class SourceEditor: text = buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter(),gtk.FALSE) + buffer = self.get_widget('spage').get_buffer() + page = buffer.get_text(buffer.get_start_iter(), + buffer.get_end_iter(),gtk.FALSE) + self.source_ref.setPage(page) self.source_ref.getDate().set(date) self.source_ref.setText(text) diff --git a/gramps2/src/gramps.glade b/gramps2/src/gramps.glade index bb29d2fa5..646baf02d 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/gramps.glade @@ -1642,7 +1642,7 @@ True - Double-click to edit the selected parents + Double-click to edit the relationship to the selected parents True False True @@ -1916,7 +1916,7 @@ True - Double-click to edit the selected parents + Double-click to edit the relationship to the selected parents True False True @@ -5676,7 +5676,6 @@ - True GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE @@ -5770,7 +5769,7 @@ 12 True - 7 + 9 3 False 6 @@ -6361,6 +6360,50 @@ + + + + <b>Preference</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 3 + 7 + 8 + fill + + + + + + + Indicates that the parents should be used as the preferred parents for reporting and display purposes + True + Use as preferred parents + True + GTK_RELIEF_NORMAL + False + False + True + + + 1 + 3 + 8 + 9 + fill + + + 0 diff --git a/gramps2/src/plugins/ReadGedcom.py b/gramps2/src/plugins/ReadGedcom.py index 6359563e0..f454d1de4 100644 --- a/gramps2/src/plugins/ReadGedcom.py +++ b/gramps2/src/plugins/ReadGedcom.py @@ -361,12 +361,14 @@ class GedcomParser: return self.groups def barf(self,level): + import traceback msg = _("Warning: line %d was not understood, so it was ignored.") % self.index self.errmsg(msg) msg = "\n\t%s\n" % self.text self.errmsg(msg) self.error_count = self.error_count + 1 +# self.errmsg(string.join(traceback.format_stack())) self.ignore_sub_junk(level) def warn(self,msg): @@ -504,7 +506,7 @@ class GedcomParser: self.db.buildPersonDisplay(self.person.getId()) elif matches[2] in ["SUBM","SUBN","REPO"]: self.ignore_sub_junk(1) - elif matches[1] in ["SUBM","SUBN","OBJE"]: + elif matches[1] in ["SUBM","SUBN","OBJE","_EVENT_DEFN"]: self.ignore_sub_junk(1) elif matches[2] == "SOUR": self.parse_source(matches[1],1) @@ -661,7 +663,7 @@ class GedcomParser: self.family.addEvent(event) self.parse_family_event(event,2) - def parse_note(self,matches,obj,level,old_note): + def parse_note_base(self,matches,obj,level,old_note,task): note = old_note if matches[2] and matches[2][0] == "@": if self.nmap.has_key(matches[2]): @@ -677,10 +679,15 @@ class GedcomParser: note = "%s\n%s%s" % (old_note,matches[2],self.parse_continue_data(level)) else: note = matches[2] + self.parse_continue_data(level) - obj.setNote(note) + task(note) self.ignore_sub_junk(level+1) return note + def parse_note(self,matches,obj,level,old_note): + self.parse_note_base(matches,obj,level,old_note,obj.setNote) + + def parse_comment(self,matches,obj,level,old_note): + self.parse_note_base(matches,obj,level,old_note,obj.setComments) def parse_individual(self): name_cnt = 0 @@ -888,6 +895,9 @@ class GedcomParser: return (string.capitalize(type),note) elif matches[1] == "PEDI": type = matches[2] + elif matches[1] == "SOUR": + source_ref = self.handle_source(matches,level) + self.person.getPrimaryName().addSourceRef(source_ref) elif matches[1] == "_PRIMARY": type = matches[1] elif matches[1] == "NOTE": @@ -1033,7 +1043,7 @@ class GedcomParser: elif matches[1] == "ADDR": address.setStreet(matches[2] + self.parse_continue_data(level+1)) self.parse_address(address,level+1) - elif matches[1] in ["AGE","AGNC","CAUS","STAT","TEMP","OBJE","TYPE"]: + elif matches[1] in ["AGE","AGNC","CAUS","STAT","TEMP","OBJE","TYPE","_DATE2"]: self.ignore_sub_junk(level+1) elif matches[1] == "SOUR": source_ref = RelLib.SourceRef() @@ -1140,7 +1150,7 @@ class GedcomParser: elif matches[1] == "DATE": event.setDateObj(self.extract_date(matches[2])) elif matches[1] == "SOUR": - event.addSourceRef(self.handle_source(matches,level)) + event.addSourceRef(self.handle_source(matches,level+1)) elif matches[1] == "PLAC": val = matches[2] n = string.strip(event.getName()) @@ -1175,7 +1185,7 @@ class GedcomParser: event.setDescription("%s%s" % (d, matches[2])) elif matches[1] == "CONT": event.setDescription("%s\n%s" % (event.getDescription(),matches[2])) - elif matches[1] in ["RELI", "TIME","ADDR","AGE","AGNC","STAT","TEMP","OBJE"]: + elif matches[1] in ["RELI", "TIME","ADDR","AGE","AGNC","STAT","TEMP","OBJE","_DATE2"]: self.ignore_sub_junk(level+1) else: self.barf(level+1) @@ -1324,7 +1334,7 @@ class GedcomParser: elif matches[1] in ["TIME","AGE","AGNC","ADDR","STAT","TEMP","HUSB","WIFE","OBJE","_CHUR"]: self.ignore_sub_junk(level+1) elif matches[1] == "SOUR": - event.addSourceRef(self.handle_source(matches,level)) + event.addSourceRef(self.handle_source(matches,level+1)) elif matches[1] == "PLAC": val = matches[2] if self.placemap.has_key(val): @@ -1372,7 +1382,7 @@ class GedcomParser: else: source.setConfidence(val) elif matches[1] == "NOTE": - self.ignore_sub_junk(level+1) + note = self.parse_comment(matches,source,level+1,note) else: self.barf(level+1) @@ -1382,13 +1392,11 @@ class GedcomParser: note = "" while 1: matches = self.get_next() - if int(matches[0]) < level: self.backup() return (date,note) elif matches[1] == "DATE": date = matches[2] - elif matches[1] == "TEXT": note = matches[2] + self.parse_continue_data(level+1) else: @@ -1425,6 +1433,8 @@ class GedcomParser: elif matches[1] == "SURN": name.setSurname(matches[2]) self.db.addSurname(matches[2]) + elif matches[1] == "_MARNM": + self.parse_marnm(self.person,matches[2].strip()) elif matches[1] == "TITL": name.setSuffix(matches[2]) elif matches[1] == "NSFX": @@ -1453,6 +1463,20 @@ class GedcomParser: else: self.barf(level+1) + def parse_marnm(self,person,text): + data = text.split() + if len(data) == 1: + name = RelLib.Name(person.getPrimaryName()) + name.setSurname(data[0]) + name.setType('Married Name') + person.addAlternateName(name) + elif len(data) > 1: + name = RelLib.Name() + name.setSurname(data[-1]) + name.setFirstName(string.join(data[0:-1],' ')) + name.setType('Married Name') + person.addAlternateName(name) + def parse_header_head(self): """validiates that this is a valid GEDCOM file""" line = string.replace(self.f.readline(),'\r','') @@ -1481,6 +1505,7 @@ class GedcomParser: self.update(self.created_obj,matches[2]) elif matches[1] == "VERS" and self.window: self.update(self.version_obj,matches[2]) + pass elif matches[1] in ["CORP","DATA","SUBM","SUBN","COPR","FILE","LANG"]: self.ignore_sub_junk(2) elif matches[1] == "DEST": @@ -1691,7 +1716,7 @@ class GedcomParser: self.ignore_sub_junk(2) else: source_ref.setBase(self.db.findSource(matches[2],self.smap)) - self.parse_source_reference(source_ref,level+1) + self.parse_source_reference(source_ref,level) return source_ref def resolve_refns(self): diff --git a/gramps2/src/plugins/WriteGedcom.py b/gramps2/src/plugins/WriteGedcom.py index 2fb59cb41..1516483c3 100644 --- a/gramps2/src/plugins/WriteGedcom.py +++ b/gramps2/src/plugins/WriteGedcom.py @@ -1081,7 +1081,7 @@ class GedcomWriter: self.writeln("%d SOUR @%s@" % (level,self.sid(ref.getBase().getId()))) if ref.getPage() != "": - self.writeln("%d PAGE %s" % (level+1,ref.getPage())) + self.write_long_text("PAGE",level+1,self.cnvtxt(ref.getPage())) ref_text = ref.getText() if ref_text != "" or not ref.getDate().isEmpty(): diff --git a/gramps2/src/srcsel.glade b/gramps2/src/srcsel.glade index 11f8a1848..0660da8a7 100644 --- a/gramps2/src/srcsel.glade +++ b/gramps2/src/srcsel.glade @@ -2,6 +2,7 @@ + True @@ -146,9 +147,6 @@ 0 0 spage - - - 1 @@ -464,27 +462,6 @@ - - - True - True - True - True - 0 - - True - * - False - - - 2 - 4 - 7 - 8 - - - - True @@ -673,6 +650,43 @@ + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 2 + 4 + 7 + 8 + fill + fill + + 0