diff --git a/ChangeLog b/ChangeLog index 208af7b29..45f117ee8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2008-02-15 Benny Malengier + * src/DataViews/RelationView.py + * src/DataViews/PedigreeView.py + * src/ReportBase/_ReportUtils.py + * src/Editors/_EditPerson.py + * src/Editors/_EditMediaRef.py + * src/DisplayTabs/_GalleryTab.py: also correct wrong popup menu + * src/plugins/Summary.py + * src/plugins/WriteCD.py + * src/plugins/IndivComplete.py + * src/plugins/NarrativeWeb.py + * src/plugins/WritePkg.py + * src/plugins/GVFamilyLines.py + * src/plugins/DefaultGramplets.py + * src/plugins/SimpleBookTitle.py + * src/plugins/Check.py + * src/plugins/GVRelGraph.py + * src/plugins/FamilyLines.py + * src/Selectors/_SelectObject.py + * src/GrampsDbUtils/_WriteGedcom.py + #1787, #1208: use relative path correctly + 2008-02-18 Raphael Ackermann * src/GrampsDbUtils/_GedcomParse.py: remove encode_filename() as filename is already unicode encoded. diff --git a/src/DataViews/PedigreeView.py b/src/DataViews/PedigreeView.py index 98319c556..100f51bfa 100644 --- a/src/DataViews/PedigreeView.py +++ b/src/DataViews/PedigreeView.py @@ -857,8 +857,11 @@ class PedigreeView(PageView.PersonNavView): if obj: mtype = obj.get_mime_type() if mtype and mtype[0:5] == "image": - image = ThumbNails.get_thumbnail_path(obj.get_path(), - rectangle=ph.get_rectangle()) + image = ThumbNails.get_thumbnail_path( + Utils.media_path_full( + self.dbstate.db, + obj.get_path()), + rectangle=ph.get_rectangle()) if cairo_available: pw = PersonBoxWidget_cairo( self.format_helper, lst[i][0], lst[i][3], positions[i][0][3], image); else: diff --git a/src/DataViews/RelationView.py b/src/DataViews/RelationView.py index 08509097d..f2dee2755 100644 --- a/src/DataViews/RelationView.py +++ b/src/DataViews/RelationView.py @@ -46,6 +46,7 @@ import gtk import gen.lib import PageView from BasicUtils import name_displayer +from Utils import media_path_full import DateHandler import ThumbNails import Config @@ -577,8 +578,10 @@ class RelationshipView(PageView.PersonNavView): if image_list: mobj = self.dbstate.db.get_object_from_handle(image_list[0].ref) if mobj and mobj.get_mime_type()[0:5] == "image": - pixbuf = ThumbNails.get_thumbnail_image(mobj.get_path(), - rectangle=image_list[0].get_rectangle()) + pixbuf = ThumbNails.get_thumbnail_image( + media_path_full(self.dbstate.db, + mobj.get_path()), + rectangle=image_list[0].get_rectangle()) image = gtk.Image() image.set_from_pixbuf(pixbuf) image.show() diff --git a/src/DisplayTabs/_GalleryTab.py b/src/DisplayTabs/_GalleryTab.py index 730ce3d68..ee710188e 100644 --- a/src/DisplayTabs/_GalleryTab.py +++ b/src/DisplayTabs/_GalleryTab.py @@ -90,18 +90,19 @@ class GalleryTab(ButtonTab): def double_click(self, obj, event): """ - Handle the double click on list. - + Handle the button press event: double click or right click on iconlist. If the double click occurs, the Edit button handler is called. - """ if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: self.edit_button_clicked(obj) + return True elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: reflist = self.iconlist.get_selected_items() if len(reflist) == 1: ref = self.media_list[reflist[0][0]] self.right_click(ref, event) + return True + return def right_click(self, obj, event): itemlist = [ @@ -119,8 +120,9 @@ class GalleryTab(ButtonTab): app = Mime.get_application(mime_type) if app: item = gtk.MenuItem(_('Open with %s') % app[1]) - item.connect('activate', make_launcher(app[0], - ref_obj.get_path())) + item.connect('activate', make_launcher(app[0], + Utils.media_path_full(self.dbstate.db, + ref_obj.get_path()))) item.show() menu.append(item) item = gtk.SeparatorMenuItem() @@ -228,9 +230,11 @@ class GalleryTab(ButtonTab): RunDatabaseRepair( _('Non existing media found in the Gallery')) else : - pixbuf = ThumbNails.get_thumbnail_image(obj.get_path(), - obj.get_mime_type(), - ref.get_rectangle()) + pixbuf = ThumbNails.get_thumbnail_image( + Utils.media_path_full(self.dbstate.db, + obj.get_path()), + obj.get_mime_type(), + ref.get_rectangle()) self.iconmodel.append(row=[pixbuf, obj.get_description(), ref]) self._connect_icon_model() self._set_label() diff --git a/src/Editors/_EditMediaRef.py b/src/Editors/_EditMediaRef.py index 280f70c0a..7db4b24d0 100644 --- a/src/Editors/_EditMediaRef.py +++ b/src/Editors/_EditMediaRef.py @@ -43,6 +43,7 @@ import const import Config import Mime import ThumbNails +from Utils import media_path_full from gen.lib import NoteType from DisplayTabs import \ @@ -98,11 +99,12 @@ class EditMediaRef(EditReference): the path. """ self.mtype = self.source.get_mime_type() - self.pix = ThumbNails.get_thumbnail_image(self.source.get_path(), + fullpath = media_path_full(self.db, self.source.get_path()) + self.pix = ThumbNails.get_thumbnail_image(fullpath, self.mtype) self.pixmap.set_from_pixbuf(self.pix) - self.subpix = ThumbNails.get_thumbnail_image(self.source.get_path(), + self.subpix = ThumbNails.get_thumbnail_image(fullpath, self.mtype, self.rectangle) self.subpixmap.set_from_pixbuf(self.subpix) @@ -336,7 +338,8 @@ class EditMediaRef(EditReference): self.subpixmap.hide() else: try: - pixbuf = gtk.gdk.pixbuf_new_from_file(path) + fullpath = media_path_full(self.db, path) + pixbuf = gtk.gdk.pixbuf_new_from_file(fullpath) width = pixbuf.get_width() height = pixbuf.get_height() upper_x = min(self.rectangle[0], self.rectangle[2])/100. @@ -390,8 +393,8 @@ class EditMediaRef(EditReference): mime_type = self.source.get_mime_type() app = Mime.get_application(mime_type) if app: - import Utils - Utils.launch(app[0],self.source.get_path()) + from Utils import launch + launch(app[0], media_path_full(self.db, self.source.get_path())) def _connect_signals(self): self.define_cancel_button(self.top.get_widget('button84')) diff --git a/src/Editors/_EditPerson.py b/src/Editors/_EditPerson.py index 73941f855..a137013df 100644 --- a/src/Editors/_EditPerson.py +++ b/src/Editors/_EditPerson.py @@ -424,7 +424,8 @@ class EditPerson(EditPrimary): been modified. """ - self.load_photo(obj.get_path(), ref.get_rectangle()) + self.load_photo(Utils.media_path_full(self.dbstate.db, obj.get_path()), + ref.get_rectangle()) def _image_button_press(self, obj, event): """ @@ -754,12 +755,13 @@ class EditPerson(EditPrimary): photo = media_list[0] object_handle = photo.get_reference_handle() obj = self.db.get_object_from_handle(object_handle) + full_path = Utils.media_path_full(self.dbstate.db, obj.get_path()) #reload if different media, or different rectangle - if self.load_obj != obj.get_path() or \ + if self.load_obj != full_path or \ self.load_rect != photo.get_rectangle(): mime_type = obj.get_mime_type() if mime_type and mime_type.startswith("image"): - self.load_photo(obj.get_path(), photo.get_rectangle()) + self.load_photo(full_path, photo.get_rectangle()) else: self.load_photo(None) else: diff --git a/src/GrampsDbUtils/_WriteGedcom.py b/src/GrampsDbUtils/_WriteGedcom.py index ae529f502..2675efb15 100644 --- a/src/GrampsDbUtils/_WriteGedcom.py +++ b/src/GrampsDbUtils/_WriteGedcom.py @@ -41,6 +41,7 @@ import _GedcomInfo as GedcomInfo import Errors import ExportOptions import BasicUtils +from Utils import media_path_full import gen.proxy from QuestionDialog import ErrorDialog @@ -1345,7 +1346,7 @@ class GedcomWriter(BasicUtils.UpdateCallback): if photo_obj: mime = photo_obj.get_mime_type() form = MIME2GED.get(mime, mime) - path = photo_obj.get_path() + path = media_path_full(self.dbase, photo_obj.get_path()) if not os.path.isfile(path): return self.__writeln(level, 'OBJE') diff --git a/src/ReportBase/_ReportUtils.py b/src/ReportBase/_ReportUtils.py index 60789a14d..3fd8ae417 100644 --- a/src/ReportBase/_ReportUtils.py +++ b/src/ReportBase/_ReportUtils.py @@ -43,6 +43,7 @@ from gettext import gettext as _ import DateHandler import gen.lib from BasicUtils import name_displayer as _nd +from Utils import media_path_full from QuestionDialog import WarningDialog import BaseDoc @@ -1566,7 +1567,7 @@ def insert_image(database, doc, photo, w_cm=4.0, h_cm=4.0): media_object = database.get_object_from_handle(object_handle) mime_type = media_object.get_mime_type() if mime_type and mime_type.startswith("image"): - filename = media_object.get_path() + filename = media_path_full(database, media_object.get_path()) if os.path.exists(filename): doc.add_media_object(filename, "right", w_cm, h_cm) else: diff --git a/src/Selectors/_SelectObject.py b/src/Selectors/_SelectObject.py index 005e0ab28..769dd7435 100644 --- a/src/Selectors/_SelectObject.py +++ b/src/Selectors/_SelectObject.py @@ -44,6 +44,7 @@ import gtk # #------------------------------------------------------------------------- import const +from Utils import media_path_full import ThumbNails from DisplayModels import MediaModel from _BaseSelector import BaseSelector @@ -90,7 +91,8 @@ class SelectObject(BaseSelector): return handle = id_list[0] obj = self.get_from_handle_func()(handle) - pix = ThumbNails.get_thumbnail_image(obj.get_path()) + pix = ThumbNails.get_thumbnail_image(media_path_full(self.db, + obj.get_path())) self.preview.set_from_pixbuf(pix) gc.collect() diff --git a/src/plugins/Check.py b/src/plugins/Check.py index 0647b0629..7609298bd 100644 --- a/src/plugins/Check.py +++ b/src/plugins/Check.py @@ -540,7 +540,7 @@ class CheckIntegrity: for ObjectId in self.db.get_media_object_handles(): obj = self.db.get_object_from_handle(ObjectId) - photo_name = obj.get_path() + photo_name = Utils.media_path_full(self.db, obj.get_path()) if photo_name is not None and photo_name != "" and not Utils.find_file(photo_name): if cl: print "Warning: media file %s was not found." \ diff --git a/src/plugins/DefaultGramplets.py b/src/plugins/DefaultGramplets.py index 61e8f753e..9f15b0f21 100644 --- a/src/plugins/DefaultGramplets.py +++ b/src/plugins/DefaultGramplets.py @@ -25,6 +25,7 @@ import urllib import gen.lib from DataViews import register, Gramplet from BasicUtils import name_displayer +from Utils import media_path_full from QuickReports import run_quick_report_by_name import DateHandler from gettext import gettext as _ @@ -474,8 +475,9 @@ class StatsGramplet(Gramplet): pobjects = len(database.get_media_object_handles()) for photo_id in database.get_media_object_handles(): photo = database.get_object_from_handle(photo_id) + fullname = media_path_full(database, photo.get_path()) try: - bytes = bytes + posixpath.getsize(photo.get_path()) + bytes = bytes + posixpath.getsize(fullname) except: notfound.append(photo.get_path()) diff --git a/src/plugins/FamilyLines.py b/src/plugins/FamilyLines.py index e66356857..6c63240ca 100644 --- a/src/plugins/FamilyLines.py +++ b/src/plugins/FamilyLines.py @@ -582,7 +582,9 @@ class FamilyLinesReport(Report): media = self.db.get_object_from_handle(mediaHandle) mediaMimeType = media.get_mime_type() if mediaMimeType[0:5] == "image": - imagePath = ThumbNails.get_thumbnail_path(media.get_path()) + imagePath = ThumbNails.get_thumbnail_path( + Utils.media_path_full(self.db, + media.get_path())) # put the label together and ouput this person label = u"" diff --git a/src/plugins/GVFamilyLines.py b/src/plugins/GVFamilyLines.py index 3393180a7..83850bf42 100644 --- a/src/plugins/GVFamilyLines.py +++ b/src/plugins/GVFamilyLines.py @@ -720,7 +720,10 @@ class FamilyLinesReport(Report): media = self.db.get_object_from_handle(mediaHandle) mediaMimeType = media.get_mime_type() if mediaMimeType[0:5] == "image": - imagePath = ThumbNails.get_thumbnail_path(media.get_path()) + imagePath = ThumbNails.get_thumbnail_path( + Utils.media_path_full(self.db, + media.get_path()) + ) # put the label together and ouput this person label = u"" diff --git a/src/plugins/GVRelGraph.py b/src/plugins/GVRelGraph.py index 32b49227b..73115aa05 100644 --- a/src/plugins/GVRelGraph.py +++ b/src/plugins/GVRelGraph.py @@ -302,7 +302,9 @@ class RelGraphReport(Report): media = self.database.get_object_from_handle(mediaHandle) mediaMimeType = media.get_mime_type() if mediaMimeType[0:5] == "image": - imagePath = ThumbNails.get_thumbnail_path(media.get_path()) + imagePath = ThumbNails.get_thumbnail_path( + Utils.media_path_full(self.database, + media.get_path())) #test if thumbnail actually exists in thumbs (import of data means media files might not be present imagePath = Utils.find_file(imagePath) diff --git a/src/plugins/IndivComplete.py b/src/plugins/IndivComplete.py index d057eb917..fb2cc298d 100644 --- a/src/plugins/IndivComplete.py +++ b/src/plugins/IndivComplete.py @@ -43,6 +43,7 @@ from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI from ReportBase import Bibliography, Endnotes from BasicUtils import name_displayer as _nd +from Utils import media_path_full from QuestionDialog import WarningDialog #------------------------------------------------------------------------ @@ -410,7 +411,7 @@ class IndivCompleteReport(Report): object = self.database.get_object_from_handle(object_handle) mime_type = object.get_mime_type() if mime_type and mime_type.startswith("image"): - filename = object.get_path() + filename = media_path_full(self.database, object.get_path()) if os.path.exists(filename): self.doc.start_paragraph("IDS-Normal") self.doc.add_media_object(filename, "center", 4.0, 4.0) diff --git a/src/plugins/NarrativeWeb.py b/src/plugins/NarrativeWeb.py index 62ba72e3b..c1c836dac 100644 --- a/src/plugins/NarrativeWeb.py +++ b/src/plugins/NarrativeWeb.py @@ -1132,7 +1132,8 @@ class MediaPage(BasePage): # image; most web browsers will dynamically resize an image # and provide zoom-in/zoom-out functionality when the image # is displayed directly - (width, height) = ImgManip.image_size(photo.get_path()) + (width, height) = ImgManip.image_size( + Utils.media_path_full(self.db, photo.get_path())) scale = 1.0 if width > _MAX_IMG_WIDTH or height > _MAX_IMG_HEIGHT: # image is too large -- scale it down and link to the full image @@ -1155,7 +1156,10 @@ class MediaPage(BasePage): dirname = tempfile.mkdtemp() thmb_path = os.path.join(dirname,"temp.png") - if ThumbNails.run_thumbnailer(mime_type, photo.get_path(), thmb_path, 320): + if ThumbNails.run_thumbnailer(mime_type, + Utils.media_path_full(self.db, + photo.get_path()), + thmb_path, 320): try: path = "%s/%s.png" % (self.build_path(photo.handle,"preview"),photo.handle) self.store_file(archive, self.html_dir, thmb_path, path) @@ -1236,14 +1240,15 @@ class MediaPage(BasePage): to_dir = self.build_path(handle,'images') newpath = to_dir + "/" + handle + ext + fullpath = Utils.media_path_full(self.db, photo.get_path()) try: if self.archive: - self.archive.add(photo.get_path(),str(newpath)) + self.archive.add(fullpath,str(newpath)) else: to_dir = os.path.join(self.html_dir,to_dir) if not os.path.isdir(to_dir): os.makedirs(to_dir) - shutil.copyfile(photo.get_path(), + shutil.copyfile(fullpath, os.path.join(self.html_dir,newpath)) return newpath except (IOError,OSError),msg: @@ -1256,7 +1261,10 @@ class MediaPage(BasePage): to_dir = self.build_path(handle,'thumb') to_path = os.path.join(to_dir,handle+".png") if photo.get_mime_type(): - from_path = ThumbNails.get_thumbnail_path(photo.get_path(),photo.get_mime_type()) + from_path = ThumbNails.get_thumbnail_path(Utils.media_path_full( + self.db, + photo.get_path()), + photo.get_mime_type()) if not os.path.isfile(from_path): from_path = os.path.join(const.IMAGE_DIR,"document.png") else: @@ -1385,7 +1393,9 @@ class IntroductionPage(BasePage): if mime_type and mime_type.startswith("image"): try: (newpath, thumb_path) = self.copy_media(obj, False) - self.store_file(archive, self.html_dir, obj.get_path(), + self.store_file(archive, self.html_dir, + Utils.media_path_full(db, + obj.get_path()), newpath) of.write('
\n') of.write('\n') of.write('\n') diff --git a/src/plugins/SimpleBookTitle.py b/src/plugins/SimpleBookTitle.py index d5f1726b4..3b93739e8 100644 --- a/src/plugins/SimpleBookTitle.py +++ b/src/plugins/SimpleBookTitle.py @@ -41,6 +41,7 @@ import gtk # #------------------------------------------------------------------------ from PluginUtils import register_report +from Utils import media_path_full from ReportBase import Report, ReportOptions, CATEGORY_TEXT, MODE_BKI import BaseDoc from Selectors import selector_factory @@ -95,7 +96,7 @@ class SimpleBookTitle(Report): if self.object_id: the_object = self.database.get_object_from_gramps_id(self.object_id) - name = the_object.get_path() + name = media_path_full(self.database, the_object.get_path()) if self.image_size: image_size = self.image_size else: @@ -253,8 +254,9 @@ class SimpleBookTitleOptions(ReportOptions): return self.options_dict['imgid'] = the_object.get_gramps_id() self.obj_title.set_text(the_object.get_description()) - icon_image = ThumbNails.get_thumbnail_image(the_object.get_path(), - the_object.get_mime_type()) + icon_image = ThumbNails.get_thumbnail_image( + media_path_full(database, the_object.get_path()), + the_object.get_mime_type()) self.preview.set_from_pixbuf(icon_image) self.remove_obj_button.set_sensitive(True) self.size.set_sensitive(True) diff --git a/src/plugins/Summary.py b/src/plugins/Summary.py index c7696b707..71026b7d6 100644 --- a/src/plugins/Summary.py +++ b/src/plugins/Summary.py @@ -45,6 +45,7 @@ import gtk.glade #------------------------------------------------------------------------ import gen.lib from PluginUtils import register_report +from Utils import media_path_full from ReportBase import CATEGORY_VIEW, MODE_GUI import DateHandler import ManagedWindow @@ -75,7 +76,8 @@ def build_report(database,person): for photo_id in database.get_media_object_handles(): photo = database.get_object_from_handle(photo_id) try: - bytes = bytes + posixpath.getsize(photo.get_path()) + bytes = bytes + posixpath.getsize(media_path_full(database, + photo.get_path())) except: notfound.append(photo.get_path()) diff --git a/src/plugins/WriteCD.py b/src/plugins/WriteCD.py index 1fd0b6f13..95ab12218 100644 --- a/src/plugins/WriteCD.py +++ b/src/plugins/WriteCD.py @@ -74,6 +74,7 @@ except: # #------------------------------------------------------------------------- from GrampsDbUtils import XmlWriter +from Utils import media_path_full from QuestionDialog import ErrorDialog, MissingMediaDialog from PluginUtils import register_export @@ -125,7 +126,7 @@ class PackageWriter: for obj_id in self.db.get_media_object_handles(): obj = self.db.get_object_from_handle(obj_id) - oldfile = obj.get_path() + oldfile = media_path_full(self.db, obj.get_path()) root = os.path.basename(oldfile) if os.path.isfile(oldfile): self.copy_file(oldfile, 'burn:///%s/%s' % (base, root)) @@ -246,7 +247,7 @@ class PackageWriter: for obj_id in self.db.get_media_object_handles(): obj = self.db.get_object_from_handle(obj_id) - oldfile = obj.get_path() + oldfile = media_path_full(self.db, obj.get_path()) root = os.path.basename(oldfile) if os.path.isfile(oldfile): self.copy_file(oldfile, 'burn:///%s/%s' % (base, root)) diff --git a/src/plugins/WritePkg.py b/src/plugins/WritePkg.py index adf2bc330..1674bde6a 100644 --- a/src/plugins/WritePkg.py +++ b/src/plugins/WritePkg.py @@ -175,7 +175,7 @@ class PackageWriter: # during the process (i.e. when removing object) for m_id in self.db.get_media_object_handles(): mobject = self.db.get_object_from_handle(m_id) - filename = str(mobject.get_path()) + filename = str(Utils.media_path_full(self.db, mobject.get_path())) if os.path.isfile(filename): archive.add(filename) # else: