svn: r2912
This commit is contained in:
Don Allingham 2004-02-25 04:08:51 +00:00
parent 9bbcabef44
commit 125654323a
5 changed files with 36 additions and 37 deletions

View File

@ -1652,7 +1652,8 @@ class EditPerson:
media_list = self.person.get_media_list() media_list = self.person.get_media_list()
if media_list: if media_list:
ph = media_list[0] ph = media_list[0]
object = ph.get_reference() object_id = ph.get_reference_id()
object = self.db.find_object_from_id(object_id)
if self.load_obj != object.get_path(): if self.load_obj != object.get_path():
if object.get_mime_type()[0:5] == "image": if object.get_mime_type()[0:5] == "image":
self.load_photo(object.get_path()) self.load_photo(object.get_path())

View File

@ -469,7 +469,7 @@ class GrampsParser:
def start_objref(self,attrs): def start_objref(self,attrs):
self.objref = RelLib.MediaRef() self.objref = RelLib.MediaRef()
self.objref.set_reference(self.db.find_object_from_id(attrs['ref'])) self.objref.set_reference_id(attrs['ref'])
if attrs.has_key('priv'): if attrs.has_key('priv'):
self.objref.set_privacy(int(attrs['priv'])) self.objref.set_privacy(int(attrs['priv']))
if self.family: if self.family:
@ -507,7 +507,7 @@ class GrampsParser:
def start_photo(self,attrs): def start_photo(self,attrs):
self.photo = RelLib.MediaObject() self.photo = RelLib.MediaObject()
self.pref = RelLib.MediaRef() self.pref = RelLib.MediaRef()
self.pref.set_reference(self.photo) self.pref.set_reference_id(self.photo.get_id())
for key in attrs.keys(): for key in attrs.keys():
if key == "descrip" or key == "description": if key == "descrip" or key == "description":
@ -1033,7 +1033,8 @@ class GrampsImportParser(GrampsParser):
def start_objref(self,attrs): def start_objref(self,attrs):
self.objref = RelLib.MediaRef() self.objref = RelLib.MediaRef()
self.objref.set_reference(self.db.find_object_no_conflicts(attrs['ref'],self.MediaFileMap)) id = self.db.find_object_no_conflicts(attrs['ref'],self.MediaFileMap).get_id()
self.objref.set_reference_id(id)
if attrs.has_key('priv'): if attrs.has_key('priv'):
self.objref.set_privacy(int(attrs['priv'])) self.objref.set_privacy(int(attrs['priv']))
if self.family: if self.family:

View File

@ -39,10 +39,4 @@ class GrampsXML(RelLib.GrampsDB):
def load(self,name,callback): def load(self,name,callback):
ReadXML.loadData(self,name,callback) ReadXML.loadData(self,name,callback)
# for key in self.person_map.keys():
# data = self.person_map[key]
# name = data[2]
# print key,data
# self.add_surname(name.get_surname())
return 1 return 1

View File

@ -170,14 +170,15 @@ class ImageSelect:
return return
already_imported = None already_imported = None
for o in self.db.get_object_map().values(): for o_id in self.db.get_object_keys():
o = self.db.find_object_from_id(o_id)
if o.get_path() == filename: if o.get_path() == filename:
already_imported = o already_imported = o
break break
if (already_imported): if (already_imported):
oref = RelLib.MediaRef() oref = RelLib.MediaRef()
oref.set_reference(already_imported) oref.set_reference_id(already_imported.get_id())
self.dataobj.add_media_reference(oref) self.dataobj.add_media_reference(oref)
self.add_thumbnail(oref) self.add_thumbnail(oref)
else: else:
@ -281,8 +282,10 @@ class Gallery(ImageSelect):
def on_drag_begin(self,obj,context): def on_drag_begin(self,obj,context):
if const.dnd_images: if const.dnd_images:
mtype = self.sel_obj.get_reference().get_mime_type() id = self.sel_obj.get_reference_id()
name = Utils.thumb_path(self.db.get_save_path(),self.sel_obj.get_reference()) obj = self.db.find_object_from_id(id)
mtype = obj.get_mime_type()
name = Utils.thumb_path(self.db.get_save_path(),obj)
pix = gtk.gdk.pixbuf_new_from_file(name) pix = gtk.gdk.pixbuf_new_from_file(name)
context.set_icon_pixbuf(pix,0,0) context.set_icon_pixbuf(pix,0,0)
@ -368,14 +371,13 @@ class Gallery(ImageSelect):
"""Save the photo in the dataobj object. (Required function)""" """Save the photo in the dataobj object. (Required function)"""
self.db.add_object(photo) self.db.add_object(photo)
oref = RelLib.MediaRef() oref = RelLib.MediaRef()
oref.set_reference(photo) oref.set_reference_id(photo.get_id())
self.dataobj.add_media_reference(oref) self.dataobj.add_media_reference(oref)
def add_thumbnail(self, photo): def add_thumbnail(self, photo):
"""Scale the image and add it to the IconList.""" """Scale the image and add it to the IconList."""
object = photo.get_reference() oid = photo.get_reference_id()
oid = object.get_id() object = self.db.find_object_from_id(oid)
if self.canvas_list.has_key(oid): if self.canvas_list.has_key(oid):
(grp,item,text,x,y) = self.canvas_list[oid] (grp,item,text,x,y) = self.canvas_list[oid]
if x != self.cx or y != self.cy: if x != self.cx or y != self.cy:
@ -509,7 +511,7 @@ class Gallery(ImageSelect):
photo.set_path(tfile) photo.set_path(tfile)
self.db.add_object(photo) self.db.add_object(photo)
oref = RelLib.MediaRef() oref = RelLib.MediaRef()
oref.set_reference(photo) oref.set_reference_id(photo.get_id())
self.dataobj.add_media_reference(oref) self.dataobj.add_media_reference(oref)
try: try:
id = photo.get_id() id = photo.get_id()
@ -529,7 +531,7 @@ class Gallery(ImageSelect):
icon_index = self.get_index(w,x,y) icon_index = self.get_index(w,x,y)
index = 0 index = 0
for p in self.dataobj.get_media_list(): for p in self.dataobj.get_media_list():
if data.data == p.get_reference().get_id(): if data.data == p.get_reference_id():
if index == icon_index or icon_index == -1: if index == icon_index or icon_index == -1:
return return
else: else:
@ -548,7 +550,7 @@ class Gallery(ImageSelect):
return return
index = index + 1 index = index + 1
oref = RelLib.MediaRef() oref = RelLib.MediaRef()
oref.set_reference(self.db.find_object_from_id(data.data)) oref.set_reference(data.data)
self.dataobj.add_media_reference(oref) self.dataobj.add_media_reference(oref)
self.add_thumbnail(oref) self.add_thumbnail(oref)
self.parent.lists_changed = 1 self.parent.lists_changed = 1
@ -577,7 +579,7 @@ class Gallery(ImageSelect):
if not object: if not object:
return return
oref = RelLib.MediaRef() oref = RelLib.MediaRef()
oref.set_reference(object) oref.set_reference_id(object.get_id())
self.dataobj.add_media_reference(oref) self.dataobj.add_media_reference(oref)
self.add_thumbnail(oref) self.add_thumbnail(oref)
@ -590,7 +592,7 @@ class Gallery(ImageSelect):
if self.sel: if self.sel:
(i,t,b,photo,oid) = self.p_map[self.sel] (i,t,b,photo,oid) = self.p_map[self.sel]
val = self.canvas_list[photo.get_reference().get_id()] val = self.canvas_list[photo.get_reference_id()]
val[0].hide() val[0].hide()
val[1].hide() val[1].hide()
val[2].hide() val[2].hide()
@ -615,7 +617,7 @@ class Gallery(ImageSelect):
menu = gtk.Menu() menu = gtk.Menu()
menu.set_title(_("Media Object")) menu.set_title(_("Media Object"))
object = photo.get_reference() object = self.db.find_object_from_id(photo.get_reference_id())
mtype = object.get_mime_type() mtype = object.get_mime_type()
progname = grampslib.default_application_name(mtype) progname = grampslib.default_application_name(mtype)
@ -634,20 +636,20 @@ class Gallery(ImageSelect):
def popup_view_photo(self, obj): def popup_view_photo(self, obj):
"""Open this picture in a picture viewer""" """Open this picture in a picture viewer"""
photo = obj.get_data('o') photo = obj.get_data('o')
Utils.view_photo(photo.get_reference()) Utils.view_photo(self.db.find_object_from_id(photo.get_reference_id()))
def popup_edit_photo(self, obj): def popup_edit_photo(self, obj):
"""Open this picture in a picture editor""" """Open this picture in a picture editor"""
photo = obj.get_data('o') photo = obj.get_data('o')
if os.fork() == 0: if os.fork() == 0:
os.execvp(const.editor,[const.editor, obj = self.db.find_object_from_id(photo.get_reference_id())
photo.get_reference().get_path()]) os.execvp(const.editor,[const.editor, obj.get_path()])
def popup_convert_to_private(self, obj): def popup_convert_to_private(self, obj):
"""Copy this picture into gramps private database instead of """Copy this picture into gramps private database instead of
leaving it as an external data object.""" leaving it as an external data object."""
photo = obj.get_data('o') photo = obj.get_data('o')
object = photo.get_reference() object = self.db.find_object_from_id(photo.get_reference_id())
name = RelImage.import_media_object(object.get_path(),self.path, name = RelImage.import_media_object(object.get_path(),self.path,
object.get_id()) object.get_id())
object.set_path(name) object.set_path(name)
@ -678,7 +680,7 @@ class LocalMediaProperties:
self.win_key = self self.win_key = self
self.child_windows = {} self.child_windows = {}
self.photo = photo self.photo = photo
self.object = photo.get_reference() self.object = self.db.find_object_from_id(photo.get_reference_id())
self.alist = photo.get_attribute_list()[:] self.alist = photo.get_attribute_list()[:]
self.lists_changed = 0 self.lists_changed = 0
self.db = parent.db self.db = parent.db
@ -1014,24 +1016,24 @@ class GlobalMediaProperties:
for key in self.db.get_person_keys(): for key in self.db.get_person_keys():
p = self.db.get_person(key) p = self.db.get_person(key)
for o in p.get_media_list(): for o in p.get_media_list():
if o.get_reference() == self.object: if o.get_reference_id() == self.object.get_id():
self.refmodel.add([_("Person"),p.get_id(),GrampsCfg.nameof(p)]) self.refmodel.add([_("Person"),p.get_id(),GrampsCfg.nameof(p)])
any = 1 any = 1
for p in self.db.get_family_id_map().values(): for p in self.db.get_family_id_map().values():
for o in p.get_media_list(): for o in p.get_media_list():
if o.get_reference() == self.object: if o.get_reference_get_id() == self.object.get_id():
self.refmodel.add([_("Family"),p.get_id(),Utils.family_name(p,self.db)]) self.refmodel.add([_("Family"),p.get_id(),Utils.family_name(p,self.db)])
any = 1 any = 1
for key in self.db.get_source_keys(): for key in self.db.get_source_keys():
p = self.db.get_source(key) p = self.db.get_source(key)
for o in p.get_media_list(): for o in p.get_media_list():
if o.get_reference() == self.object: if o.get_reference_id() == self.object.get_id():
self.refmodel.add([_("Source"),p.get_id(),p.get_title()]) self.refmodel.add([_("Source"),p.get_id(),p.get_title()])
any = 1 any = 1
for key in self.db.get_place_id_keys(): for key in self.db.get_place_id_keys():
p = self.db.get_place_id(key) p = self.db.get_place_id(key)
for o in p.get_media_list(): for o in p.get_media_list():
if o.get_reference() == self.object: if o.get_reference_id() == self.object.get_id():
self.refmodel.add([_("Place"),p.get_id(),p.get_title()]) self.refmodel.add([_("Place"),p.get_id(),p.get_title()])
any = 1 any = 1
if any: if any:
@ -1129,7 +1131,7 @@ class DeleteMediaQuery:
nl = [] nl = []
change = 0 change = 0
for photo in p.get_media_list(): for photo in p.get_media_list():
if photo.get_reference() != self.media: if photo.get_reference_id() != self.media.get_id():
nl.append(photo) nl.append(photo)
else: else:
change = 1 change = 1
@ -1140,7 +1142,7 @@ class DeleteMediaQuery:
nl = [] nl = []
change = 0 change = 0
for photo in p.get_media_list(): for photo in p.get_media_list():
if photo.get_reference() != self.media: if photo.get_reference_id() != self.media.get_id():
nl.append(photo) nl.append(photo)
else: else:
change = 1 change = 1
@ -1152,7 +1154,7 @@ class DeleteMediaQuery:
nl = [] nl = []
change = 0 change = 0
for photo in p.get_media_list(): for photo in p.get_media_list():
if photo.get_reference() != self.media: if photo.get_reference_id() != self.media.get_id():
nl.append(photo) nl.append(photo)
else: else:
change = 1 change = 1
@ -1164,7 +1166,7 @@ class DeleteMediaQuery:
nl = [] nl = []
change = 0 change = 0
for photo in p.get_media_list(): for photo in p.get_media_list():
if photo.get_reference() != self.media: if photo.get_reference_id() != self.media.get_id():
nl.append(photo) nl.append(photo)
else: else:
change = 1 change = 1

View File

@ -286,6 +286,7 @@ class PeopleView:
self.parent.load_person(self.parent.active_person) self.parent.load_person(self.parent.active_person)
def apply_filter(self,current_model=None): def apply_filter(self,current_model=None):
self.parent.status_text(_('Updating display...')) self.parent.status_text(_('Updating display...'))
datacomp = self.DataFilter.compare datacomp = self.DataFilter.compare