From d5b51fe57b5db41a8f9237f16a5b65e88f18ae46 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Thu, 11 Oct 2001 13:15:10 +0000 Subject: [PATCH] Fixed GEDCOM import of images svn: r455 --- src/ImageSelect.py | 6 +++-- src/WriteXML.py | 7 +++--- src/gramps_main.py | 48 ++++++++++++++++++++++++++++----------- src/plugins/ReadGedcom.py | 4 ++++ 4 files changed, 46 insertions(+), 19 deletions(-) diff --git a/src/ImageSelect.py b/src/ImageSelect.py index aaa2f3734..f4b21e972 100644 --- a/src/ImageSelect.py +++ b/src/ImageSelect.py @@ -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() diff --git a/src/WriteXML.py b/src/WriteXML.py index c9ee07a59..0870da108 100644 --- a/src/WriteXML.py +++ b/src/WriteXML.py @@ -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("\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\n' % sp) - def write_url_list(g, list): for url in list: g.write(' \n') - def write_place_obj(g,place): title = place.get_title() diff --git a/src/gramps_main.py b/src/gramps_main.py index 444d8e8fe..d795e06bc 100755 --- a/src/gramps_main.py +++ b/src/gramps_main.py @@ -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) diff --git a/src/plugins/ReadGedcom.py b/src/plugins/ReadGedcom.py index 435432377..695697e13 100644 --- a/src/plugins/ReadGedcom.py +++ b/src/plugins/ReadGedcom.py @@ -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") % \