pychecker fixes, GEDCOM import/export improvements, calendar improvements

svn: r1250
This commit is contained in:
Don Allingham 2003-01-10 05:21:32 +00:00
parent 7cbe8331e0
commit 141fec93ab
48 changed files with 489 additions and 480 deletions

Binary file not shown.

View File

@ -37,7 +37,6 @@ from intl import gettext as _
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gobject
import gtk.glade
#-------------------------------------------------------------------------
@ -210,8 +209,6 @@ class AddSpouse:
else:
sgender = const.female
index = 0
self.entries = []
self.slist.clear()
for key in self.db.getPersonKeys():

View File

@ -41,8 +41,7 @@ import const
import Utils
import Sources
import AutoComp
from RelLib import Attribute
import RelLib
from intl import gettext as _
@ -125,7 +124,7 @@ class AttributeEditor:
priv = self.priv.get_active()
if self.attrib == None:
self.attrib = Attribute()
self.attrib = RelLib.Attribute()
self.parent.alist.append(self.attrib)
self.attrib.setSourceRefList(self.srcreflist)

View File

@ -29,7 +29,6 @@ __version__ = "$Revision$"
#
#-------------------------------------------------------------------------
import gtk
import gnome.ui
#-------------------------------------------------------------------------
#

View File

@ -28,7 +28,6 @@ web site at http://www.scottlee.com
__author__ = "Donald N. Allingham"
__version__ = "$Revision$"
import math
from intl import gettext as _
import re
@ -158,7 +157,7 @@ class Calendar:
return 1
def quote_display(self,year,month,day,mode):
return "%s (%s)" % (text,Calendar.NAME)
return "%04d-%02d-%02d (%s)" % (year,month,day,Calendar.NAME)
def display(self,year,month,day,mode):
return _FMT_FUNC[Calendar.FORMATCODE](self,year,month,day,mode)
@ -168,8 +167,8 @@ class Calendar:
return ""
elif day == UNDEF:
if month == UNDEF:
retval = str(self.year)
elif self.year == UNDEF:
retval = str(year)
elif year == UNDEF:
retval = "????-%02d-??" % (month)
else:
retval = "%04d-%02d" % (year,month)
@ -270,7 +269,7 @@ class Calendar:
retval = str(year)
else:
month_str = self.month(month).upper()[0:3]
if self.year == UNDEF:
if year == UNDEF:
retval = "%d %s ????" % (day,month_str)
else:
retval = "%d %s %d" % (day,month_str,year)
@ -295,7 +294,7 @@ class Calendar:
retval = str(year)
else:
month_str = self.month(month).upper()[0:3]
if self.year == UNDEF:
if year == UNDEF:
retval = "%d. %s ????" % (day,month_str)
else:
retval = "%d. %s %d" % (day,month_str,year)
@ -356,7 +355,7 @@ class Calendar:
pass
elif day == UNDEF:
if month == UNDEF:
retval = str(self.year)
retval = str(year)
elif year == UNDEF:
retval = "????%s%02d%s??" % (sep,month+1,sep)
else:

View File

@ -48,7 +48,6 @@ import gtk.glade
#-------------------------------------------------------------------------
import RelLib
import const
import sort
import Utils
import GrampsCfg

View File

@ -333,7 +333,7 @@ class SingleDate:
self.calendar.set_month_string(text)
def getMonthStr(self):
return _mname[self.month]
return self.calendar.month(self.month)
def getIsoDate(self):
if self.year == UNDEF:

View File

@ -31,9 +31,7 @@ import pickle
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gobject
import gtk
import gnome.ui
import gtk.glade
from gtk.gdk import ACTION_COPY, BUTTON1_MASK, INTERP_BILINEAR, pixbuf_new_from_file
@ -47,13 +45,13 @@ import const
import Utils
import GrampsCfg
import Date
from RelLib import *
import ImageSelect
import sort
import AutoComp
import ListModel
import RelLib
from DateEdit import DateEdit
from QuestionDialog import QuestionDialog
from QuestionDialog import QuestionDialog, WarningDialog, ErrorDialog
from intl import gettext as _
@ -168,9 +166,9 @@ class EditPerson:
self.name_source = self.get_widget("name_source")
self.gid = self.get_widget("gid")
self.death = Event(person.getDeath())
self.birth = Event(person.getBirth())
self.pname = Name(person.getPrimaryName())
self.death = RelLib.Event(person.getDeath())
self.birth = RelLib.Event(person.getBirth())
self.pname = RelLib.Name(person.getPrimaryName())
self.elist = person.getEventList()[:]
self.nlist = person.getAlternateNames()[:]
@ -218,9 +216,9 @@ class EditPerson:
self.gid.set_text(person.getId())
self.gid.set_editable(GrampsCfg.id_edit)
self.lds_baptism = LdsOrd(self.person.getLdsBaptism())
self.lds_endowment = LdsOrd(self.person.getLdsEndowment())
self.lds_sealing = LdsOrd(self.person.getLdsSeal())
self.lds_baptism = RelLib.LdsOrd(self.person.getLdsBaptism())
self.lds_endowment = RelLib.LdsOrd(self.person.getLdsEndowment())
self.lds_sealing = RelLib.LdsOrd(self.person.getLdsSeal())
if GrampsCfg.uselds or self.lds_baptism or self.lds_endowment or self.lds_sealing:
self.get_widget("lds_tab").show()
@ -232,9 +230,9 @@ class EditPerson:
self.autotype = AutoComp.AutoEntry(self.ntype_field.entry,types)
self.write_primary_name()
if person.getGender() == Person.male:
if person.getGender() == RelLib.Person.male:
self.is_male.set_active(1)
elif person.getGender() == Person.female:
elif person.getGender() == RelLib.Person.female:
self.is_female.set_active(1)
else:
self.is_unknown.set_active(1)
@ -250,32 +248,24 @@ class EditPerson:
self.event_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY)
self.event_list.connect('drag_data_get', self.ev_drag_data_get)
self.event_list.connect('drag_begin', self.ev_drag_begin)
self.event_list.connect('drag_data_received',
self.ev_drag_data_received)
self.event_list.connect('drag_data_received',self.ev_drag_data_received)
self.web_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY)
self.web_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY)
self.web_list.connect('drag_data_get', self.url_drag_data_get)
self.web_list.connect('drag_begin', self.url_drag_begin)
self.web_list.connect('drag_data_received',
self.url_drag_data_received)
self.web_list.connect('drag_data_received',self.url_drag_data_received)
self.attr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,
ACTION_COPY)
self.attr_list.drag_source_set(BUTTON1_MASK, pycode_tgts,
ACTION_COPY)
self.attr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY)
self.attr_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY)
self.attr_list.connect('drag_data_get', self.at_drag_data_get)
self.attr_list.connect('drag_data_received',
self.at_drag_data_received)
self.attr_list.connect('drag_data_received',self.at_drag_data_received)
self.attr_list.connect('drag_begin', self.at_drag_begin)
self.addr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,
pycode_tgts,ACTION_COPY)
self.addr_list.drag_source_set(BUTTON1_MASK, pycode_tgts,
ACTION_COPY)
self.addr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY)
self.addr_list.drag_source_set(BUTTON1_MASK, pycode_tgts,ACTION_COPY)
self.addr_list.connect('drag_data_get', self.ad_drag_data_get)
self.addr_list.connect('drag_data_received',
self.ad_drag_data_received)
self.addr_list.connect('drag_data_received',self.ad_drag_data_received)
self.addr_list.connect('drag_begin', self.ev_drag_begin)
self.bdate_check = DateEdit(self.bdate,self.get_widget("birth_stat"))
@ -873,7 +863,7 @@ class EditPerson:
if self.pname.getNote() != name.getNote():
changed = 1
if self.lds_not_loaded == 0 and self.check_lds():
changed == 1
changed = 1
bplace = string.strip(self.bplace.get_text())
dplace = string.strip(self.dplace.get_text())
@ -898,11 +888,11 @@ class EditPerson:
changed = 1
if not self.death.are_equal(self.person.getDeath()):
changed = 1
if male and self.person.getGender() != Person.male:
if male and self.person.getGender() != RelLib.Person.male:
changed = 1
elif female and self.person.getGender() != Person.female:
elif female and self.person.getGender() != RelLib.Person.female:
changed = 1
elif unknown and self.person.getGender() != Person.unknown:
elif unknown and self.person.getGender() != RelLib.Person.unknown:
changed = 1
if text != self.person.getNote() or self.lists_changed:
changed = 1
@ -1200,7 +1190,7 @@ class EditPerson:
msg2 = _("%(grampsid)s is already used by %(person)s") % {
'grampsid' : idval,
'person' : n }
GnomeWarningDialog("%s\n%s" % (msg1,msg2))
WarningDialog("%s\n%s" % (msg1,msg2))
if suffix != name.getSuffix():
name.setSuffix(suffix)
@ -1267,8 +1257,8 @@ class EditPerson:
female = self.is_female.get_active()
unknown = self.is_unknown.get_active()
error = 0
if male and self.person.getGender() != Person.male:
self.person.setGender(Person.male)
if male and self.person.getGender() != RelLib.Person.male:
self.person.setGender(RelLib.Person.male)
for temp_family in self.person.getFamilyList():
if self.person == temp_family.getMother():
if temp_family.getFather() != None:
@ -1277,8 +1267,8 @@ class EditPerson:
temp_family.setMother(None)
temp_family.setFather(self.person)
Utils.modified()
elif female and self.person.getGender() != Person.female:
self.person.setGender(Person.female)
elif female and self.person.getGender() != RelLib.Person.female:
self.person.setGender(RelLib.Person.female)
for temp_family in self.person.getFamilyList():
if self.person == temp_family.getFather():
if temp_family.getMother() != None:
@ -1287,8 +1277,8 @@ class EditPerson:
temp_family.setFather(None)
temp_family.setMother(self.person)
Utils.modified()
elif unknown and self.person.getGender() != Person.unknown:
self.person.setGender(Person.unknown)
elif unknown and self.person.getGender() != RelLib.Person.unknown:
self.person.setGender(RelLib.Person.unknown)
for temp_family in self.person.getFamilyList():
if self.person == temp_family.getFather():
if temp_family.getMother() != None:
@ -1319,17 +1309,17 @@ class EditPerson:
if self.lds_not_loaded == 0:
self.check_lds()
ord = LdsOrd(self.person.getLdsBaptism())
ord = RelLib.LdsOrd(self.person.getLdsBaptism())
if not self.lds_baptism.are_equal(ord):
self.person.setLdsBaptism(self.lds_baptism)
Utils.modified()
ord = LdsOrd(self.person.getLdsEndowment())
ord = RelLib.LdsOrd(self.person.getLdsEndowment())
if not self.lds_endowment.are_equal(ord):
self.person.setLdsEndowment(self.lds_endowment)
Utils.modified()
ord = LdsOrd(self.person.getLdsSeal())
ord = RelLib.LdsOrd(self.person.getLdsSeal())
if not self.lds_sealing.are_equal(ord):
self.person.setLdsSeal(self.lds_sealing)
Utils.modified()
@ -1346,7 +1336,7 @@ class EditPerson:
if self.pmap.has_key(text):
return self.db.getPlaceMap()[self.pmap[text]]
elif makenew:
place = Place()
place = RelLib.Place()
place.set_title(text)
self.db.addPlace(place)
self.pmap[text] = place.getId()
@ -1396,7 +1386,6 @@ class EditPerson:
def on_ldsseal_source_clicked(self,obj):
import Sources
ord = self.person.getLdsSeal()
Sources.SourceSelector(self.lds_sealing.getSourceRefList(),self,self.lds_seal_list)
def lds_seal_list(self,list):
@ -1450,7 +1439,7 @@ class EditPerson:
self.nlist.remove(new)
self.nlist.append(old)
self.redraw_name_list()
self.pname = Name(new)
self.pname = RelLib.Name(new)
self.lists_changed = 1
self.write_primary_name()

View File

@ -33,7 +33,6 @@ import pickle
import gobject
import gtk
import gtk.glade
import gnome.ui
#-------------------------------------------------------------------------
#
@ -43,7 +42,6 @@ import gnome.ui
import const
import Utils
import GrampsCfg
from RelLib import *
import Sources
import ImageSelect
@ -78,7 +76,6 @@ class EditPlace:
self.srcreflist = []
self.top_window = gtk.glade.XML(const.placesFile,"placeEditor")
adj = gtk.Adjustment()
self.iconlist = self.top_window.get_widget('iconlist')
self.glry = ImageSelect.Gallery(place, self.path, self.iconlist, self.db, self)

View File

@ -34,7 +34,6 @@ import gtk.glade
import const
import Utils
import GrampsCfg
from RelLib import *
import ImageSelect
from intl import gettext as _

View File

@ -39,10 +39,10 @@ import Utils
import GrampsCfg
import AutoComp
import Calendar
import RelLib
import Date
from DateEdit import DateEdit
from Date import compare_dates
from RelLib import *
from intl import gettext as _
#-------------------------------------------------------------------------
@ -66,10 +66,10 @@ class EventEditor:
if event:
self.srcreflist = self.event.getSourceRefList()
self.date = Date(self.event.getDateObj())
self.date = Date.Date(self.event.getDateObj())
else:
self.srcreflist = []
self.date = Date(None)
self.date = Date.Date(None)
self.top = gtk.glade.XML(const.dialogFile, "event_edit")
self.window = self.top.get_widget("event_edit")
@ -165,7 +165,7 @@ class EventEditor:
if self.pmap.has_key(text):
return self.parent.db.getPlaceMap()[self.pmap[text]]
elif makenew:
place = Place()
place = RelLib.Place()
place.set_title(text)
self.parent.db.addPlace(place)
self.pmap[text] = place.getId()
@ -190,7 +190,7 @@ class EventEditor:
epriv = self.priv.get_active()
if self.event == None:
self.event = Event()
self.event = RelLib.Event()
self.event.setSourceRefList(self.srcreflist)
self.parent.elist.append(self.event)
@ -220,7 +220,7 @@ class EventEditor:
self.event.setSourceRefList(self.srcreflist)
if compare_dates(dobj,date) != 0:
if Date.compare_dates(dobj,date) != 0:
self.event.setDateObj(date)
self.parent.lists_changed = 1

View File

@ -18,6 +18,13 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------------
#
# standard python modules
#
#-------------------------------------------------------------------------
import pickle
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
@ -26,6 +33,7 @@
import gobject
import gtk
import gtk.glade
from gtk.gdk import ACTION_COPY, BUTTON1_MASK
#-------------------------------------------------------------------------
#
@ -34,17 +42,19 @@ import gtk.glade
#-------------------------------------------------------------------------
import const
import sort
from intl import gettext as _
import Utils
import GrampsCfg
from RelLib import Person
from QuestionDialog import QuestionDialog
import AddSpouse
import SelectChild
import DisplayTrace
import Marriage
import ChooseParents
import RelLib
from intl import gettext as _
from QuestionDialog import QuestionDialog,WarningDialog
pycode_tgts = [('child', 0, 0)]
#-------------------------------------------------------------------------
#
@ -98,11 +108,18 @@ class FamilyView:
self.selected_spouse = None
self.child_list = self.top.get_widget('chlist')
self.child_list.set_reorderable(gtk.TRUE)
self.child_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY)
self.child_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY)
self.child_list.connect('drag_data_get', self.drag_data_get)
self.child_list.connect('drag_begin', self.drag_begin)
self.child_list.connect('drag_data_received',self.drag_data_received)
self.child_model = gtk.ListStore(gobject.TYPE_INT, gobject.TYPE_STRING,
gobject.TYPE_STRING,gobject.TYPE_STRING,
gobject.TYPE_STRING,gobject.TYPE_STRING,
gobject.TYPE_STRING)
self.child_selection = self.child_list.get_selection()
self.child_list.connect('button-press-event',self.on_child_list_button_press)
@ -351,7 +368,7 @@ class FamilyView:
def delete_family_from(self,person):
person.removeFamily(self.family)
self.db.deleteFamily(self.family)
self.parent.db.deleteFamily(self.family)
flist = self.person.getFamilyList()
if len(flist) > 0:
self.family = flist[0][0]
@ -385,9 +402,9 @@ class FamilyView:
attr = ""
for child in child_list:
status = _("Unknown")
if child.getGender() == Person.male:
if child.getGender() == RelLib.Person.male:
gender = const.male
elif child.getGender() == Person.female:
elif child.getGender() == RelLib.Person.female:
gender = const.female
else:
gender = const.unknown
@ -507,5 +524,94 @@ class FamilyView:
Utils.modified()
self.load_family()
def child_list_reordered(self,path,iter):
print path,iter
def on_child_list_row_move(self,clist,fm,to):
"""Validate whether or not this child can be moved within the clist.
This routine is called in the middle of the clist's callbacks, so
the state can be confusing. If the code is being debugged, the
display at this point shows that the list has been reordered when in
actuality it hasn't. All accesses to the clist data structure
reference the state just prior to the move.
This routine must keep/compute its own list indices as the functions
list.remove(), list.insert(), list.reverse() etc. do not affect the
values returned from the list.index() routine."""
family = clist.get_data("f")
# Create a list based upon the current order of the clist
clist_order = []
for i in range(clist.rows):
clist_order = clist_order + [clist.get_row_data(i)]
child = clist_order[fm]
# This function deals with ascending order lists. Convert if
# necessary.
if (self.child_sort.sort_direction() == GTK.SORT_DESCENDING):
clist_order.reverse()
max_index = len(clist_order) - 1
fm = max_index - fm
to = max_index - to
# Create a new list to match the requested order
desired_order = clist_order[:fm] + clist_order[fm+1:]
desired_order = desired_order[:to] + [child] + desired_order[to:]
# Check birth date order in the new list
if (EditPerson.birth_dates_in_order(desired_order) == 0):
clist.emit_stop_by_name("row_move")
msg = _("Invalid move. Children must be ordered by birth date.")
WarningDialog(msg)
return
# OK, this birth order works too. Update the family data structures.
family.setChildList(desired_order)
# Build a mapping of child item to list position. This would not
# be necessary if indices worked properly
i = 0
new_order = {}
for tmp in desired_order:
new_order[tmp] = i
i = i + 1
# Convert the original list back to whatever ordering is being
# used by the clist itself.
if self.child_sort.sort_direction() == GTK.SORT_DESCENDING:
clist_order.reverse()
# Update the clist indices so any change of sorting works
i = 0
for tmp in clist_order:
clist.set_text(i,0,"%2d"%(new_order[tmp]+1))
i = i + 1
# Need to save the changed order
Utils.modified()
def drag_data_received(self,widget,context,x,y,sel_data,info,time):
row = self.child_list.get_row_at(x,y)
if sel_data and sel_data.data:
exec 'data = %s' % sel_data.data
exec 'mytype = "%s"' % data[0]
exec 'person = "%s"' % data[1]
if mytype != 'child':
return
elif person == self.person.getId():
print row
# self.move_element(self.elist,self.etree.get_selected_row(),row)
def drag_data_get(self,widget, context, sel_data, info, time):
ev = self.child_list.get_selected_objects()
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(ev[0]);
data = str(('child',self.person.getId(),pickled));
sel_data.set(sel_data.target, bits_per, data)
def drag_begin(self, context, a):
return

View File

@ -85,7 +85,7 @@ class FrenchRepublic(Calendar.Calendar):
try:
return FrenchRepublic.M2NUM[val]
except KeyError:
return UNDEF
return Calendar.UNDEF
def get_sdn(self,y,m,d):
"""Converts a French Republican Calendar date to an SDN number"""

View File

@ -48,9 +48,10 @@ import gtk
#
#-------------------------------------------------------------------------
import const
from RelLib import *
import RelLib
import Date
from intl import gettext as _
from Utils import for_each_ancestor
#-------------------------------------------------------------------------
#
@ -151,7 +152,7 @@ class IsFemale(Rule):
return 'Is a female'
def apply(self,db,p):
return p.getGender() == Person.female
return p.getGender() == RelLib.Person.female
#-------------------------------------------------------------------------
#
@ -296,7 +297,7 @@ class IsMale(Rule):
return 'Is a male'
def apply(self,db,p):
return p.getGender() == Person.male
return p.getGender() == Person.Person.male
#-------------------------------------------------------------------------
#

View File

@ -24,7 +24,6 @@
# Standard python modules
#
#-------------------------------------------------------------------------
import string
import os
import PaperMenu
@ -40,14 +39,15 @@ import gobject
import gconf
import gtk
import gtk.glade
import gnome
#-------------------------------------------------------------------------
#
# gramps modules
#
#-------------------------------------------------------------------------
from RelLib import *
from Date import *
import RelLib
#from Date import *
import const
import Utils
@ -285,7 +285,7 @@ def loadConfig(call):
autocomp = not ac
Calendar.set_format_code(dateFormat)
Calendar.ENTRYCODE = dateEntry
Calendar.Calendar.ENTRYCODE = dateEntry
if _name_format == 0:
nameof = Utils.normal_name
@ -354,7 +354,7 @@ def get_researcher():
ph = get_string("/apps/gramps/researcher-phone")
e = get_string("/apps/gramps/researcher-email")
owner = Researcher()
owner = RelLib.Researcher()
owner.set(n,a,c,s,ct,p,ph,e)
return owner
@ -555,7 +555,6 @@ class GrampsPreferences:
vc = self.top.get_widget("use_vc")
vcom = self.top.get_widget("vc_comment")
compress = self.top.get_widget("uncompress")
detail = self.top.get_widget("showdetail")
auto.set_active(autoload)
asave_int.set_value(int(autosave_int))
@ -671,7 +670,7 @@ class GrampsPreferences:
item.connect("activate", self.on_format_toggled)
item.show()
date_menu.append(item)
date_menu.set_active(Calendar.ENTRYCODE)
date_menu.set_active(Calendar.Calendar.ENTRYCODE)
date_entry.set_menu(date_menu)
name_option = self.top.get_widget("name_format")
@ -912,7 +911,7 @@ class GrampsPreferences:
format_menu = self.top.get_widget("date_entry_format").get_menu()
entry_active = format_menu.get_active().get_data(INDEX)
Calendar.ENTRYCODE = entry_active
Calendar.Calendar.ENTRYCODE = entry_active
set_int("/apps/gramps/date-entry",entry_active)
# get the name format

View File

@ -18,8 +18,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
from RelLib import *
from Date import SingleDate
import RelLib
import Date
import string
import Calendar
@ -93,7 +93,7 @@ class GrampsParser:
self.event = None
self.name = None
self.tempDefault = None
self.owner = Researcher()
self.owner = RelLib.Researcher()
self.func_list = [None]*50
self.func_index = 0
self.func = None
@ -114,7 +114,7 @@ class GrampsParser:
def start_lds_ord(self,attrs):
type = attrs['type']
self.ord = LdsOrd()
self.ord = RelLib.LdsOrd()
if self.person:
if type == "baptism":
self.person.setLdsBaptism(self.ord)
@ -158,7 +158,7 @@ class GrampsParser:
"""Bypass the function calls for this one, since it appears to
take up quite a bit of time"""
loc = Location()
loc = RelLib.Location()
if attrs.has_key('city'):
loc.city = attrs['city']
if attrs.has_key('parish'):
@ -182,7 +182,7 @@ class GrampsParser:
self.placeobj.set_longitude(attrs['long'])
def start_event(self,attrs):
self.event = Event()
self.event = RelLib.Event()
self.event_type = attrs["type"]
if attrs.has_key("conf"):
self.event.conf = int(attrs["conf"])
@ -192,7 +192,7 @@ class GrampsParser:
self.event.private = int(attrs["priv"])
def start_attribute(self,attrs):
self.attribute = Attribute()
self.attribute = RelLib.Attribute()
if attrs.has_key("conf"):
self.attribute.conf = int(attrs["conf"])
else:
@ -215,7 +215,7 @@ class GrampsParser:
self.family.addAttribute(self.attribute)
def start_address(self,attrs):
self.address = Address()
self.address = RelLib.Address()
self.person.addAddress(self.address)
if attrs.has_key("conf"):
self.address.conf = int(attrs["conf"])
@ -257,7 +257,7 @@ class GrampsParser:
desc = ""
try:
url = Url()
url = RelLib.Url()
url.set_path(attrs["href"])
url.set_description(desc)
if attrs.has_key("priv"):
@ -295,7 +295,7 @@ class GrampsParser:
self.person.FamilyList.append(self.db.findFamilyNoMap(attrs["ref"]))
def start_name(self,attrs):
self.name = Name()
self.name = RelLib.Name()
if attrs.has_key("type"):
self.name.setType(attrs["type"])
if attrs.has_key("conf"):
@ -313,7 +313,7 @@ class GrampsParser:
self.in_note = 1
def start_sourceref(self,attrs):
self.source_ref = SourceRef()
self.source_ref = RelLib.SourceRef()
source = self.db.findSourceNoMap(attrs["ref"])
if attrs.has_key("conf"):
self.source_ref.confidence = int(attrs["conf"])
@ -345,7 +345,7 @@ class GrampsParser:
self.source = self.db.findSourceNoMap(attrs["id"])
def start_objref(self,attrs):
self.objref = ObjectRef()
self.objref = RelLib.ObjectRef()
self.objref.setReference(self.db.findObjectNoMap(attrs['ref']))
if attrs.has_key('priv'):
self.objref.setPrivacy(int(attrs['priv']))
@ -378,8 +378,8 @@ class GrampsParser:
self.objref = None
def start_photo(self,attrs):
self.photo = Photo()
self.pref = ObjectRef()
self.photo = RelLib.Photo()
self.pref = RelLib.ObjectRef()
self.pref.setReference(self.photo)
for key in attrs.keys():
@ -396,7 +396,7 @@ class GrampsParser:
self.photo.setPath(src)
self.photo.setLocal(0)
else:
a = Attribute()
a = RelLib.Attribute()
a.setType(key)
a.setValue(attrs[key])
self.photo.addAttribute(a)
@ -531,7 +531,7 @@ class GrampsParser:
if self.place_map.has_key(tag):
self.placeobj = self.place_map[tag]
else:
self.placeobj = Place()
self.placeobj = RelLib.Place()
self.placeobj.set_title(tag)
self.db.addPlace(self.placeobj)
self.place_map[tag] = self.placeobj
@ -571,11 +571,11 @@ class GrampsParser:
def stop_gender(self,tag):
t = tag
if t == "M":
self.person.gender = Person.male
self.person.gender = RelLib.Person.male
elif t == "F":
self.person.gender = Person.female
self.person.gender = RelLib.Person.female
else:
self.person.gender = Person.unknown
self.person.gender = RelLib.Person.unknown
def stop_stitle(self,tag):
self.source.setTitle(tag)
@ -591,7 +591,7 @@ class GrampsParser:
self.source.setAuthor(tag)
def stop_sdate(self,tag):
date = Date()
date = Date.Date()
date.set(tag)
self.source_ref.setDate(date)
@ -874,7 +874,7 @@ class GrampsImportParser(GrampsParser):
self.family.setRelationship(attrs["type"])
def start_sourceref(self,attrs):
self.source_ref = SourceRef()
self.source_ref = RelLib.SourceRef()
self.source = self.db.findSource(attrs["ref"],self.smap)
self.source_ref.setBase(self.source)
if self.address:

View File

@ -18,12 +18,12 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
from RelLib import GrampsDB
import RelLib
import WriteXML
import ReadXML
import const
class GrampsXML(GrampsDB):
class GrampsXML(RelLib.GrampsDB):
def get_base(self):
return const.xmlFile
@ -32,7 +32,7 @@ class GrampsXML(GrampsDB):
return 'GrampsXML'
def new(self):
GrampsDB.new(self)
RelLib.GrampsDB.new(self)
def save(self,name,callback):
WriteXML.exportData(self,name,callback)

View File

@ -101,7 +101,7 @@ class Hebrew(Calendar.Calendar):
try:
return Hebrew.M2NUM[unicode(text.lower())]
except KeyError:
return UNDEF
return Calendar.UNDEF
def Tishri1(self,metonicYear, moladDay, moladHalakim):

View File

@ -26,13 +26,11 @@
import os
import string
import urlparse
import gc
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gobject
import gtk
import gnome.ui
import gnome.canvas
@ -47,13 +45,8 @@ import const
import Utils
import GrampsCfg
import Plugins
from RelLib import *
import RelLib
import RelImage
import EditPerson
import Marriage
import EditPlace
import EditSource
import ListModel
import grampslib
@ -157,13 +150,13 @@ class ImageSelect:
break
if (already_imported):
oref = ObjectRef()
oref = RelLib.ObjectRef()
oref.setReference(already_imported)
self.dataobj.addPhoto(oref)
self.add_thumbnail(oref)
else:
type = Utils.get_mime_type(filename)
mobj = Photo()
mobj = RelLib.Photo()
if description == "":
description = os.path.basename(filename)
mobj.setDescription(description)
@ -229,7 +222,6 @@ class Gallery(ImageSelect):
self.root = self.iconlist.root()
# Local object variables
x = 0
self.y = 0
self.remember_x = -1
self.remember_y = -1
@ -260,9 +252,9 @@ class Gallery(ImageSelect):
self.drag_item = widget.get_item_at(self.remember_x,
self.remember_y)
if self.drag_item:
context = widget.drag_begin(_drag_targets,
gtk.gdk.ACTION_COPY|gtk.gdk.ACTION_MOVE,
self.button, event)
widget.drag_begin(_drag_targets,
gtk.gdk.ACTION_COPY|gtk.gdk.ACTION_MOVE,
self.button, event)
return gtk.TRUE
style = self.iconlist.get_style()
@ -321,7 +313,7 @@ class Gallery(ImageSelect):
def savephoto(self, photo):
"""Save the photo in the dataobj object. (Required function)"""
self.db.addObject(photo)
oref = ObjectRef()
oref = RelLib.ObjectRef()
oref.setReference(photo)
self.dataobj.addPhoto(oref)
self.add_thumbnail(oref)
@ -408,7 +400,7 @@ class Gallery(ImageSelect):
if protocol == "file":
name = file
mime = Utils.get_mime_type(name)
photo = Photo()
photo = RelLib.Photo()
photo.setPath(name)
photo.setMimeType(mime)
basename = os.path.basename(name)
@ -434,13 +426,13 @@ class Gallery(ImageSelect):
ErrorDialog("%s\n%s %d" % (t,msg[0],msg[1]))
return
mime = Utils.get_mime_type(tfile)
photo = Photo()
photo = RelLib.Photo()
photo.setMimeType(mime)
photo.setDescription(d)
photo.setLocal(1)
photo.setPath(tfile)
self.db.addObject(photo)
oref = ObjectRef()
oref = RelLib.ObjectRef()
oref.setReference(photo)
self.dataobj.addPhoto(oref)
try:
@ -482,7 +474,7 @@ class Gallery(ImageSelect):
self.load_images()
return
index = index + 1
oref = ObjectRef()
oref = RelLib.ObjectRef()
oref.setReference(self.db.findObjectNoMap(data.data))
self.dataobj.addPhoto(oref)
self.add_thumbnail(oref)

View File

@ -20,7 +20,6 @@
import os
import const
import string
#-------------------------------------------------------------------------
#
@ -44,8 +43,8 @@ class ImgManip:
if no_pil:
def size(self):
img = GdkImlib.Image(self.src)
return (img.rgb_width,img.rgb_height)
img = gtk.gdk.pixbuf_new_from_file(self.src)
return (img.get_width(),img.get_height())
def fmt_thumbnail(self,dest,width,height,cnv):
w = int(width)

View File

@ -182,3 +182,4 @@ class ListModel:
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
self.double_click(obj)
return 1
return 0

View File

@ -32,7 +32,7 @@ import gtk.glade
#-------------------------------------------------------------------------
import const
import Utils
from RelLib import *
import RelLib
from intl import gettext as _
@ -84,7 +84,7 @@ class LocationEditor:
parish = self.parish.get_text()
if self.location == None:
self.location = Location()
self.location = RelLib.Location()
self.parent.llist.append(self.location)
self.update_location(city,parish,county,state,country)

View File

@ -25,10 +25,8 @@ import pickle
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gobject
import gtk
import gtk.glade
import gnome.ui
#-------------------------------------------------------------------------
#
@ -41,11 +39,18 @@ import GrampsCfg
import Utils
import AutoComp
import ListModel
from QuestionDialog import QuestionDialog
from RelLib import *
import RelLib
import ImageSelect
import Date
from QuestionDialog import QuestionDialog, WarningDialog
from intl import gettext as _
#-------------------------------------------------------------------------
#
# Globals
#
#-------------------------------------------------------------------------
_temple_names = const.lds_temple_codes.keys()
_temple_names.sort()
_temple_names = [""] + _temple_names
@ -210,7 +215,7 @@ class Marriage:
import Sources
ord = self.family.getLdsSeal()
if ord == None:
ord = LdsOrd()
ord = RelLib.LdsOrd()
self.family.setLdsSeal(ord)
Sources.SourceSelector(ord.getSourceRefList(),self)
@ -218,7 +223,7 @@ class Marriage:
import NoteEdit
ord = self.family.getLdsSeal()
if ord == None:
ord = LdsOrd()
ord = RelLib.LdsOrd()
self.family.setLdsSeal(ord)
NoteEdit.NoteEditor(ord)
@ -360,9 +365,9 @@ class Marriage:
if date or temple or place or self.seal_stat:
changed = 1
else:
d = Date()
d = Date.Date()
d.set(date)
if compare_dates(d,ord.getDateObj()) != 0 or \
if Date.compare_dates(d,ord.getDateObj()) != 0 or \
ord.getTemple() != temple or \
ord.getPlace() != place or \
ord.getStatus() != self.seal_stat:
@ -401,7 +406,7 @@ class Marriage:
Utils.modified()
else:
msg1 = _("GRAMPS ID value was not changed.")
GnomeWarningDialog("%s" % msg1)
WarningDialog("%s" % msg1)
relation = self.type_field.entry.get_text()
father = self.family.getFather()
@ -414,8 +419,8 @@ class Marriage:
val = const.save_frel(relation)
if val == "Partners":
val = "Unknown"
if father.getGender() == Person.female or \
mother.getGender() == Person.male:
if father.getGender() == RelLib.Person.female or \
mother.getGender() == RelLib.Person.male:
self.family.setFather(mother)
self.family.setMother(father)
self.family.setRelationship(val)
@ -438,7 +443,7 @@ class Marriage:
ord = self.family.getLdsSeal()
if not ord:
if date or temple or place or self.seal_stat:
ord = LdsOrd()
ord = RelLib.LdsOrd()
ord.setDate(date)
ord.setTemple(temple)
ord.setStatus(self.seal_stat)
@ -446,9 +451,9 @@ class Marriage:
self.family.setLdsSeal(ord)
Utils.modified()
else:
d = Date()
d = Date.Date()
d.set(date)
if compare_dates(d,ord.getDateObj()) != 0:
if Date.compare_dates(d,ord.getDateObj()) != 0:
ord.setDateObj(d)
Utils.modified()
if ord.getTemple() != temple:

View File

@ -24,6 +24,7 @@
#
#-------------------------------------------------------------------------
import string
import os
#-------------------------------------------------------------------------
#
@ -34,21 +35,20 @@ import gobject
import gtk
import gtk.gdk
import ImageSelect
#-------------------------------------------------------------------------
#
# gramps modules
#
#-------------------------------------------------------------------------
from RelLib import *
from QuestionDialog import QuestionDialog, ErrorDialog
import RelLib
import Utils
import os
import GrampsCfg
import const
import ImageSelect
import RelImage
from QuestionDialog import QuestionDialog, ErrorDialog
#-------------------------------------------------------------------------
#
# internationalization
@ -187,7 +187,7 @@ class MediaView:
def popup_convert_to_private(self, obj):
path = self.db.getSavePath()
id = self.obj.getId()
name = RelImage.import_object(self.obj.getPath(),path,id)
name = RelImage.import_media_object(self.obj.getPath(),path,id)
if name:
self.obj.setPath(name)
self.obj.setLocal(1)
@ -302,7 +302,7 @@ class MediaView:
if protocol == "file":
name = file
mime = Utils.get_mime_type(name)
photo = Photo()
photo = RelLib.Photo()
photo.setPath(name)
photo.setMimeType(mime)
description = os.path.basename(name)
@ -332,13 +332,13 @@ class MediaView:
ErrorDialog("%s\n%s %d" % (t,msg[0],msg[1]))
return
mime = Utils.get_mime_type(tfile)
photo = Photo()
photo = RelLib.Photo()
photo.setMimeType(mime)
photo.setDescription(d)
photo.setLocal(1)
photo.setPath(tfile)
self.db.addObject(photo)
oref = ObjectRef()
oref = RelLib.ObjectRef()
oref.setReference(photo)
try:
id = photo.getId()

View File

@ -34,7 +34,7 @@ import const
import Utils
import AutoComp
import Sources
from RelLib import *
import RelLib
from intl import gettext as _
@ -114,7 +114,7 @@ class NameEditor:
type = "Also Known As"
if self.name == None:
self.name = Name()
self.name = RelLib.Name()
self.parent.nlist.append(self.name)
self.name.setSourceRefList(self.srcreflist)

View File

@ -24,7 +24,6 @@
#
#-------------------------------------------------------------------------
import gtk
import gnome.ui
#-------------------------------------------------------------------------
#

View File

@ -348,100 +348,6 @@ class PedigreeView:
y*19.0, y*21.0, y*23.0, y*25.0, y*27.0, y*29.0, y*31.0 ]
return map(lambda coord, top_pad=top_pad: coord + top_pad, res)
def add_box(self, x, y, bwidth, bheight, person, style):
"""Draw a box of the specified size at the specified location.
The box consists of a shadow box for effect, the real box
that contains the information, and the basic text
information. For convience, the all the subelements are
grouped into a GNOME canvas group."""
shadow = _PAD
xpad = _PAD
name = person.getPrimaryName().getName()
group = self.root.add(gnome.canvas.CanvasGroup,x=x,y=y)
self.canvas_items.append(group)
# draw the shadow box
item = group.add(gnome.canvas.CanvasRect, x1=shadow, y1=shadow,
x2=bwidth+shadow, y2=bheight+shadow,
outline_color_gdk=style.dark[gtk.STATE_NORMAL],
fill_color_gdk=style.dark[gtk.STATE_NORMAL])
self.canvas_items.append(item)
# draw the real box
item = group.add(gnome.canvas.CanvasRect, x1=0, y1=0, x2=bwidth, y2=bheight,
outline_color_gdk=style.bg[gtk.STATE_NORMAL],
fill_color_gdk=style.white)
self.canvas_items.append(item)
# Write the text
font = gtk.gdk.font_from_description(style.font_desc)
item = group.add(gnome.canvas.CanvasText, x=xpad, y=bheight/2.0, text=name,
fill_color_gdk=style.text[gtk.STATE_NORMAL],
font=font, anchor=gtk.ANCHOR_WEST)
self.canvas_items.append(item)
group.connect('event',self.box_event)
group.set_data('p',person)
def box_event(self,obj,event):
"""Handle events over a drawn box. Doubleclick would edit,
shift doubleclick would change the active person, entering
the box expands it to display more information, leaving a
box returns it to the original size and information"""
if event.type == gtk.gdk._2BUTTON_PRESS:
# if event.button == 1:
# person = obj.get_data(_PERSON)
# if (event.state & gtk.gdk.SHIFT_MASK) or (event.state & gtk.gdk.CONTROL_MASK):
# self.change_active_person(person)
# del self.presel_descendants[:]
# self.load_canvas(person)
# else:
# self.load_person(person)
return 1
elif event.type == gtk.gdk.ENTER_NOTIFY:
self.expand_box(obj)
return 0
elif event.type == gtk.gdk.LEAVE_NOTIFY:
self.shrink_box(obj)
return 0
return 0
def shrink_box(self,obj):
"""Shrink an exanded box back down to normal size"""
box = self.group_map[obj][1]
x,y,w,h = box.get_bounds()
box.set(x1=x,y1=y,x2=w,y2=h/3)
box2 = self.group_map[obj][2]
x,y,w,h1 = box2.get_bounds()
person = obj.get_data('p')
n = person.getPrimaryName().getName()
box2.set(text=n)
self.update()
self.canvas.update_now()
def expand_box(self,obj):
"""Expand a box to include additional information"""
obj.raise_to_top()
x,y,w,h = box.get_bounds()
box.set(x1=x,y1=y,x2=w,y2=h*3)
box2 = self.group_map[obj][0]
x,y,w,h1 = box2.get_bounds()
box2.set(x1=x,y1=y,x2=w,y2=(3*h)+_PAD)
person = obj.get_data('p')
color = self.canvas.get_style().text[gtk.STATE_NORMAL]
n = "%s\nb. %s.\nd. %s" % (person.getPrimaryName().getName(),
person.getBirth().getDate(),
person.getDeath().getDate())
box2 = self.group_map[obj][2]
box2.set(text=n)
box2.show()
msg = _("Doubleclick to edit, Shift-Doubleclick to make the active person")
self.sb.set_status(msg)
def line_event(self,obj,event):
"""Catch X events over a line and respond to the ones we care about"""
@ -461,18 +367,6 @@ class PedigreeView:
obj.set(fill_color_gdk=style.black, width_pixels=2)
self.update()
def on_canvas1_event(self,obj,event):
"""Handle resize events over the canvas, redrawing if the size changes"""
if event.type == gtk.gdk.EXPOSE:
x1,y1,x2,y2 = self.canvas.get_allocation()
if self.x1 != x1 or self.x2 != x2 or \
self.y1 != y1 or self.y2 != y2:
self.x1 = x1; self.x2 = x2
self.y1 = y1; self.y2 = y2
self.load_canvas(self.active_person)
return 0
def find_tree(self,person,index,depth,list,val=0):
"""Recursively build a list of ancestors"""
@ -492,3 +386,14 @@ class PedigreeView:
if mother != None:
self.find_tree(mother,(2*index)+2,depth+1,list,mrel)
def on_canvas1_event(self,obj,event):
"""Handle resize events over the canvas, redrawing if the size changes"""
if event.type == gtk.gdk.EXPOSE:
x1,y1,x2,y2 = self.canvas.get_allocation()
if self.x1 != x1 or self.x2 != x2 or \
self.y1 != y1 or self.y2 != y2:
self.x1 = x1; self.x2 = x2
self.y1 = y1; self.y2 = y2
self.load_canvas(self.active_person)
return 0

View File

@ -36,13 +36,11 @@ import gtk.gdk
# Gramps modules
#
#-------------------------------------------------------------------------
from RelLib import *
from QuestionDialog import QuestionDialog, ErrorDialog
import RelLib
import EditPlace
import Utils
import GrampsCfg
from QuestionDialog import QuestionDialog, ErrorDialog
from intl import gettext as _
_column_headers = [
@ -147,6 +145,7 @@ class PlaceView:
if mlist:
EditPlace.EditPlace(self,mlist[0],self.update_display)
return 1
return 0
def new_place_after_edit(self,place):
self.db.addPlace(place)
@ -158,7 +157,7 @@ class PlaceView:
self.update(0)
def on_add_place_clicked(self,obj):
EditPlace.EditPlace(self,Place(),self.new_place_after_edit)
EditPlace.EditPlace(self,RelLib.Place(),self.new_place_after_edit)
def on_delete_clicked(self,obj):
mlist = []

View File

@ -167,12 +167,12 @@ class PluginDialog:
xpm = data[3]
status = data[4]
st = string.join(xpm,'\n')
# image = gtk.gdk.pixbuf_new_from_inline(len(st),st,0)
#st = string.join(xpm,'\n')
#image = gtk.gdk.pixbuf_new_from_inline(len(st),st,0)
self.description.set_text(doc)
self.status.set_text(": %s" % status)
self.label.show()
# self.img.set_from_pixbuf(image)
#self.img.set_from_pixbuf(image)
self.title.set_text(title)
self.dialog.get_widget("title").set_text(title)

View File

@ -19,7 +19,6 @@
#
import gtk
import gnome.ui
from intl import gettext as _
class QuestionDialog:

View File

@ -26,19 +26,12 @@
import string
import os
#-------------------------------------------------------------------------
#
# Gnome/GTK
#
#-------------------------------------------------------------------------
import gnome.ui
#-------------------------------------------------------------------------
#
# Gramps Modules
#
#-------------------------------------------------------------------------
from RelLib import *
import RelLib
from GrampsParser import GrampsParser, GrampsImportParser
from QuestionDialog import ErrorDialog, WarningDialog
from intl import gettext as _

View File

@ -32,7 +32,7 @@ import string
#
#-------------------------------------------------------------------------
import gtk
from QuestionDialog import ErrorDialog
from QuestionDialog import ErrorDialog, WarningDialog
#-------------------------------------------------------------------------
#
@ -105,7 +105,7 @@ def scale_image(path,size):
try:
image1 = gtk.gdk.pixbuf_new_from_file(path)
except:
GnomeWarningDialog(_("Could not load image file %s") % path)
WarningDialog(_("Could not load image file %s") % path)
return gtk.gdk.pixbuf_new_from_file(const.icon)
width = image1.get_width()
@ -116,7 +116,7 @@ def scale_image(path,size):
image1.scale_simple(int(scale*width), int(scale*height), gtk.gdk.INTERP_BILINEAR)
return image1
except:
GnomeWarningDialog(_("Could not load image file %s") % path)
WarningDialog(_("Could not load image file %s") % path)
return gtk.gdk.pixbuf_new_from_file(const.icon)
#-------------------------------------------------------------------------

View File

@ -30,7 +30,6 @@ from intl import gettext as _
# standard python modules
#
#-------------------------------------------------------------------------
import string
#-------------------------------------------------------------------------
#
@ -44,13 +43,9 @@ import gtk.glade
# gramps modules
#
#-------------------------------------------------------------------------
from RelLib import *
import RelLib
import const
import sort
import Utils
import GrampsCfg
import AutoComp
import ListModel
#-------------------------------------------------------------------------
@ -96,7 +91,7 @@ class SelectChild:
fname = self.person.getPrimaryName().getName()
label = _("Relationship to %s") % fname
if self.person.getGender() == Person.male:
if self.person.getGender() == RelLib.Person.male:
self.xml.get_widget("flabel").set_text(label)
self.xml.get_widget("mrel_combo").set_sensitive(0)
else:
@ -118,8 +113,6 @@ class SelectChild:
def redraw_child_list(self,filter):
self.refmodel.clear()
index = 0
bday = self.person.getBirth().getDateObj()
dday = self.person.getDeath().getDateObj()
@ -187,7 +180,7 @@ class SelectChild:
if self.family == None:
self.family = self.db.newFamily()
self.person.addFamily(self.family)
if self.person.getGender() == Person.male:
if self.person.getGender() == RelLib.Person.male:
self.family.setFather(self.person)
else:
self.family.setMother(self.person)
@ -196,13 +189,13 @@ class SelectChild:
mrel = const.childRelations[self.mrel.get_text()]
mother = self.family.getMother()
if mother and mother.getGender() != Person.female:
if mother and mother.getGender() != RelLib.Person.female:
if mrel == "Birth":
mrel = "Unknown"
frel = const.childRelations[self.frel.get_text()]
father = self.family.getFather()
if father and father.getGender() != Person.male:
if father and father.getGender() !=RelLib. Person.male:
if frel == "Birth":
frel = "Unknown"

View File

@ -38,12 +38,11 @@ import gtk.gdk
# gramps modules
#
#-------------------------------------------------------------------------
from RelLib import *
from QuestionDialog import QuestionDialog
import RelLib
import EditSource
import Utils
import GrampsCfg
from QuestionDialog import QuestionDialog
#-------------------------------------------------------------------------
#
@ -109,9 +108,10 @@ class SourceView:
source = self.db.getSource(id)
EditSource.EditSource(source,self.db,self.update_display)
return 1
return 0
def on_add_clicked(self,obj):
EditSource.EditSource(Source(),self.db,self.new_after_edit)
EditSource.EditSource(RelLib.Source(),self.db,self.new_after_edit)
def on_delete_clicked(self,obj):

View File

@ -34,7 +34,7 @@ import gtk.glade
#-------------------------------------------------------------------------
import const
import Utils
from RelLib import *
import RelLib
from intl import gettext as _
#-------------------------------------------------------------------------
@ -50,7 +50,7 @@ class SourceSelector:
self.orig = srclist
self.list = []
for s in self.orig:
self.list.append(SourceRef(s))
self.list.append(RelLib.SourceRef(s))
self.update=update
self.top = gtk.glade.XML(const.srcselFile,"sourcesel")
self.top.signal_autoconnect({
@ -106,7 +106,7 @@ class SourceSelector:
inst.redraw()
def add_src_clicked(self,obj):
src = SourceRef()
src = RelLib.SourceRef()
SourceEditor(src,self.db,self.add_ref,self)
def del_src_clicked(self,obj):
@ -177,7 +177,7 @@ class SourceTab:
SourceEditor(src,self.db,self.update_clist,self)
def add_src_clicked(self,obj):
src = SourceRef()
src = RelLib.SourceRef()
SourceEditor(src,self.db,self.add_ref,self)
def add_ref(self,inst,ref):

View File

@ -20,7 +20,6 @@
import const
import gtk.glade
import gnome
import gconf
import Utils
@ -75,18 +74,18 @@ class StartupDialog:
dateFormat = 1
else:
dateFormat = 2
self.client_set_int("/gramps/config/dateEntry",dateFormat)
self.client.set_int("/gramps/config/dateEntry",dateFormat)
showcal = self.druid.get_widget("altcal").get_active()
self.client_set_int("/gramps/config/ShowCalendar",showcal)
self.client.set_int("/gramps/config/ShowCalendar",showcal)
lds = self.druid.get_widget("enable_lds").get_active()
self.client_set_int("/gramps/config/UseLDS",lds)
self.client_set_int(_StartupEntry,const.startup)
self.client_sync()
self.client.set_int("/gramps/config/UseLDS",lds)
self.client.set_int(_StartupEntry,const.startup)
self.client.sync()
Utils.destroy_passed_object(obj)
def on_cancel_clicked(self,obj):
self.client_set_int(_StartupEntry,const.startup)
self.client_sync()
self.client.set_int(_StartupEntry,const.startup)
self.client.sync()
Utils.destroy_passed_object(obj)

View File

@ -30,7 +30,6 @@ __version__ = "$Revision$"
# GNOME/GTK modules
#
#------------------------------------------------------------------------
import gtk.glade
import gtk
#------------------------------------------------------------------------
@ -70,7 +69,7 @@ class StyleListDisplay:
"on_edit_clicked" : self.on_edit_clicked
})
self.list = ListModel.ListModel(self.top.get_widget("list"),[('Style',10,10)])
self.list = ListModel.ListModel(self.top.get_widget("list"),[('Style',-1,10)])
self.redraw()
def redraw(self):
@ -151,14 +150,15 @@ class StyleEditor:
self.top.signal_autoconnect({
"on_save_style_clicked" : self.on_save_style_clicked,
"fg_color_set":self.fg_color_set,
"bg_color_set":self.bg_color_set,
"destroy_passed_object" : Utils.destroy_passed_object
})
self.window = self.top.get_widget("editor")
self.pnames = self.top.get_widget("name")
self.top.get_widget('color').connect('color-set',self.fg_color_set)
self.top.get_widget('bgcolor').connect('color-set',self.bg_color_set)
self.top.get_widget("style_name").set_text(name)
myMenu = gtk.Menu()
first = 0
@ -202,16 +202,16 @@ class StyleEditor:
self.top.get_widget("lborder").set_active(p.get_left_border())
self.top.get_widget("rborder").set_active(p.get_right_border())
self.top.get_widget("bborder").set_active(p.get_bottom_border())
c = font.get_color()
self.top.get_widget("color").set_i8(c[0],c[1],c[2],0)
c = p.get_background_color()
self.top.get_widget("bgcolor").set_i8(c[0],c[1],c[2],0)
self.fg_color = font.get_color()
self.top.get_widget("color").set_i8(self.fg_color[0],self.fg_color[1],self.fg_color[2],0)
self.bg_color = p.get_background_color()
self.top.get_widget("bgcolor").set_i8(self.bg_color[0],self.bg_color[1],self.bg_color[2],0)
def bg_color_set(self,obj,r,g,b,a):
print r,g,b,a
def bg_color_set(self,x,r,g,b,a):
self.bg_color = (r >> 8, g >> 8, b >> 8)
def fg_color_set(self,obj,r,g,b,a):
print r,g,b,ax
def fg_color_set(self,x,r,g,b,a):
self.fg_color = (r >> 8, g >> 8, b >> 8)
def save_paragraph(self,p):
"""Saves the current paragraph displayed on the dialog"""
@ -244,10 +244,8 @@ class StyleEditor:
p.set_right_border(self.top.get_widget("rborder").get_active())
p.set_bottom_border(self.top.get_widget("bborder").get_active())
c = fg.get_i8()
font.set_color((c[0],c[1],c[2]))
c = bg.get_i8()
p.set_background_color((c[0],c[1],c[2]))
font.set_color(self.fg_color)
p.set_background_color(self.bg_color)
def on_save_style_clicked(self,obj):
"""

View File

@ -32,7 +32,7 @@ import gtk.glade
#-------------------------------------------------------------------------
import const
import Utils
from RelLib import *
import RelLib
#-------------------------------------------------------------------------
#
@ -68,7 +68,7 @@ class UrlEditor:
priv = self.priv.get_active()
if self.url == None:
self.url = Url()
self.url = RelLib.Url()
self.parent.ulist.append(self.url)
self.update_url(des,addr,priv)

View File

@ -554,3 +554,36 @@ def build_columns(tree,list):
column.set_visible(gtk.FALSE)
cnum = cnum + 1
tree.append_column(column)
#-------------------------------------------------------------------------
#
# Iterate over ancestors.
#
#-------------------------------------------------------------------------
def for_each_ancestor(start, func, data):
"""
Recursively iterate (breadth-first) over ancestors of
people listed in start.
Call func(data,pid) for the Id of each person encountered.
Exit and return 1, as soon as func returns true.
Return 0 otherwise.
"""
todo = start
doneIds = {}
while len(todo):
p = todo.pop()
pid = p.getId()
# Don't process the same Id twice. This can happen
# if there is a cycle in the database, or if the
# initial list contains X and some of X's ancestors.
if doneIds.has_key(pid):
continue
doneIds[pid] = 1
if func(data,pid):
return 1
for fam, mrel, frel in p.getParentList():
f = fam.getFather()
m = fam.getMother()
if f: todo.append(f)
if m: todo.append(m)
return 0

View File

@ -40,6 +40,7 @@ import os
import const
import GrampsCfg
import Calendar
import Gregorian
from RelLib import *
from intl import gettext as _
from QuestionDialog import ErrorDialog
@ -455,7 +456,7 @@ class XmlWriter:
return
name = date.get_calendar().NAME
if name != Calendar.Gregorian.NAME:
if name != Gregorian.Gregorian.NAME:
calstr = ' cformat="%s"' % name
else:
calstr = ''

View File

@ -1,5 +1,6 @@
import cStringIO
s0 = {
_s0 = {
0xA1 : u'\x01\x41', 0xA2 : u'\xD8', 0xA3 : u'\x01\x10',
0xA4 : u'\xDE', 0xA5 : u'\xC6', 0xA6 : u'\x01\x52',
0xA7 : u'\x02\xB9', 0xA8 : u'\xB7', 0xA9 : u'\x26\x6D',

View File

@ -28,6 +28,13 @@ web site at http://www.scottlee.com
__author__ = "Donald N. Allingham"
__version__ = "$Revision$"
#-------------------------------------------------------------------------
#
# python modules
#
#-------------------------------------------------------------------------
import math
#-------------------------------------------------------------------------
#
# Gramps Modules
@ -69,7 +76,7 @@ class Islamic(Calendar.Calendar):
try:
return Islamic.M2NUM[unicode(text.lower())]
except KeyError:
return UNDEF
return Calendar.UNDEF
def month(self,val):
try:

View File

@ -28,6 +28,13 @@ web site at http://www.scottlee.com
__author__ = "Donald N. Allingham"
__version__ = "$Revision$"
#-------------------------------------------------------------------------
#
# python modules
#
#-------------------------------------------------------------------------
import math
#-------------------------------------------------------------------------
#
# Gramps Modules
@ -67,7 +74,7 @@ class Persian(Calendar.Calendar):
try:
return Persian.M2NUM[unicode(text.lower())]
except KeyError:
return UNDEF
return Calendar.UNDEF
def month(self,val):
try:

View File

@ -922,70 +922,6 @@ class Gramps:
self.status_text(name)
return 0
def on_child_list_row_move(self,clist,fm,to):
"""Validate whether or not this child can be moved within the clist.
This routine is called in the middle of the clist's callbacks, so
the state can be confusing. If the code is being debugged, the
display at this point shows that the list has been reordered when in
actuality it hasn't. All accesses to the clist data structure
reference the state just prior to the move.
This routine must keep/compute its own list indices as the functions
list.remove(), list.insert(), list.reverse() etc. do not affect the
values returned from the list.index() routine."""
family = clist.get_data("f")
# Create a list based upon the current order of the clist
clist_order = []
for i in range(clist.rows):
clist_order = clist_order + [clist.get_row_data(i)]
child = clist_order[fm]
# This function deals with ascending order lists. Convert if
# necessary.
if (self.child_sort.sort_direction() == GTK.SORT_DESCENDING):
clist_order.reverse()
max_index = len(clist_order) - 1
fm = max_index - fm
to = max_index - to
# Create a new list to match the requested order
desired_order = clist_order[:fm] + clist_order[fm+1:]
desired_order = desired_order[:to] + [child] + desired_order[to:]
# Check birth date order in the new list
if (EditPerson.birth_dates_in_order(desired_order) == 0):
clist.emit_stop_by_name("row_move")
msg = _("Invalid move. Children must be ordered by birth date.")
WarningDialog(msg)
return
# OK, this birth order works too. Update the family data structures.
family.setChildList(desired_order)
# Build a mapping of child item to list position. This would not
# be necessary if indices worked properly
i = 0
new_order = {}
for tmp in desired_order:
new_order[tmp] = i
i = i + 1
# Convert the original list back to whatever ordering is being
# used by the clist itself.
if self.child_sort.sort_direction() == GTK.SORT_DESCENDING:
clist_order.reverse()
# Update the clist indices so any change of sorting works
i = 0
for tmp in clist_order:
clist.set_text(i,0,"%2d"%(new_order[tmp]+1))
i = i + 1
# Need to save the changed order
Utils.modified()
def on_open_activate(self,obj):
wFs = gtk.glade.XML(const.revisionFile, "dbopen")
wFs.signal_autoconnect({

View File

@ -90,7 +90,11 @@ class GraphVizDialog(ReportDialog):
ans.set_name(_("Ancestors of %s") % name)
ans.add_rule(GenericFilter.IsAncestorOf([self.person.getId()]))
return [all,des,ans]
com = GenericFilter.GenericFilter()
com.set_name(_("People with common ancestor with %s") % name)
com.add_rule(GenericFilter.HasCommonAncestorWith([self.person.getId()]))
return [all,des,ans,com]
def add_user_options(self):
self.arrowstyle_optionmenu = gtk.OptionMenu()
@ -162,13 +166,21 @@ class GraphVizDialog(ReportDialog):
_("Non-birth relationships will show up "
"as dashed lines in the graph."))
self.show_families_cb = gtk.CheckButton(_("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.Adjustment(value=0.5, lower=0.25,
upper=100.0, step_incr=0.25)
lr_margin_adj = gtk.Adjustment(value=0.5, lower=0.25,
upper=100.0, step_incr=0.25)
self.tb_margin_sb = gtk.SpinButton(adj=tb_margin_adj, digits=2)
self.lr_margin_sb = gtk.SpinButton(adj=lr_margin_adj, digits=2)
self.tb_margin_sb = gtk.SpinButton(adjustment=tb_margin_adj, digits=2)
self.lr_margin_sb = gtk.SpinButton(adjustment=lr_margin_adj, digits=2)
self.add_frame_option(_("GraphViz Options"),
_("Top & Bottom Margins"),
@ -180,8 +192,8 @@ class GraphVizDialog(ReportDialog):
hpages_adj = gtk.Adjustment(value=1, lower=1, upper=25, step_incr=1)
vpages_adj = gtk.Adjustment(value=1, lower=1, upper=25, step_incr=1)
self.hpages_sb = gtk.SpinButton(adj=hpages_adj, digits=0)
self.vpages_sb = gtk.SpinButton(adj=vpages_adj, digits=0)
self.hpages_sb = gtk.SpinButton(adjustment=hpages_adj, digits=0)
self.vpages_sb = gtk.SpinButton(adjustment=vpages_adj, digits=0)
self.add_frame_option(_("GraphViz Options"),
_("Number of Horizontal Pages"),
@ -239,12 +251,13 @@ class GraphVizDialog(ReportDialog):
self.arrowheadstyle, self.arrowtailstyle = menu.get_active().get_data('t')
self.includedates = self.includedates_cb.get_active()
self.includeurl = self.includeurl_cb.get_active()
self.tb_margin = self.tb_margin_sb.get_value_as_float()
self.lr_margin = self.lr_margin_sb.get_value_as_float()
self.tb_margin = self.tb_margin_sb.get_value()
self.lr_margin = self.lr_margin_sb.get_value()
self.colorize = self.colorize_cb.get_active()
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()
#------------------------------------------------------------------------
#
@ -258,12 +271,13 @@ class GraphVizDialog(ReportDialog):
file = open(self.target_path,"w")
ind_list = self.filter.apply(self.db.getPersonMap().values())
ind_list = self.filter.apply(self.db, self.db.getPersonMap().values())
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)
#------------------------------------------------------------------------
#
@ -280,23 +294,26 @@ def report(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()
@ -306,40 +323,67 @@ def write_dot(file, ind_list, orien, width, height, tb_margin,
#
#
#------------------------------------------------------------------------
def dump_person(person_list,file,adoptionsdashed,arrowheadstyle,arrowtailstyle):
def dump_person(person_list,file,adoptionsdashed,arrowheadstyle,
arrowtailstyle,show_families):
# Hash people in a dictionary for faster inclusion checking.
person_dict = {}
for p in person_list:
person_dict[p] = 1
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 and (person_dict.has_key(father) or
person_dict.has_key(mother)):
# 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 person_dict.has_key(father):
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 person_dict.has_key(mother):
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:
@ -364,6 +408,21 @@ 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')
#------------------------------------------------------------------------
#

View File

@ -38,7 +38,6 @@ import time
#-------------------------------------------------------------------------
import gtk
import gtk.glade
import gnome.ui
#-------------------------------------------------------------------------
#
@ -46,9 +45,12 @@ import gnome.ui
#
#-------------------------------------------------------------------------
from RelLib import *
import Julian
import FrenchRepublic
import Hebrew
import Date
from ansel_utf8 import ansel_to_utf8
import latin_utf8
import Utils
from GedcomInfo import *
@ -1569,11 +1571,11 @@ class GedcomParser:
pass
if cal1 == "FRENCH R":
dateobj.set_calendar(Date.FRENCH)
dateobj.set_calendar(FrenchRepublic.FrenchRepublic)
elif cal1 == "JULIAN":
dateobj.set_calendar(Date.JULIAN)
dateobj.set_calendar(Julian.Julian)
elif cal1 == "HEBREW":
dateobj.set_calendar(Date.HEBREW)
dateobj.set_calendar(Hebrew.Hebrew)
dateobj.get_start_date().set(data1)
dateobj.get_stop_date().set(data2)
dateobj.set_range(1)
@ -1583,11 +1585,11 @@ class GedcomParser:
if match:
(abt,cal,data) = match.groups()
if cal == "FRENCH R":
dateobj.set_calendar(Date.FRENCH)
dateobj.set_calendar(FrenchRepublic.FrenchRepublic)
elif cal == "JULIAN":
dateobj.set_calendar(Date.JULIAN)
dateobj.set_calendar(Julian.Julian)
elif cal == "HEBREW":
dateobj.set_calendar(Date.HEBREW)
dateobj.set_calendar(Hebrew.Hebrew)
dateobj.set(data)
if abt:
dateobj.get_start_date().setMode(abt)
@ -1615,7 +1617,6 @@ class GedcomParser:
def resolve_refns(self):
prefix = self.db.iprefix
renamed = []
index = 0
new_pmax = self.db.pmapIndex
pmap = self.db.getPersonMap()

View File

@ -50,6 +50,10 @@ import const
import Utils
import Date
import Calendar
import Julian
import Hebrew
import FrenchRepublic
from intl import gettext as _
from latin_utf8 import latin_to_utf8
from GedcomInfo import *
@ -66,7 +70,7 @@ except:
#-------------------------------------------------------------------------
_hmonth = [
"", "ELUL", "TSH", "CSH", "KSL", "TVT", "SHV", "ADR",
"ADS", "NSN", "IYR", "SVN", "TMZ", "AAV", "ELL" ]
_fmonth = [
@ -78,9 +82,9 @@ _month = [
"JUL", "AUG", "SEP", "OCT", "NOV", "DEC" ]
_calmap = {
Calendar.Hebrew : (_hmonth, '@#HEBREW@'),
Calendar.FrenchRepublic : (_fmonth, '@#FRENCH R@'),
Calendar.Julian : (_month, '@#JULIAN@'),
Hebrew.Hebrew.NAME : (_hmonth, '@#HEBREW@'),
FrenchRepublic.FrenchRepublic.NAME : (_fmonth, '@#FRENCH R@'),
Julian.Julian.NAME : (_month, '@#JULIAN@'),
}
_caldef = {
@ -201,14 +205,8 @@ def make_date(subdate):
mon_valid = subdate.getMonthValid()
year_valid = subdate.getYearValid()
# Adjust `mon' so it can be used as index in our _Xmonth arrays.
if mon_valid:
mon += 1
else:
mon = 0
if _calmap.has_key(subdate.calendar):
(mmap,prefix) = _calmap[subdate.calendar]
if _calmap.has_key(subdate.calendar.NAME):
(mmap,prefix) = _calmap[subdate.calendar.NAME]
else:
mmap = _month
prefix = ""
@ -780,7 +778,7 @@ class GedcomWriter:
text = addr_append(text,addr.getPostal())
text = addr_append(text,addr.getCountry())
if text:
self.g.write("2 PLAC %s\n" % string.replace(self.cnvtxt(text)),'\r',' ')
self.g.write("2 PLAC %s\n" % string.replace(self.cnvtxt(text),'\r',' '))
if addr.getNote():
self.write_long_text("NOTE",3,self.cnvtxt(addr.getNote()))
for srcref in addr.getSourceRefList():