Handle deleting of images

svn: r1101
This commit is contained in:
Don Allingham 2002-07-28 16:41:21 +00:00
parent 684191d168
commit 1572cd1a89
5 changed files with 28 additions and 20 deletions

View File

@ -94,7 +94,7 @@ class EditPerson:
self.load_obj = None
self.top = libglade.GladeXML(const.editPersonFile, "editPerson")
gwidget = self.top.get_widget("photolist")
self.gallery = ImageSelect.Gallery(person, self.path, gwidget, self.db)
self.gallery = ImageSelect.Gallery(person, self.path, gwidget, self.db, self)
self.name_update_btn = self.top.get_widget('aka_update')
self.name_delete_btn = self.top.get_widget('aka_delete')
@ -780,12 +780,8 @@ class EditPerson:
text = self.notes_field.get_chars(0,-1)
idval = self.gid.get_text()
# self.pmap = {}
# for key in db.getPlaceKeys():
# p = db.getPlaceDisplay(key)
# self.pmap[p[0]] = key
changed = 0
print self.lists_changed
name = self.person.getPrimaryName()
if self.person.getId() != idval:

View File

@ -78,7 +78,7 @@ class EditPlace:
self.top_window = libglade.GladeXML(const.placesFile,"placeEditor")
plwidget = self.top_window.get_widget("photolist")
self.glry = ImageSelect.Gallery(place, self.path, plwidget, db)
self.glry = ImageSelect.Gallery(place, self.path, plwidget, db, self)
self.title = self.top_window.get_widget("place_title")
self.city = self.top_window.get_widget("city")
self.parish = self.top_window.get_widget("parish")

View File

@ -58,7 +58,7 @@ class EditSource:
self.top_window = libglade.GladeXML(const.gladeFile,"sourceEditor")
plwidget = self.top_window.get_widget("photolist")
self.gallery = ImageSelect.Gallery(source, self.path, plwidget, db)
self.gallery = ImageSelect.Gallery(source, self.path, plwidget, db, self)
self.title = self.top_window.get_widget("source_title")
self.author = self.top_window.get_widget("author")
self.pubinfo = self.top_window.get_widget("pubinfo")

View File

@ -65,12 +65,13 @@ _ = gettext
#-------------------------------------------------------------------------
class ImageSelect:
def __init__(self, path, db):
def __init__(self, path, db, parent):
"""Creates an edit window. Associates a person with the window."""
self.path = path;
self.db = db
self.dataobj = None
self.icon_cache = []
self.path = path;
self.db = db
self.dataobj = None
self.icon_cache = []
self.parent = parent
def add_thumbnail(self, photo):
"should be overrridden"
@ -169,7 +170,7 @@ class ImageSelect:
mobj.setLocal(1)
mobj.setPath(name)
Utils.modified()
self.parent.lists_changed = 1
Utils.destroy_passed_object(obj)
self.load_images()
@ -185,8 +186,8 @@ class ImageSelect:
#
#-------------------------------------------------------------------------
class Gallery(ImageSelect):
def __init__(self, dataobj, path, icon_list, db):
ImageSelect.__init__(self, path, db)
def __init__(self, dataobj, path, icon_list, db, parent):
ImageSelect.__init__(self, path, db, parent)
t = [
('STRING', 0, 0),
@ -272,8 +273,9 @@ class Gallery(ImageSelect):
name = RelImage.import_media_object(name,self.path,photo.getId())
photo.setPath(name)
photo.setLocal(1)
Utils.modified()
self.parent.lists_changed = 1
if GrampsCfg.globalprop:
Utils.modified()
GlobalMediaProperties(self.db,photo,None)
elif protocol != "":
import urllib
@ -305,8 +307,9 @@ class Gallery(ImageSelect):
w.drag_finish(context, 1, 0, time)
return
self.add_thumbnail(oref)
Utils.modified()
self.parent.lists_changed = 1
if GrampsCfg.globalprop:
Utils.modified()
GlobalMediaProperties(self.db,photo,None)
else:
if self.db.getObjectMap().has_key(data.data):
@ -328,6 +331,7 @@ class Gallery(ImageSelect):
nl = nl[0:icon_index] + [item] + nl[icon_index:]
self.dataobj.setPhotoList(nl)
Utils.modified()
self.parent.lists_changed = 1
self.load_images()
return
index = index + 1
@ -335,6 +339,7 @@ class Gallery(ImageSelect):
oref.setReference(self.db.findObjectNoMap(data.data))
self.dataobj.addPhoto(oref)
self.add_thumbnail(oref)
self.parent.lists_changed = 1
if GrampsCfg.globalprop:
LocalMediaProperties(oref,self.path)
Utils.modified()
@ -361,7 +366,10 @@ class Gallery(ImageSelect):
icon = self.selectedIcon
if icon != -1:
self.icon_list.remove(icon)
del self.dataobj.getPhotoList()[icon]
list = self.dataobj.getPhotoList()
del list[icon]
self.dataobj.setPhotoList(list)
self.parent.lists_changed = 1
if len(self.dataobj.getPhotoList()) == 0:
self.selectedIcon = -1
else:
@ -498,9 +506,11 @@ class LocalMediaProperties:
if text != note or priv != self.photo.getPrivacy():
self.photo.setNote(text)
self.photo.setPrivacy(priv)
self.parent.lists_changed = 1
Utils.modified()
if self.lists_changed:
self.photo.setAttributeList(self.alist)
self.parent.lists_changed = 1
Utils.modified()
def on_ok_clicked(self, obj):
@ -673,9 +683,11 @@ class GlobalMediaProperties:
if text != note or desc != self.object.getDescription():
self.object.setNote(text)
self.object.setDescription(desc)
self.parent.lists_changed = 1
Utils.modified()
if self.lists_changed:
self.object.setAttributeList(self.alist)
self.parent.lists_changed = 1
Utils.modified()
if self.update != None:
self.update()

View File

@ -76,7 +76,7 @@ class Marriage:
self.top = libglade.GladeXML(const.marriageFile,"marriageEditor")
top_window = self.get_widget("marriageEditor")
plwidget = self.top.get_widget("photolist")
self.gallery = ImageSelect.Gallery(family, self.path, plwidget, db)
self.gallery = ImageSelect.Gallery(family, self.path, plwidget, db, self)
self.top.signal_autoconnect({
"destroy_passed_object" : self.on_cancel_edit,
"on_up_clicked" : self.on_up_clicked,