From 9d94d34a1fbe2105d4360200e82c314ac76e1e03 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 4 Sep 2002 12:54:38 +0000 Subject: [PATCH] Hopefully removed *.so files from the building of the tarball, added GraphViz patches from Alexandre Duret-Lutz. svn: r1129 --- gramps/gramps.spec | 2 +- gramps/src/GrampsCfg.py | 93 ++++++++++-------------- gramps/src/RelLib.py | 7 +- gramps/src/WriteXML.py | 9 ++- gramps/src/const.py | 2 +- gramps/src/plugins/GraphViz.py | 127 +++++++++++++++++++++++---------- 6 files changed, 138 insertions(+), 102 deletions(-) diff --git a/gramps/gramps.spec b/gramps/gramps.spec index 7271e91df..3a59828e8 100644 --- a/gramps/gramps.spec +++ b/gramps/gramps.spec @@ -1,5 +1,5 @@ %define ver 0.8.0 -%define rel 1 +%define rel pl1 %define prefix /usr Summary: Genealogical Research and Analysis Management Programming System. diff --git a/gramps/src/GrampsCfg.py b/gramps/src/GrampsCfg.py index e8bd3f841..11d49d72d 100644 --- a/gramps/src/GrampsCfg.py +++ b/gramps/src/GrampsCfg.py @@ -39,7 +39,7 @@ import GTK import gtk import gnome.ui import libglade -from gnome.config import * +import gnome.config #------------------------------------------------------------------------- # @@ -228,10 +228,10 @@ def loadConfig(call): lastfile = get_string("/gramps/data/LastFile") usetabs = get_bool("/gramps/config/UseTabs") uselds = get_bool("/gramps/config/UseLDS") - ac = get_bool("/gramps/config/DisableAutoComplete") - mediaref = get_bool("/gramps/config/MakeReference") - globalprop = get_bool("/gramps/config/DisplayGlobal") - localprop = get_bool("/gramps/config/DisplayLocal") + ac = get_bool("/gramps/config/DisableAutoComplete",0) + mediaref = get_bool("/gramps/config/MakeReference",1) + globalprop = get_bool("/gramps/config/DisplayGlobal",1) + localprop = get_bool("/gramps/config/DisplayLocal",1) calendar = get_bool("/gramps/config/ShowCalendar") usevc = get_bool("/gramps/config/UseVersionControl") vc_comment = get_bool("/gramps/config/UseComment") @@ -241,7 +241,7 @@ def loadConfig(call): index_visible = get_bool("/gramps/config/IndexVisible") show_detail = get_bool("/gramps/config/ShowDetail") status_bar = get_int("/gramps/config/StatusBar") - t = get_int("/gramps/config/ToolBar") + t = get_int("/gramps/config/ToolBar",2) if t == 0: toolbar = 2 else: @@ -250,7 +250,7 @@ def loadConfig(call): attr_name = get_string("/gramps/config/DisplayAttrName") hide_altnames = get_bool("/gramps/config/DisplayAltNames") - autoload = get_bool("/gramps/config/autoLoad") + autoload = get_bool("/gramps/config/autoLoad",0) autosave_int = get_int("/gramps/config/autoSaveInterval") dateFormat = get_int("/gramps/config/dateFormat") dateEntry = get_int("/gramps/config/dateEntry") @@ -323,60 +323,12 @@ def loadConfig(call): if attr_name == None: attr_name = "" - if autoload == None: - autoload = 1 - if autosave_int == None: - autosave_int = 0 - if mediaref == None: - mediaref = 1 - if globalprop == None: - globalprop = 1 - if localprop == None: - localprop =1 - if usetabs == None: - usetabs = 0 - if uselds == None: - uselds = 0 - if ac == None: - autocomp = 1 - else: - autocomp = not ac + autocomp = not ac - if calendar == None: - calendar = 0 - if usevc == None: - usevc = 0 - if vc_comment == None: - vc_comment = 0 - if uncompress == None: - uncompress = 0 - if id_visible == None: - id_visible = 0 - if id_edit == None: - id_edit = 0 - if index_visible == None: - index_visible = 0 - if show_detail == None: - show_detail = 0 - if status_bar == None: - status_bar = 0 - if toolbar == None: - toolbar = 2 - if hide_altnames == None: - hide_altnames = 0 - if dateFormat == None: - dateFormat = 0 - if dateEntry == None: - dateEntry = 0 - set_format_code(dateFormat) Date.entryCode = dateEntry - if lastnamegen == None or lastnamegen == 0: - lastnamegen = 0 - - if _name_format == None or _name_format == 0: - _name_format = 0 + if _name_format == 0: nameof = Utils.normal_name else: nameof = Utils.phonebook_name @@ -386,6 +338,33 @@ def loadConfig(call): make_path(os.path.expanduser("~/.gramps/plugins")) make_path(os.path.expanduser("~/.gramps/templates")) +def get_string(value,defval=""): + v = gnome.config.get_string(value) + if v == None: + return defval + else: + return v + +def get_bool(key,defval=0): + v = gnome.config.get_bool(key) + if v: + return v + else: + return defval + +def get_int(key,defval=0): + v = gnome.config.get_int(key) + if v: + return v + else: + return defval + +def set_bool(key,value): + gnome.config.set_bool(key,value) + +def set_string(key,value): + gnome.config.set_string(key,value) + #------------------------------------------------------------------------- # # diff --git a/gramps/src/RelLib.py b/gramps/src/RelLib.py index d10b0335e..dd0cebb03 100644 --- a/gramps/src/RelLib.py +++ b/gramps/src/RelLib.py @@ -2183,7 +2183,6 @@ class GrampsDB(Persistent): else: source = Source() map[idVal] = self.addSource(source) - self.sourceTable[map[idVal]] = source.getDisplayInfo() return source def addSourceNoMap(self,source,index): @@ -2203,7 +2202,6 @@ class GrampsDB(Persistent): else: source = Source() self.addSourceNoMap(source,val) - self.sourceTable[val] = source.getDisplayInfo() return source def addObject(self,object): @@ -2334,7 +2332,10 @@ class GrampsDB(Persistent): return self.sourceTable[key] def getSource(self,key): - return self.sourceMap[key] + if self.sourceMap.has_key(key): + return self.sourceMap[key] + else: + return None def buildSourceDisplay(self,nkey,okey=None): if nkey != okey and okey != None: diff --git a/gramps/src/WriteXML.py b/gramps/src/WriteXML.py index 8089aa8c9..3075b5b2d 100644 --- a/gramps/src/WriteXML.py +++ b/gramps/src/WriteXML.py @@ -32,6 +32,8 @@ import time import shutil import os +from gnome.ui import GnomeErrorDialog + #------------------------------------------------------------------------- # # load GRAMPS libraries @@ -71,7 +73,6 @@ def exportData(database, filename, callback): g = XmlWriter(database,callback,0,compress) g.write(filename) except: - from gnome.ui import GnomeErrorDialog import DisplayTrace DisplayTrace.DisplayTrace() @@ -295,6 +296,12 @@ class XmlWriter: self.g.write(" \n") for key in self.db.getSourceKeys(): source = self.db.getSource(key) + if not source: + d = self.db.getSourceDisplay(key) + GnomeErrorDialog("Database inconsistency found with sources\n" + "Index found for %s (%s)\n" + "but not included in tables - attempting to fix" % (d[0],d[1])) + continue if self.callback and count % delta == 0: self.callback(float(count)/float(total)) count = count + 1 diff --git a/gramps/src/const.py b/gramps/src/const.py index b6dc91e51..bf9322a1f 100644 --- a/gramps/src/const.py +++ b/gramps/src/const.py @@ -92,7 +92,7 @@ startup = 1 # #------------------------------------------------------------------------- progName = "GRAMPS" -version = "0.8.0-1" +version = "0.8.0-pl1" copyright = "© 2001-2002 Donald N. Allingham" authors = ["Donald N. Allingham", "David Hampton","Donald A. Peterson"] comments = _("GRAMPS (Genealogical Research and Analysis " diff --git a/gramps/src/plugins/GraphViz.py b/gramps/src/plugins/GraphViz.py index 24981a37b..b2472a251 100644 --- a/gramps/src/plugins/GraphViz.py +++ b/gramps/src/plugins/GraphViz.py @@ -165,6 +165,14 @@ class GraphVizDialog(ReportDialog): _("Non-birth relationships will show up " "as dashed lines in the graph.")) + self.show_families_cb = gtk.GtkCheckButton(_("Show family nodes")) + self.show_families_cb.set_active(0) + self.add_frame_option(_("GraphViz Options"), + '', + self.show_families_cb, + _("Families will show up as circles, linked" + "to parents and children.")) + tb_margin_adj = gtk.GtkAdjustment(value=0.5, lower=0.25, upper=100.0, step_incr=0.25) lr_margin_adj = gtk.GtkAdjustment(value=0.5, lower=0.25, @@ -218,7 +226,7 @@ class GraphVizDialog(ReportDialog): """Do Nothing. This document will be created in the make_report routine.""" pass - + #------------------------------------------------------------------------ # # Functions related to setting up the dialog window @@ -248,7 +256,8 @@ class GraphVizDialog(ReportDialog): self.adoptionsdashed = self.adoptionsdashed_cb.get_active() self.hpages = self.hpages_sb.get_value_as_int() self.vpages = self.vpages_sb.get_value_as_int() - + self.show_families = self.show_families_cb.get_active() + #------------------------------------------------------------------------ # # Functions related to creating the actual report document. @@ -266,83 +275,108 @@ class GraphVizDialog(ReportDialog): write_dot(file, ind_list, self.orien, width, height, self.tb_margin, self.lr_margin, self.hpages, self.vpages, self.includedates, self.includeurl, - self.colorize, self.adoptionsdashed, self.arrowheadstyle, self.arrowtailstyle) - + self.colorize, self.adoptionsdashed, self.arrowheadstyle, + self.arrowtailstyle, self.show_families) + #------------------------------------------------------------------------ # -# +# # #------------------------------------------------------------------------ def report(database,person): GraphVizDialog(database,person) - + #------------------------------------------------------------------------ # -# +# # #------------------------------------------------------------------------ def write_dot(file, ind_list, orien, width, height, tb_margin, lr_margin, hpages, vpages, includedates, includeurl, - colorize, adoptionsdashed, arrowheadstyle, arrowtailstyle): + colorize, adoptionsdashed, arrowheadstyle, arrowtailstyle, + show_families): file.write("digraph g {\n") file.write("bgcolor=white;\n") file.write("rankdir=LR;\n") file.write("center=1;\n") file.write("margin=0.5;\n") file.write("ratio=fill;\n") - file.write("size=\"%3.1fin,%3.1fin\";\n" % ((width*hpages)-(lr_margin*2)-((hpages-1)*1.0), + file.write("size=\"%3.1f,%3.1f\";\n" % ((width*hpages)-(lr_margin*2)-((hpages-1)*1.0), (height*vpages)-(tb_margin*2)-((vpages-1)*1.0))) - file.write("page=\"%3.1fin,%3.1fin\";\n" % (width,height)) + file.write("page=\"%3.1f,%3.1f\";\n" % (width,height)) if orien == PAPER_LANDSCAPE: file.write("rotate=90;\n") if len(ind_list) > 1: - dump_index(ind_list,file,includedates,includeurl,colorize) - dump_person(ind_list,file,adoptionsdashed,arrowheadstyle,arrowtailstyle) + dump_index(ind_list,file,includedates,includeurl,colorize, + arrowheadstyle,arrowtailstyle,show_families) + dump_person(ind_list,file,adoptionsdashed,arrowheadstyle, + arrowtailstyle,show_families) file.write("}\n") file.close() #------------------------------------------------------------------------ # -# +# # #------------------------------------------------------------------------ -def dump_person(person_list,file,adoptionsdashed,arrowheadstyle,arrowtailstyle): +def dump_person(person_list,file,adoptionsdashed,arrowheadstyle, + arrowtailstyle,show_families): for person in person_list: pid = string.replace(person.getId(),'-','_') - family, mrel, frel = person.getMainParentsRel() - if family == None: - continue - father = family.getFather() - if father and father in person_list: - fid = string.replace(father.getId(),'-','_') - file.write('p%s -> p%s [' % (pid, fid)) - file.write('arrowhead=%s, arrowtail=%s, ' % (arrowheadstyle, arrowtailstyle)) - if adoptionsdashed and frel != _("Birth"): - file.write('style=dashed') + for family, mrel, frel in person.getParentList(): + father = family.getFather() + mother = family.getMother() + fadopted = frel != _("Birth") + madopted = mrel != _("Birth") + if show_families: + # Link to the family node. + famid = string.replace(family.getId(),'-','_') + file.write('p%s -> f%s [' % (pid, famid)) + file.write('arrowhead=%s, arrowtail=%s, ' % + (arrowheadstyle, arrowtailstyle)) + if adoptionsdashed and (fadopted or madopted): + file.write('style=dashed') + else: + file.write('style=solid') + file.write('];\n') else: - file.write('style=solid') - file.write('];\n') - mother = family.getMother() - if mother and mother in person_list: - mid = string.replace(mother.getId(),'-','_') - file.write('p%s -> p%s [' % (pid, mid)) - file.write('arrowhead=%s, arrowtail=%s, ' % (arrowheadstyle, arrowtailstyle)) - if adoptionsdashed and mrel != _("Birth"): - file.write('style=dashed') - else: - file.write('style=solid') - file.write('];\n') + # Link to the parents' nodes directly. + if father and father in person_list: + fid = string.replace(father.getId(),'-','_') + file.write('p%s -> p%s [' % (pid, fid)) + file.write('arrowhead=%s, arrowtail=%s, ' % + (arrowheadstyle, arrowtailstyle)) + if adoptionsdashed and fadopted: + file.write('style=dashed') + else: + file.write('style=solid') + file.write('];\n') + if mother and mother in person_list: + mid = string.replace(mother.getId(),'-','_') + file.write('p%s -> p%s [' % (pid, mid)) + file.write('arrowhead=%s, arrowtail=%s, ' % + (arrowheadstyle, arrowtailstyle)) + if adoptionsdashed and madopted: + file.write('style=dashed') + else: + file.write('style=solid') + file.write('];\n') #------------------------------------------------------------------------ # -# +# # #------------------------------------------------------------------------ -def dump_index(person_list,file,includedates,includeurl,colorize): +def dump_index(person_list,file,includedates,includeurl,colorize, + arrowheadstyle,arrowtailstyle,show_families): + # The list of families for which we have output the node, so we + # don't do it twice. + families_done = [] for person in person_list: + # Output the person's node. label = person.getPrimaryName().getName() id = string.replace(person.getId(),'-','_') if includedates: @@ -367,10 +401,25 @@ def dump_index(person_list,file,includedates,includeurl,colorize): else: file.write('color=black, ') file.write('fontname="Arial", label="%s"];\n' % label) + # Output families's nodes. + if show_families: + family_list = person.getFamilyList() + for fam in family_list: + fid = string.replace(fam.getId(),'-','_') + if fam not in families_done: + file.write('f%s [shape=circle, label="", ' % fid) + file.write('weight=8, height=.3];\n') + # Link this person to all his/her families. + file.write('f%s -> p%s [' % (fid, id)) + file.write('arrowhead=%s, arrowtail=%s, ' % + (arrowheadstyle, arrowtailstyle)) + file.write('style=solid];\n') + + #------------------------------------------------------------------------ # -# +# # #------------------------------------------------------------------------ def get_description():