Fixed GEDCOM import of images
svn: r455
This commit is contained in:
parent
7aef6c5340
commit
d5b51fe57b
@ -163,6 +163,7 @@ class Gallery(ImageSelect):
|
||||
t = [
|
||||
('STRING', 0, 0),
|
||||
('text/plain',0,0),
|
||||
('text/uri-list',0,2),
|
||||
('application/x-rootwin-drop',0,1)]
|
||||
|
||||
icon_list.drag_dest_set(DEST_DEFAULT_ALL, t, GDK.ACTION_COPY)
|
||||
@ -240,8 +241,9 @@ class Gallery(ImageSelect):
|
||||
|
||||
def on_photolist_drag_data_received(self,w, context, x, y, data, info, time):
|
||||
if data and data.format == 8:
|
||||
if data.data[0:5] == "file:":
|
||||
name = string.strip(data.data[5:])
|
||||
d = string.strip(string.replace(data.data,'\0',' '))
|
||||
if d[0:5] == "file:":
|
||||
name = d[5:]
|
||||
mime = gnome.mime.type_or_default_of_file(name,"unknown")
|
||||
if mime[0:5] == "image":
|
||||
photo = Photo()
|
||||
|
@ -71,7 +71,7 @@ def write_note(g,val,note,indent=0):
|
||||
g.write(" " * indent)
|
||||
|
||||
g.write("<" + val + ">")
|
||||
g.write(fix(note))
|
||||
g.write(fix(string.rstrip(note)))
|
||||
g.write("</" + val + ">\n")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -282,7 +282,8 @@ def write_attribute_list(g, list, indent=3):
|
||||
def write_photo_list(g,list,indent=3):
|
||||
sp = ' '*indent
|
||||
for photo in list:
|
||||
g.write('%s<objref ref="%s"' % (sp,photo.getReference().getId()))
|
||||
mobj = photo.getReference()
|
||||
g.write('%s<objref ref="%s"' % (sp,mobj.getId()))
|
||||
if photo.getPrivacy():
|
||||
g.write(' priv="1"')
|
||||
proplist = photo.getAttributeList()
|
||||
@ -296,7 +297,6 @@ def write_photo_list(g,list,indent=3):
|
||||
dump_source_ref(g,s,indent+1)
|
||||
g.write('%s</objref>\n' % sp)
|
||||
|
||||
|
||||
def write_url_list(g, list):
|
||||
for url in list:
|
||||
g.write(' <url priv="%d" href="%s"' % \
|
||||
@ -305,7 +305,6 @@ def write_url_list(g, list):
|
||||
g.write(' description="%s"' % fix(url.get_description()))
|
||||
g.write('/>\n')
|
||||
|
||||
|
||||
def write_place_obj(g,place):
|
||||
title = place.get_title()
|
||||
|
||||
|
@ -2544,19 +2544,35 @@ def change_parents(family):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
def find_tree(person,index,depth,list):
|
||||
def find_tree(person,index,depth,list,val=0):
|
||||
|
||||
if depth > 5 or person == None:
|
||||
return
|
||||
family = person.getMainFamily()
|
||||
list[index] = person
|
||||
frel = 0
|
||||
mrel = 0
|
||||
if family == None:
|
||||
l = person.getAltFamilyList()
|
||||
if len(l) > 0:
|
||||
f = l[0]
|
||||
family = f[0]
|
||||
if f[1] == "Birth":
|
||||
mrel = 0
|
||||
else:
|
||||
mrel = 1
|
||||
if f[2] == "Birth":
|
||||
frel = 0
|
||||
else:
|
||||
frel = 1
|
||||
|
||||
list[index] = (person,val)
|
||||
if family != None:
|
||||
father = family.getFather()
|
||||
if father != None:
|
||||
find_tree(father,(2*index)+1,depth+1,list)
|
||||
find_tree(father,(2*index)+1,depth+1,list,frel)
|
||||
mother = family.getMother()
|
||||
if mother != None:
|
||||
find_tree(mother,(2*index)+2,depth+1,list)
|
||||
find_tree(mother,(2*index)+2,depth+1,list,mrel)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -2588,11 +2604,11 @@ def load_canvas():
|
||||
find_tree(active_person,0,1,list)
|
||||
for t in list:
|
||||
if t:
|
||||
n = t.getPrimaryName().getName()
|
||||
n = t[0].getPrimaryName().getName()
|
||||
h = max(h,font.height(n)+2*PAD)
|
||||
w = max(w,font.width(n)+2*PAD)
|
||||
w = max(w,font.width("d. %s" % t.getDeath().getDate())+2*PAD)
|
||||
w = max(w,font.width("b. %s" % t.getBirth().getDate())+2*PAD)
|
||||
w = max(w,font.width("d. %s" % t[0].getDeath().getDate())+2*PAD)
|
||||
w = max(w,font.width("b. %s" % t[0].getBirth().getDate())+2*PAD)
|
||||
|
||||
cpad = max(h+4,CANVASPAD)
|
||||
cw = (cx2-cx1-(2*cpad))
|
||||
@ -2641,10 +2657,12 @@ def load_canvas():
|
||||
canvas_items = []
|
||||
|
||||
if list[1]:
|
||||
l = add_parent_button(root,canvas_items,list[1],cx2-PAD,ypts[1],h)
|
||||
p = list[1]
|
||||
l = add_parent_button(root,canvas_items,p[0],cx2-PAD,ypts[1],h)
|
||||
|
||||
if list[2]:
|
||||
l = add_parent_button(root,canvas_items,list[2],cx2-PAD,ypts[2],h)
|
||||
p = list[2]
|
||||
l = add_parent_button(root,canvas_items,p[0],cx2-PAD,ypts[2],h)
|
||||
|
||||
for i in range(gen):
|
||||
if list[i]:
|
||||
@ -2652,12 +2670,15 @@ def load_canvas():
|
||||
findex = (2*i)+1
|
||||
mindex = findex+1
|
||||
if list[findex]:
|
||||
p = list[findex]
|
||||
draw_canvas_line(root, xpts[i], ypts[i], xpts[findex],
|
||||
ypts[findex], h, w, list[findex], style)
|
||||
ypts[findex], h, w, p[0], style, p[1])
|
||||
if list[mindex]:
|
||||
p = list[mindex]
|
||||
draw_canvas_line(root,xpts[i],ypts[i], xpts[mindex],
|
||||
ypts[mindex], h, w, list[mindex], style)
|
||||
add_box(root,xpts[i],ypts[i],w,h,list[i],style)
|
||||
ypts[mindex], h, w, p[0], style, p[1])
|
||||
p = list[i]
|
||||
add_box(root,xpts[i],ypts[i],w,h,p[0],style)
|
||||
|
||||
|
||||
def add_parent_button(root,item_list,parent,x,y,h):
|
||||
@ -2685,12 +2706,13 @@ def change_to_parent(obj):
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def draw_canvas_line(root,x1,y1,x2,y2,h,w,data,style):
|
||||
def draw_canvas_line(root,x1,y1,x2,y2,h,w,data,style,ls):
|
||||
startx = x1+(w/2.0)
|
||||
pts = [startx,y1, startx,y2+(h/2.0), x2,y2+(h/2.0)]
|
||||
item = root.add("line",
|
||||
width_pixels=2,
|
||||
points=pts,
|
||||
line_style=ls,
|
||||
fill_color_gdk=style.black)
|
||||
item.set_data("p",data)
|
||||
item.connect("event",line_event)
|
||||
|
@ -783,6 +783,10 @@ class GedcomParser:
|
||||
photo = Photo()
|
||||
photo.setPath(path)
|
||||
photo.setDescription(title)
|
||||
photo.setMimeType(gnome.mime.type_or_default_of_file(name,"unknown"))
|
||||
db.addObject(photo)
|
||||
oref = ObjectRef()
|
||||
oref.setReference(photo)
|
||||
self.person.addPhoto(photo)
|
||||
else:
|
||||
self.warn(_("Could not import %s: currently an unknown file type") % \
|
||||
|
Loading…
Reference in New Issue
Block a user