0001006: Narrative Web: Media objects missing title (description), mime_type, or path, are displayed poorly.

svn: r8366
This commit is contained in:
Brian Matherly 2007-04-09 03:40:11 +00:00
parent 6303d781c4
commit d731371b7f
2 changed files with 21 additions and 8 deletions

View File

@ -1,3 +1,7 @@
2007-04-08 Brian Matherly <brian@gramps-project.org>
* src/plugins/NarrativeWeb.py: 0001006: Narrative Web: Media objects missing
title (description), mime_type, or path, are displayed poorly.
2007-04-08 Don Allingham <don@gramps-project.org> 2007-04-08 Don Allingham <don@gramps-project.org>
* src/DisplayState.py (DisplayState.__init__): allocate 15 spaces for match label * src/DisplayState.py (DisplayState.__init__): allocate 15 spaces for match label

View File

@ -402,16 +402,19 @@ class BasePage:
photo_handle = mediaref.get_reference_handle() photo_handle = mediaref.get_reference_handle()
photo = db.get_object_from_handle(photo_handle) photo = db.get_object_from_handle(photo_handle)
mime_type = photo.get_mime_type() mime_type = photo.get_mime_type()
title = photo.get_description()
if title == "":
title = "(untitled)"
if mime_type: if mime_type:
try: try:
(real_path,newpath) = self.copy_media(photo) (real_path,newpath) = self.copy_media(photo)
descr = " ".join(wrapper.wrap(photo.get_description())) descr = " ".join(wrapper.wrap(title))
self.media_link(of, photo_handle, newpath, descr, up=True) self.media_link(of, photo_handle, newpath, descr, up=True)
except (IOError,OSError),msg: except (IOError,OSError),msg:
WarningDialog(_("Could not add photo to page"),str(msg)) WarningDialog(_("Could not add photo to page"),str(msg))
else: else:
try: try:
descr = " ".join(wrapper.wrap(photo.get_description())) descr = " ".join(wrapper.wrap(title))
self.doc_link(of, photo_handle, descr, up=True) self.doc_link(of, photo_handle, descr, up=True)
lnk = (self.cur_name,self.page_title,self.gid) lnk = (self.cur_name,self.page_title,self.gid)
if self.photo_list.has_key(photo_handle): if self.photo_list.has_key(photo_handle):
@ -827,12 +830,13 @@ class MediaPage(BasePage):
of = self.create_link_file(handle,"img") of = self.create_link_file(handle,"img")
mime_type = photo.get_mime_type() mime_type = photo.get_mime_type()
note_only = mime_type == None
if not note_only: if mime_type:
note_only = False
newpath = self.copy_source_file(handle, photo) newpath = self.copy_source_file(handle, photo)
target_exists = newpath != None target_exists = newpath != None
else: else:
note_only = True
target_exists = False target_exists = False
self.copy_thumbnail(handle, photo) self.copy_thumbnail(handle, photo)
@ -955,7 +959,9 @@ class MediaPage(BasePage):
os.path.join(self.html_dir,newpath)) os.path.join(self.html_dir,newpath))
return newpath return newpath
except (IOError,OSError),msg: except (IOError,OSError),msg:
WarningDialog(_("Missing media object"),str(msg)) error = _("Missing media object:") + \
"%s (%s)" % (photo.get_description(),photo.get_gramps_id())
WarningDialog(error,str(msg))
return None return None
def copy_thumbnail(self,handle,photo): def copy_thumbnail(self,handle,photo):
@ -964,9 +970,9 @@ class MediaPage(BasePage):
if photo.get_mime_type(): if photo.get_mime_type():
from_path = ImgManip.get_thumbnail_path(photo.get_path(),photo.get_mime_type()) from_path = ImgManip.get_thumbnail_path(photo.get_path(),photo.get_mime_type())
if not os.path.isfile(from_path): if not os.path.isfile(from_path):
from_path = os.path.join(const.data_dir,"document.png") from_path = os.path.join(const.image_dir,"document.png")
else: else:
from_path = os.path.join(const.data_dir,"document.png") from_path = os.path.join(const.image_dir,"document.png")
if self.archive: if self.archive:
self.archive.add(from_path,to_path) self.archive.add(from_path,to_path)
@ -1278,12 +1284,15 @@ class GalleryPage(BasePage):
for handle in mlist: for handle in mlist:
media = db.get_object_from_handle(handle) media = db.get_object_from_handle(handle)
date = _dd.display(media.get_date_object()) date = _dd.display(media.get_date_object())
title = media.get_description()
if title == "":
title = "untitled"
of.write('<tr>\n') of.write('<tr>\n')
of.write('<td class="category">%d.</td>\n' % index) of.write('<td class="category">%d.</td>\n' % index)
of.write('<td class="data">') of.write('<td class="data">')
self.media_ref_link(of,handle,media.get_description()) self.media_ref_link(of,handle,title)
of.write('</td>\n') of.write('</td>\n')
of.write('<td class="data">%s</td>\n' % date) of.write('<td class="data">%s</td>\n' % date)