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

View File

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

View File

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

View File

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

View File

@ -73,7 +73,7 @@ class EditSource:
self.notes_buffer.set_text(source.getNote()) self.notes_buffer.set_text(source.getNote())
self.top_window.signal_autoconnect({ 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_switch_page" : self.on_switch_page,
"on_addphoto_clicked" : self.gallery.on_add_photo_clicked, "on_addphoto_clicked" : self.gallery.on_add_photo_clicked,
"on_deletephoto_clicked" : self.gallery.on_delete_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("add_photo").set_sensitive(0)
self.top_window.get_widget("delete_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): def display_references(self):
p_event_list = [] p_event_list = []
p_attr_list = [] p_attr_list = []
@ -197,7 +201,8 @@ class EditSource:
self.source.setNote(note) self.source.setNote(note)
Utils.modified() Utils.modified()
Utils.destroy_passed_object(self.top) self.close(None)
if self.callback: if self.callback:
self.callback(self.source) self.callback(self.source)

View File

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

View File

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

View File

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

View File

@ -889,7 +889,9 @@ class ReportDialog:
self.report_menu = None self.report_menu = None
if self.extra_textbox: 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: else:
self.report_text = "" self.report_text = ""

View File

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

View File

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

View File

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

View File

@ -130,60 +130,3 @@ def latin_to_ansel(s):
buff.close() buff.close()
return ans 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 = {} self.text = {}
for (p,x,y) in self.v: for (p,x,y) in self.v:
self.text[p] = [] self.text[p.getId()] = []
subst = SubstKeywords(p) subst = SubstKeywords(p)
for line in self.display: 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() 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) new_width = string_width(self.font,line)
self.box_width = max(self.box_width,new_width) 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): def write_report(self):
@ -242,7 +242,7 @@ class DescendantReport:
if plist: if plist:
for (p,x,y) in 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 x = (x-1)*delta + left + _sep
y = (y-1)*(self.height+_sep)+top y = (y-1)*(self.height+_sep)+top
self.doc.draw_box("box",name,x,y) self.doc.draw_box("box",name,x,y)

View File

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

View File

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