From 2fbbc07aef76f0523658258c103b0993cc4b75bc Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Mon, 4 Apr 2005 15:38:36 +0000 Subject: [PATCH] * src/ImageSelect.py (on_savephoto_clicked): Pass transaction to savephoto; (savephoto): take transaction argument); (on_photolist_drag_data_received): Pass transaction. svn: r4290 --- gramps2/ChangeLog | 5 +++++ gramps2/src/ImageSelect.py | 28 ++++++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 0ca826d2e..7c2a993c0 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,8 @@ +2005-04-04 Alex Roitman + * src/ImageSelect.py (on_savephoto_clicked): Pass transaction to + savephoto; (savephoto): take transaction argument); + (on_photolist_drag_data_received): Pass transaction. + 2005-04-03 Don Allingham * src/FamilyView.py: commit family properly * src/PedView.py: change_active_person typo diff --git a/gramps2/src/ImageSelect.py b/gramps2/src/ImageSelect.py index 1a9e0f145..c09702002 100644 --- a/gramps2/src/ImageSelect.py +++ b/gramps2/src/ImageSelect.py @@ -198,15 +198,14 @@ class ImageSelect: mobj.set_description(description) mobj.set_mime_type(mtype) mobj.set_path(filename) - self.savephoto(mobj) - self.db.commit_media_object(mobj,trans) + self.savephoto(mobj,trans) self.db.transaction_commit(trans,'Edit Media Objects') self.parent.lists_changed = 1 self.load_images() - def savephoto(self, photo): + def savephoto(self, photo, transaction): """Save the photo in the dataobj object - must be overridden""" pass @@ -359,9 +358,9 @@ class Gallery(ImageSelect): self.in_event = 0 return False - def savephoto(self, photo): + def savephoto(self,photo,transaction): """Save the photo in the dataobj object. (Required function)""" - self.db.add_object(photo,None) + self.db.add_object(photo,transaction) oref = RelLib.MediaRef() oref.set_reference_handle(photo.get_handle()) self.dataobj.add_media_reference(oref) @@ -479,9 +478,11 @@ class Gallery(ImageSelect): basename = os.path.basename(name) (root,ext) = os.path.splitext(basename) photo.set_description(root) - self.savephoto(photo) + trans = self.db.transaction_begin() + self.savephoto(photo,trans) if GrampsKeys.get_media_reference() == 0: photo.set_path(name) + self.db.transaction_commit(trans,_("Drag Media Object")) self.parent.lists_changed = 1 if GrampsKeys.get_media_global(): GlobalMediaProperties(self.db,photo, @@ -500,15 +501,18 @@ class Gallery(ImageSelect): photo.set_mime_type(mime) photo.set_description(d) photo.set_path(tfile) - self.db.add_object(photo,None) + trans = self.db.transaction_begin() + self.db.add_object(photo,trans) + self.db.transaction_commit(trans,_("Drag Media Object")) oref = RelLib.MediaRef() oref.set_reference_handle(photo.get_handle()) self.dataobj.add_media_reference(oref) - try: - photo.set_path(name) - except: - photo.set_path(tfile) - return +# This code seems to be reproducing what is already done. +# try: +# photo.set_path(name) +# except: +# photo.set_path(tfile) +# return self.add_thumbnail(oref) self.parent.lists_changed = 1 if GrampsKeys.get_media_global():