* gramps.sh.in: escape the arguments to prevent spaces in
filenames to be parsed as to seperate arguments * src/ImageSelect.py: pass the mime_type to the thumbnail generator * src/ImgManip.py: query the gconf database to find appropriate thumbnail generators * src/NameDisplay.py: don't force a comma if the last name does not exist * src/WriteGedcom.py: don't copy a file on top of itself * src/plugins/Ancestors.py: verify the existance of a file * src/plugins/NavWebPage.py: don't use HOME page if it would be empty * src/plugins/Ancestors.py: fix pagebreak and borders around image svn: r5119
This commit is contained in:
parent
c2374c1ac5
commit
cc88a37d0b
@ -1,3 +1,19 @@
|
||||
2005-08-23 Don Allingham <don@gramps-project.org>
|
||||
* gramps.sh.in: escape the arguments to prevent spaces in
|
||||
filenames to be parsed as to seperate arguments
|
||||
* src/ImageSelect.py: pass the mime_type to the thumbnail generator
|
||||
* src/ImgManip.py: query the gconf database to find appropriate
|
||||
thumbnail generators
|
||||
* src/NameDisplay.py: don't force a comma if the last name does
|
||||
not exist
|
||||
* src/WriteGedcom.py: don't copy a file on top of itself
|
||||
* src/plugins/Ancestors.py: verify the existance of a file
|
||||
* src/plugins/NavWebPage.py: don't use HOME page if it would be
|
||||
empty
|
||||
|
||||
2005-08-23 Tim Allen <tim@proximity.com.au>
|
||||
* src/plugins/Ancestors.py: fix pagebreak and borders around image
|
||||
|
||||
2005-08-22 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
||||
* src/plugins/ExportVCard.py (write_person): Fix typo
|
||||
|
||||
|
@ -36,4 +36,4 @@ else
|
||||
export PYTHONPATH=$GRAMPSDIR:$GRAMPSLIBDIR:$GRAMPSPLUGINSDIR:$PYTHONPATH
|
||||
fi
|
||||
|
||||
exec @PYTHON@ $GRAMPSDIR/gramps.py $*
|
||||
exec @PYTHON@ $GRAMPSDIR/gramps.py "$*"
|
||||
|
@ -384,12 +384,7 @@ class Gallery(ImageSelect):
|
||||
|
||||
try:
|
||||
mtype = media_obj.get_mime_type()
|
||||
if mtype and mtype.startswith("image"):
|
||||
image = ImgManip.get_thumbnail_image(media_obj.get_path())
|
||||
else:
|
||||
image = Utils.find_mime_type_pixbuf(mtype)
|
||||
if not image:
|
||||
image = gtk.gdk.pixbuf_new_from_file(const.icon)
|
||||
image = ImgManip.get_thumbnail_image(media_obj.get_path(),mtype)
|
||||
except gobject.GError,msg:
|
||||
ErrorDialog(str(msg))
|
||||
image = gtk.gdk.pixbuf_new_from_file(const.icon)
|
||||
@ -709,7 +704,7 @@ class LocalMediaProperties:
|
||||
descr_window.set_text(self.obj.get_description())
|
||||
mtype = self.obj.get_mime_type()
|
||||
|
||||
self.pix = ImgManip.get_thumbnail_image(self.obj.get_path())
|
||||
self.pix = ImgManip.get_thumbnail_image(self.obj.get_path(),mtype)
|
||||
self.pixmap.set_from_pixbuf(self.pix)
|
||||
|
||||
self.change_dialog.get_widget("private").set_active(photo.get_privacy())
|
||||
@ -979,7 +974,7 @@ class GlobalMediaProperties:
|
||||
self.descr_window.set_text(self.obj.get_description())
|
||||
mtype = self.obj.get_mime_type()
|
||||
if mtype:
|
||||
pb = ImgManip.get_thumbnail_image(self.obj.get_path())
|
||||
pb = ImgManip.get_thumbnail_image(self.obj.get_path(),mtype)
|
||||
self.pixmap.set_from_pixbuf(pb)
|
||||
descr = Utils.get_mime_description(mtype)
|
||||
self.change_dialog.get_widget("type").set_text(descr)
|
||||
|
@ -25,12 +25,17 @@ import md5
|
||||
import gtk
|
||||
import gobject
|
||||
|
||||
import GrampsKeys
|
||||
|
||||
class ImgManip:
|
||||
def __init__(self,source):
|
||||
self.src = source
|
||||
|
||||
def size(self):
|
||||
img = gtk.gdk.pixbuf_new_from_file(self.src)
|
||||
try:
|
||||
img = gtk.gdk.pixbuf_new_from_file(self.src)
|
||||
except GError:
|
||||
return (0,0)
|
||||
return (img.get_width(),img.get_height())
|
||||
|
||||
def fmt_thumbnail(self,dest,width,height,cnv):
|
||||
@ -97,12 +102,24 @@ def _build_thumb_path(path):
|
||||
m = md5.md5(path)
|
||||
return os.path.join(base,m.hexdigest()+'.jpg')
|
||||
|
||||
def run_thumbnailer(cmd, frm, to):
|
||||
sublist = {
|
||||
'%s' : "%dx%d" % (int(const.thumbScale),int(const.thumbScale)),
|
||||
'%u' : frm,
|
||||
'%o' : to,
|
||||
}
|
||||
cmdlist = map(lambda x: sublist.get(x,x),cmd.split())
|
||||
if os.fork() == 0:
|
||||
os.execvp(cmdlist[0],cmdlist)
|
||||
os.wait()
|
||||
|
||||
def set_thumbnail_image(path,mtype=None):
|
||||
if mtype == "application/pdf":
|
||||
if os.fork() == 0:
|
||||
os.execvp('evince-thumbnailer',['evince-thumbnailer', path,
|
||||
_build_thumb_path(path)])
|
||||
os.wait()[0]
|
||||
if mtype and not mtype.startswith('image/'):
|
||||
base = '/desktop/gnome/thumbnailers/%s' % mtype.replace('/','@')
|
||||
thumbnailer = GrampsKeys.client.get_string(base + '/command')
|
||||
enable = GrampsKeys.client.get_bool(base + '/enable')
|
||||
if thumbnailer and enable:
|
||||
run_thumbnailer(thumbnailer,path,_build_thumb_path(path))
|
||||
else:
|
||||
try:
|
||||
pixbuf = gtk.gdk.pixbuf_new_from_file(path)
|
||||
@ -121,11 +138,14 @@ def set_thumbnail_image(path,mtype=None):
|
||||
def get_thumbnail_image(path,mtype=None):
|
||||
filename = _build_thumb_path(path)
|
||||
if not os.path.isfile(filename):
|
||||
set_thumbnail_image(path,type)
|
||||
set_thumbnail_image(path,mtype)
|
||||
try:
|
||||
return gtk.gdk.pixbuf_new_from_file(filename)
|
||||
except gobject.GError:
|
||||
return None
|
||||
if mtype:
|
||||
return Utils.find_mime_type_pixbuf(mtype)
|
||||
else:
|
||||
return gtk.gdk.pixbuf_new_from_file(os.path.join(const.dataDir,"document.png"))
|
||||
|
||||
def get_thumbnail_path(path,mtype=None):
|
||||
filename = _build_thumb_path(path)
|
||||
|
@ -235,10 +235,7 @@ class MediaView:
|
||||
path = mobj.get_path()
|
||||
if mtype:
|
||||
type_name = Utils.get_mime_description(mtype)
|
||||
if mtype[0:5] == "image":
|
||||
image = ImgManip.get_thumbnail_image(path)
|
||||
else:
|
||||
image = Utils.find_mime_type_pixbuf(mtype)
|
||||
image = ImgManip.get_thumbnail_image(path,mtype)
|
||||
else:
|
||||
image = Utils.find_mime_type_pixbuf('text/plain')
|
||||
type_name = _('Note')
|
||||
@ -379,7 +376,8 @@ class MediaView:
|
||||
handle = store.get_value(node,_HANDLE_COL)
|
||||
obj = self.db.get_object_from_handle(handle)
|
||||
if obj.get_path():
|
||||
image = ImgManip.get_thumbnail_image(obj.get_path())
|
||||
image = ImgManip.get_thumbnail_image(obj.get_path(),
|
||||
obj.get_mime_type())
|
||||
context.set_icon_pixbuf(image,0,0)
|
||||
|
||||
def on_drag_data_get(self, w, context, selection_data, info, time):
|
||||
|
@ -242,16 +242,19 @@ class NameDisplay:
|
||||
else:
|
||||
last = name.surname
|
||||
|
||||
if last:
|
||||
last += ","
|
||||
|
||||
if name.suffix:
|
||||
if name.prefix:
|
||||
return "%s %s, %s %s" % (name.prefix, last, first, name.suffix)
|
||||
return "%s %s %s %s" % (name.prefix, last, first, name.suffix)
|
||||
else:
|
||||
return "%s, %s %s" % (last, first, name.suffix)
|
||||
return "%s %s %s" % (last, first, name.suffix)
|
||||
else:
|
||||
if name.prefix:
|
||||
return "%s %s, %s" % (name.prefix, last, first)
|
||||
return "%s %s %s" % (name.prefix, last, first)
|
||||
else:
|
||||
return "%s, %s" % (last, first)
|
||||
return "%s %s" % (last, first)
|
||||
|
||||
|
||||
displayer = NameDisplay()
|
||||
|
@ -984,12 +984,13 @@ class GedcomWriter:
|
||||
continue
|
||||
basename = os.path.basename(path)
|
||||
dest = os.path.join (imgdir, basename)
|
||||
try:
|
||||
shutil.copyfile(path, dest)
|
||||
except (IOError,OSError),msg:
|
||||
msg2 = _("Could not create %s") % dest
|
||||
WarningDialog(msg2,str(msg))
|
||||
continue
|
||||
if dest != path:
|
||||
try:
|
||||
shutil.copyfile(path, dest)
|
||||
except (IOError,OSError),msg:
|
||||
msg2 = _("Could not create %s") % dest
|
||||
WarningDialog(msg2,str(msg))
|
||||
continue
|
||||
|
||||
self.writeln('1 OBJE')
|
||||
self.writeln('2 FORM jpeg')
|
||||
|
@ -27,6 +27,7 @@
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
import os
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -120,10 +121,6 @@ class ComprehensiveAncestorsReport (Report.Report):
|
||||
|
||||
cell = BaseDoc.TableCellStyle ()
|
||||
cell.set_padding (0.1)
|
||||
cell.set_left_border (1)
|
||||
cell.set_top_border (1)
|
||||
cell.set_right_border (1)
|
||||
cell.set_bottom_border (1)
|
||||
self.doc.add_cell_style ("AR-NoPhoto", cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle ()
|
||||
@ -155,6 +152,9 @@ class ComprehensiveAncestorsReport (Report.Report):
|
||||
[self.start_person.get_handle()])
|
||||
|
||||
if len (self.sources) > 0:
|
||||
if self.pgbrk:
|
||||
self.doc.page_break()
|
||||
|
||||
self.doc.start_paragraph ("AR-Heading")
|
||||
self.doc.write_text (_("Sources"))
|
||||
self.doc.end_paragraph ()
|
||||
@ -370,11 +370,12 @@ class ComprehensiveAncestorsReport (Report.Report):
|
||||
for media_ref in partner.get_media_list ()[:1]:
|
||||
object_handle = media_ref.get_reference_handle()
|
||||
mobject = self.database.get_object_from_handle(object_handle)
|
||||
mime_type = mobject.get_mime_type()
|
||||
if mime_type and mime_type.startswith("image"):
|
||||
spouse.append ((self.doc.add_media_object,
|
||||
[mobject.get_path (),
|
||||
'right', 2, 2]))
|
||||
if os.path.isfile(mobject.get_path()):
|
||||
mime_type = mobject.get_mime_type()
|
||||
if mime_type and mime_type.startswith("image"):
|
||||
spouse.append ((self.doc.add_media_object,
|
||||
[mobject.get_path (),
|
||||
'right', 2, 2]))
|
||||
|
||||
if suppress_children and len (already_described):
|
||||
style = "AR-Child"
|
||||
@ -396,7 +397,6 @@ class ComprehensiveAncestorsReport (Report.Report):
|
||||
if len (photos) == 0:
|
||||
ret.append ((self.doc.start_cell, ["AR-NoPhoto"]))
|
||||
ret.append ((self.doc.start_paragraph, ["AR-NoPhotoText"]))
|
||||
ret.append ((self.doc.write_text, [_("(no photo)")]))
|
||||
ret.append ((self.doc.end_paragraph, []))
|
||||
ret.append ((self.doc.end_cell, []))
|
||||
else:
|
||||
@ -405,7 +405,8 @@ class ComprehensiveAncestorsReport (Report.Report):
|
||||
object_handle = media_ref.get_reference_handle()
|
||||
mobject = self.database.get_object_from_handle(object_handle)
|
||||
mime_type = mobject.get_mime_type()
|
||||
if mime_type and mime_type.startswith("image"):
|
||||
if os.path.isfile(mobject.get_path()) and \
|
||||
mime_type and mime_type.startswith("image"):
|
||||
ret.append ((self.doc.add_media_object,
|
||||
[mobject.get_path (), 'left', 2, 2]))
|
||||
ret.append ((self.doc.end_cell, []))
|
||||
|
@ -267,10 +267,16 @@ class BasePage:
|
||||
of.write('<div class="navbyline">%s</div>\n' % msg)
|
||||
of.write('<h1 class="navtitle">%s</h1>\n' % self.title_str)
|
||||
of.write('<div class="nav">\n')
|
||||
self.show_link(of,'index',_('Home'),path)
|
||||
|
||||
use_home = self.options.handler.options_dict['NWEBhomenote'] != ""
|
||||
if use_home:
|
||||
self.show_link(of,'index',_('Home'),path)
|
||||
if self.use_intro:
|
||||
self.show_link(of,'introduction',_('Introduction'),path)
|
||||
self.show_link(of,'surnames',_('Surnames'),path)
|
||||
if not use_home and not self.use_intro:
|
||||
self.show_link(of,'index',_('Surnames'),path)
|
||||
else:
|
||||
self.show_link(of,'surnames',_('Surnames'),path)
|
||||
self.show_link(of,'individuals',_('Individuals'),path)
|
||||
self.show_link(of,'sources',_('Sources'),path)
|
||||
self.show_link(of,'places',_('Places'),path)
|
||||
@ -305,6 +311,14 @@ class BasePage:
|
||||
of.write('</div>\n')
|
||||
except (IOError,OSError),msg:
|
||||
WarningDialog(_("Could not add photo to page"),str(msg))
|
||||
elif mime_type.startswith('video/'):
|
||||
try:
|
||||
(real_path,newpath) = self.copy_media(photo)
|
||||
of.write('<div class="snapshot">\n')
|
||||
self.media_link(of,photo_handle,newpath,'',up=True)
|
||||
of.write('</div>\n')
|
||||
except (IOError,OSError),msg:
|
||||
WarningDialog(_("Could not add photo to page"),str(msg))
|
||||
else:
|
||||
try:
|
||||
(real_path,newpath) = self.copy_media(photo)
|
||||
@ -333,6 +347,13 @@ class BasePage:
|
||||
photo.get_description(),up=True)
|
||||
except (IOError,OSError),msg:
|
||||
WarningDialog(_("Could not add photo to page"),str(msg))
|
||||
elif mime_type.startswith('video/'):
|
||||
try:
|
||||
(real_path,newpath) = self.copy_media(photo)
|
||||
self.media_link(of,photo_handle,newpath,
|
||||
photo.get_description(),up=True)
|
||||
except (IOError,OSError),msg:
|
||||
WarningDialog(_("Could not add photo to page"),str(msg))
|
||||
else:
|
||||
try:
|
||||
self.doc_link(of,photo_handle,
|
||||
@ -730,20 +751,28 @@ class MediaPage(BasePage):
|
||||
|
||||
mime_type = photo.get_mime_type()
|
||||
if mime_type and (mime_type.startswith("image") or
|
||||
mime_type.startswith('video') or
|
||||
mime_type == "application/pdf"):
|
||||
ext = os.path.splitext(photo.get_path())[1]
|
||||
to_dir = self.build_path(handle,'thumb')
|
||||
to_path = os.path.join(to_dir,handle+ext)
|
||||
from_path = ImgManip.get_thumbnail_path(photo.get_path(),mime_type)
|
||||
if not os.path.isfile(from_path):
|
||||
from_path = os.path.join(const.dataDir,"document.png")
|
||||
|
||||
if self.archive:
|
||||
imagefile = open(from_path,"r")
|
||||
self.archive.add_file(to_path,time.time(),imagefile)
|
||||
imagefile.close()
|
||||
else:
|
||||
to_dir = os.path.join(self.html_dir,to_dir)
|
||||
dest = os.path.join(self.html_dir,to_path)
|
||||
if not os.path.isdir(to_dir):
|
||||
os.makedirs(to_dir)
|
||||
shutil.copyfile(from_path,os.path.join(self.html_dir,to_path))
|
||||
try:
|
||||
shutil.copyfile(from_path,dest)
|
||||
except IOError:
|
||||
print "Could not copy file"
|
||||
|
||||
self.page_title = photo.get_description()
|
||||
self.display_header(of,db, "%s - %s" % (_('Gallery'), title),
|
||||
@ -769,7 +798,7 @@ class MediaPage(BasePage):
|
||||
of.write('<img ')
|
||||
of.write('src="../../../%s" alt="%s" />\n' % (newpath, self.page_title))
|
||||
of.write('</div>\n')
|
||||
elif mime_type and mime_type == "application/pdf":
|
||||
elif mime_type and mime_type == "application/pdf" or mime_type.startswith('video/'):
|
||||
ext = os.path.splitext(photo.get_path())[1]
|
||||
to_dir = self.build_path(handle,'thumb')
|
||||
path = os.path.join(to_dir,handle+ext)
|
||||
@ -815,10 +844,10 @@ class SurnameListPage(BasePage):
|
||||
ORDER_BY_NAME = 0
|
||||
ORDER_BY_COUNT = 1
|
||||
def __init__(self, db, title, person_handle_list, options, archive,
|
||||
media_list, order_by=ORDER_BY_NAME):
|
||||
media_list, order_by=ORDER_BY_NAME,filename="surnames"):
|
||||
BasePage.__init__(self, title, options, archive, media_list, "")
|
||||
if order_by == self.ORDER_BY_NAME:
|
||||
of = self.create_file("surnames")
|
||||
of = self.create_file(filename)
|
||||
self.display_header(of,db,_('Surnames'),get_researcher().get_name())
|
||||
of.write('<h3>%s</h3>\n' % _('Surnames'))
|
||||
else:
|
||||
@ -1706,6 +1735,7 @@ class WebReport(Report.Report):
|
||||
self.user_footer = options.handler.options_dict['NWEBfooter']
|
||||
self.use_archive = options.handler.options_dict['NWEBarchive']
|
||||
self.use_intro = options.handler.options_dict['NWEBintronote'] != u""
|
||||
self.use_home = options.handler.options_dict['NWEBhomenote'] != u""
|
||||
|
||||
def write_report(self):
|
||||
if not self.use_archive:
|
||||
@ -1878,9 +1908,13 @@ class WebReport(Report.Report):
|
||||
local_list = sort_people(self.database,ind_list)
|
||||
self.progress.set_pass(_("Creating surname pages"),len(local_list))
|
||||
|
||||
if self.use_home:
|
||||
defname="surnames"
|
||||
else:
|
||||
defname="index"
|
||||
SurnameListPage(
|
||||
self.database, self.title, ind_list, self.options, archive,
|
||||
self.photo_list, SurnameListPage.ORDER_BY_NAME)
|
||||
self.photo_list, SurnameListPage.ORDER_BY_NAME,defname)
|
||||
|
||||
SurnameListPage(
|
||||
self.database, self.title, ind_list, self.options, archive,
|
||||
@ -1946,8 +1980,9 @@ class WebReport(Report.Report):
|
||||
index += 1
|
||||
|
||||
def base_pages(self, photo_list, archive):
|
||||
|
||||
HomePage(self.database, self.title, self.options, archive, photo_list)
|
||||
|
||||
if self.use_home:
|
||||
HomePage(self.database, self.title, self.options, archive, photo_list)
|
||||
|
||||
if self.inc_contact:
|
||||
ContactPage(self.database, self.title, self.options, archive, photo_list)
|
||||
|
Loading…
x
Reference in New Issue
Block a user