scope fixes

svn: r1212
This commit is contained in:
Don Allingham 2002-11-28 05:52:02 +00:00
parent 3a2e952bb1
commit d92a1d98ff
16 changed files with 93 additions and 137 deletions

View File

@ -62,7 +62,7 @@ class AddSpouse:
family with the passed person as one spouse, and another person to
be selected.
"""
def __init__(self,db,person,update,addperson):
def __init__(self,db,person,update,addperson,family=None):
"""
Displays the AddSpouse dialog box.
@ -75,6 +75,7 @@ class AddSpouse:
self.update = update
self.person = person
self.addperson = addperson
self.active_family = family
self.glade = gtk.glade.XML(const.gladeFile, "spouseDialog")
@ -166,20 +167,21 @@ class AddSpouse:
return
Utils.modified()
family = self.db.newFamily()
self.person.addFamily(family)
spouse.addFamily(family)
if not self.active_family:
self.active_family = self.db.newFamily()
self.person.addFamily(self.active_family)
spouse.addFamily(self.active_family)
if self.person.getGender() == RelLib.Person.male:
family.setMother(spouse)
family.setFather(self.person)
self.active_family.setMother(spouse)
self.active_family.setFather(self.person)
else:
family.setFather(spouse)
family.setMother(self.person)
self.active_family.setFather(spouse)
self.active_family.setMother(self.person)
family.setRelationship(const.save_frel(self.relation_type.get_text()))
self.active_family.setRelationship(const.save_frel(self.relation_type.get_text()))
Utils.destroy_passed_object(obj)
self.update(family)
self.update(self.active_family)
def relation_type_changed(self,obj):
self.update_data()

View File

@ -130,7 +130,6 @@ class AttributeEditor:
self.attrib.setSourceRefList(self.srcreflist)
self.update(type,value,note,priv)
print self.parent
self.parent.redraw_attr_list()
Utils.destroy_passed_object(obj)

View File

@ -747,7 +747,8 @@ class EditPerson:
_("Are you sure you want to abandon your changes?"),
self.cancel_callback)
else:
Utils.destroy_passed_object(obj)
self.gallery.close()
self.window.destroy()
def on_delete_event(self,obj,b):
"""If the data has changed, give the user a chance to cancel
@ -758,12 +759,14 @@ class EditPerson:
self.cancel_callback)
return 1
else:
Utils.destroy_passed_object(obj)
self.gallery.close()
self.window.destroy()
return 0
def cancel_callback(self):
"""If the user answered yes to abandoning changes, close the window"""
Utils.destroy_passed_object(self.window)
self.gallery.close()
self.window.destroy()
def did_data_change(self):
"""Check to see if any of the data has changed from the
@ -1257,7 +1260,8 @@ class EditPerson:
self.update_lists()
if self.callback:
self.callback(self,self.add_places)
Utils.destroy_passed_object(obj)
self.gallery.close()
self.window.destroy()
def get_place(self,field,makenew=0):
text = string.strip(field.get_text())

View File

@ -136,7 +136,7 @@ class EditPlace:
self.note_buffer.set_text(place.getNote())
self.top_window.signal_autoconnect({
"destroy_passed_object" : Utils.destroy_passed_object,
"destroy_passed_object" : self.close,
"on_switch_page" : self.on_switch_page,
"on_addphoto_clicked" : self.glry.on_add_photo_clicked,
"on_deletephoto_clicked" : self.glry.on_delete_photo_clicked,
@ -174,6 +174,10 @@ class EditPlace:
self.redraw_url_list()
self.redraw_location_list()
def close(self):
self.glry.close()
self.top.close()
def build_columns(self,tree,list):
cnum = 0
for name in list:
@ -261,7 +265,7 @@ class EditPlace:
self.update_lists()
Utils.destroy_passed_object(self.top)
self.close(None)
if self.callback:
self.callback(self.place)

View File

@ -73,7 +73,7 @@ class EditSource:
self.notes_buffer.set_text(source.getNote())
self.top_window.signal_autoconnect({
"destroy_passed_object" : Utils.destroy_passed_object,
"destroy_passed_object" : self.close,
"on_switch_page" : self.on_switch_page,
"on_addphoto_clicked" : self.gallery.on_add_photo_clicked,
"on_deletephoto_clicked" : self.gallery.on_delete_photo_clicked,
@ -87,6 +87,10 @@ class EditSource:
self.top_window.get_widget("add_photo").set_sensitive(0)
self.top_window.get_widget("delete_photo").set_sensitive(0)
def close(self,obj):
self.gallery.close()
self.top.destroy()
def display_references(self):
p_event_list = []
p_attr_list = []
@ -197,7 +201,8 @@ class EditSource:
self.source.setNote(note)
Utils.modified()
Utils.destroy_passed_object(self.top)
self.close(None)
if self.callback:
self.callback(self.source)

View File

@ -83,6 +83,7 @@ class FamilyView:
self.spouse_list.set_model(self.spouse_model)
self.spouse_selection = self.spouse_list.get_selection()
self.spouse_selection.connect('changed',self.spouse_changed)
self.spouse_list.connect('button-press-event',self.edit_relationship)
self.top.get_widget('add_parents').connect('clicked',self.add_parents_clicked)
self.top.get_widget('del_parents').connect('clicked',self.del_parents_clicked)
@ -111,7 +112,6 @@ class FamilyView:
self.swap_btn.connect('clicked',self.spouse_swap)
self.remove_spouse_btn.connect('clicked',self.remove_spouse)
self.add_spouse_btn.connect('clicked',self.add_spouse)
self.spouse_list.connect('button-press-event',self.edit_releationship)
self.child_list.set_model(self.child_model)
self.child_list.set_search_column(0)
@ -137,12 +137,18 @@ class FamilyView:
row = model.get_path(iter)
self.display_marriage(self.person.getFamilyList()[row[0]])
def edit_releationship(self,obj,event):
def edit_relationship(self,obj,event):
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
if self.person:
try:
if self.selected_spouse:
Marriage.Marriage(self.family,self.parent.db,
self.parent.new_after_edit)
else:
AddSpouse.AddSpouse(self.parent.db,self.person,
self.load_family,
self.parent.redisplay_person_list,
self.family)
except:
DisplayTrace.DisplayTrace()
@ -182,9 +188,9 @@ class FamilyView:
if len(self.family.getChildList()) == 0:
if self.family.getFather() == None:
self.parent.delete_family_from(self.family.getMother())
self.delete_family_from(self.family.getMother())
elif self.family.getMother() == None:
self.parent.delete_family_from(self.family.getFather())
self.delete_family_from(self.family.getFather())
Utils.modified()
self.load_family()
@ -341,6 +347,15 @@ class FamilyView:
else:
return _("%s: unknown") % (l)
def delete_family_from(self,person):
person.removeFamily(self.family)
self.db.deleteFamily(self.family)
flist = self.person.getFamilyList()
if len(flist) > 0:
self.family = flist[0][0]
else:
self.family = None
def display_marriage(self,family):
self.child_model.clear()

View File

@ -26,7 +26,7 @@
import os
import string
import urlparse
import gc
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
@ -80,7 +80,6 @@ class ImageSelect:
self.dataobj = None
self.parent = parent
self.canvas_list = {}
self.item_map = {}
self.p_map = {}
def add_thumbnail(self, photo):
@ -218,7 +217,6 @@ class Gallery(ImageSelect):
icon_list.connect("drag_data_get",
self.on_photolist_drag_data_get)
icon_list.connect('destroy',self.unmap)
# Remember arguments
self.path = path;
self.dataobj = dataobj;
@ -226,7 +224,7 @@ class Gallery(ImageSelect):
self.root = self.iconlist.root()
# Local object variables
self.x = 0
x = 0
self.y = 0
self.remember_x = -1
self.remember_y = -1
@ -235,10 +233,14 @@ class Gallery(ImageSelect):
self.sel = None
self.photo = None
def unmap(self,obj):
for i in self.item_map.keys():
print i
i.destroy()
def close(self):
# self.iconlist.hide()
# print self.canvas_list
# print self.p_map
# self.canvas_list = None
# self.p_map = None
# gc.collect()
# self.iconlist.destroy()
def on_canvas1_event(self,obj,event):
"""Handle resize events over the canvas, redrawing if the size changes"""
@ -352,14 +354,8 @@ class Gallery(ImageSelect):
justification=gtk.JUSTIFY_CENTER,
y=_IMAGEY-10, text=description)
self.item_map[box] = oid
self.item_map[text] = oid
self.item_map[grp] = oid
self.item_map[item] = oid
for i in [ item, text, box, grp ] :
self.item_map[i] = oid
self.p_map[i] = (item,text,box,photo)
self.p_map[i] = (item,text,box,photo,oid)
i.show()
self.canvas_list[oid] = (grp,item,text,self.cx,self.cy)
@ -375,6 +371,7 @@ class Gallery(ImageSelect):
Imlibs. Then add each photo in the place's list of photos to the
photolist window."""
print "load images"
self.pos = 0
self.cx = _PAD
self.cy = _PAD
@ -491,8 +488,8 @@ class Gallery(ImageSelect):
def on_photolist_drag_data_get(self,w, context, selection_data, info, time):
if info == 1:
return
id = self.item_map[self.drag_item]
selection_data.set(selection_data.target, 8, id)
id = self.p_map[self.drag_item]
selection_data.set(selection_data.target, 8, id[4])
self.drag_item = None
def on_add_photo_clicked(self, obj):

View File

@ -186,7 +186,6 @@ class MergePeople:
else:
sname = GrampsCfg.nameof(spouse)
name = "%s [%s]" % (sname,spouse.getId())
print name, widget
widget.add([name])
def set_field(self,widget,value):

View File

@ -889,7 +889,9 @@ class ReportDialog:
self.report_menu = None
if self.extra_textbox:
self.report_text = string.split(self.extra_textbox.get_chars(0,-1),'\n')
b = self.extra_textbox.get_buffer()
text_val = b.get_text(b.get_start_iter(),b.get_end_iter(),gtk.FALSE)
self.report_text = string.split(text_val,'\n')
else:
self.report_text = ""

View File

@ -235,7 +235,6 @@ class SelectChild:
depending on the gender of the person."""
id = person.getId()
dinfo = self.db.getPersonDisplay(id)
print dinfo
rdata = [dinfo[0],dinfo[1],dinfo[3],dinfo[5],dinfo[6]]
self.refmodel.add_and_select(rdata)
self.add_person(person)

View File

@ -74,34 +74,25 @@ class SubstKeywords:
self.D = person.getDeath().getPlaceName()
self.i = str(person.getId())
if len(person.getFamilyList()) > 0:
self.s = ""
self.S = ""
self.m = ""
self.M = ""
if person.getFamilyList():
f = person.getFamilyList()[0]
if f.getFather() == person:
if f.getMother():
self.s = f.getMother().getPrimaryName().getRegularName()
self.S = f.getMother().getPrimaryName().getName()
else:
self.s = ""
self.S = ""
else:
if f.getFather():
self.s = f.getFather().getPrimaryName().getRegularName()
self.S = f.getFather().getPrimaryName().getName()
else:
self.s = ""
self.S = ""
self.m = ''
self.M = ''
for e in f.getEventList():
if e.getName == 'Marriage':
self.m = e.getDate()
self.M = e.getPlace()
else:
self.s = ""
self.S = ""
self.m = ""
self.M = ""
self.M = e.getPlaceName()
def replace(self,line):
"""Returns a new line of text with the substitutions performed."""

View File

@ -1940,10 +1940,6 @@
<property name="homogeneous">True</property>
<property name="spacing">0</property>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkButton" id="add_spouse">
<property name="visible">True</property>
@ -1964,12 +1960,16 @@
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="padding">5</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkButton" id="remove_spouse">
<property name="visible">True</property>
@ -1990,15 +1990,11 @@
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="padding">5</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="left_attach">1</property>

View File

@ -130,60 +130,3 @@ def latin_to_ansel(s):
buff.close()
return ans
if __name__ == "__main__":
print 'static unsigned char s0[] = {'
for i in range(256):
if i == 255:
suf = '};\n\n'
else:
suf = ','
if i%16 == 0 and i != 0:
print '\n',
try:
print "%3d%s" % (_s0[i],suf),
except:
print "%3d%s" % (i,suf),
print 'static unsigned char t0[] = {'
for i in range(256):
if i == 255:
suf = '};\n\n'
else:
suf = ','
if i%16 == 0 and i != 0:
print '\n',
try:
print "%3d%s" % (ord(_t0[i]),suf),
except KeyError:
print '0%s' % suf,
print 'static unsigned char* t1[] = {'
for i in range(256):
if i == 255:
suf = '};\n\n'
else:
suf = ','
if i%8== 0 and i != 0:
print '\n',
try:
t = _t1[i]
print '"\\%03o\\%03o"%s' % (ord(t[0]),ord(t[1]),suf),
except KeyError:
print '"\\%03o"%s' % (i,suf),
for key in _s1.keys():
print 'static unsigned char s_%x[] = {' % key
for i in range(256):
if i == 255:
suf = '};\n\n'
else:
suf = ','
if i%16 == 0 and i != 0:
print '\n',
try:
print "%3d%s" % (_s1[key][i],suf),
except:
print "%3d%s" % (i,suf),

View File

@ -84,17 +84,17 @@ class DescendantReport:
self.text = {}
for (p,x,y) in self.v:
self.text[p] = []
self.text[p.getId()] = []
subst = SubstKeywords(p)
for line in self.display:
self.text[p].append(subst.replace(line))
self.text[p.getId()].append(subst.replace(line))
self.font = self.doc.style_list["Normal"].get_font()
for line in self.text[p]:
for line in self.text[p.getId()]:
new_width = string_width(self.font,line)
self.box_width = max(self.box_width,new_width)
self.lines = max(self.lines,len(self.text[p]))
self.lines = max(self.lines,len(self.text[p.getId()]))
def write_report(self):
@ -242,7 +242,7 @@ class DescendantReport:
if plist:
for (p,x,y) in plist:
name = string.join(self.text[p],"\n")
name = string.join(self.text[p.getId()],"\n")
x = (x-1)*delta + left + _sep
y = (y-1)*(self.height+_sep)+top
self.doc.draw_box("box",name,x,y)

View File

@ -1414,7 +1414,7 @@ class GedcomParser:
self.code = ANSEL
self.cnv = ansel_to_utf8
else:
self.cnv = latin_to_utf8
self.cnv = latin_utf8.latin_to_utf8
self.ignore_sub_junk(2)
self.update(self.encoding_obj,matches[2])
elif matches[1] == "GEDC":

View File

@ -784,8 +784,8 @@ class WebReport(Report):
idoc.create_page()
idoc.close()
self.progress_bar_step()
while events_pending():
mainiteration()
while gtk.events_pending():
gtk.mainiteration()
if len(ind_list) > 1:
self.dump_index(ind_list,self.selected_style,