* src/RelImage.py: remove PIL
* src/Imgmanip.py: remove PIL * src/MediaView.py: remove PIL * src/accent.py: support of unaccenting characters for comparison, and sorting * src/RelLib.py: build sort name using unaccented version * src/PeopleView.py: get bold working again * src/PeopleModel.py: sort using unaccented characters svn: r3428
This commit is contained in:
parent
baa5ec71f4
commit
ec9723a390
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
2004-08-17 Don Allingham <dallingham@users.sourceforge.net>
|
||||||
|
* src/RelImage.py: remove PIL
|
||||||
|
* src/Imgmanip.py: remove PIL
|
||||||
|
* src/MediaView.py: remove PIL
|
||||||
|
* src/accent.py: support of unaccenting characters for comparison,
|
||||||
|
and sorting
|
||||||
|
* src/RelLib.py: build sort name using unaccented version
|
||||||
|
* src/PeopleView.py: get bold working again
|
||||||
|
* src/PeopleModel.py: sort using unaccented characters
|
||||||
|
|
||||||
2004-08-17 Tim Waugh <twaugh@redhat.com>
|
2004-08-17 Tim Waugh <twaugh@redhat.com>
|
||||||
* src/FamilyView.py (spouse_changed): Update display.
|
* src/FamilyView.py (spouse_changed): Update display.
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ class GrampsBSDDB(GrampsDbBase):
|
|||||||
for name in names:
|
for name in names:
|
||||||
a[unicode(name)] = 1
|
a[unicode(name)] = 1
|
||||||
vals = a.keys()
|
vals = a.keys()
|
||||||
vals.sort()
|
vals.sort(accent.sort_by_accent)
|
||||||
return vals
|
return vals
|
||||||
|
|
||||||
def get_person_event_type_list(self):
|
def get_person_event_type_list(self):
|
||||||
|
122
src/ImgManip.py
122
src/ImgManip.py
@ -27,92 +27,44 @@ import signal
|
|||||||
# Check for the python imaging library
|
# Check for the python imaging library
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
try:
|
|
||||||
import PIL.Image
|
import popen2
|
||||||
import StringIO
|
import gtk
|
||||||
PIL.Image.init()
|
|
||||||
no_pil = 0
|
|
||||||
except:
|
|
||||||
import popen2
|
|
||||||
import gtk
|
|
||||||
no_pil = 1
|
|
||||||
|
|
||||||
class ImgManip:
|
class ImgManip:
|
||||||
def __init__(self,source):
|
def __init__(self,source):
|
||||||
self.src = source
|
self.src = source
|
||||||
|
|
||||||
if no_pil:
|
def size(self):
|
||||||
|
img = gtk.gdk.pixbuf_new_from_file(self.src)
|
||||||
def size(self):
|
return (img.get_width(),img.get_height())
|
||||||
img = gtk.gdk.pixbuf_new_from_file(self.src)
|
|
||||||
return (img.get_width(),img.get_height())
|
def fmt_thumbnail(self,dest,width,height,cnv):
|
||||||
|
w = int(width)
|
||||||
def fmt_thumbnail(self,dest,width,height,cnv):
|
h = int(height)
|
||||||
w = int(width)
|
cmd = "%s -geometry %dx%d '%s' '%s:%s'" % (const.convert,w,h,self.src,cnv,dest)
|
||||||
h = int(height)
|
os.system(cmd)
|
||||||
cmd = "%s -geometry %dx%d '%s' '%s:%s'" % (const.convert,w,h,self.src,cnv,dest)
|
|
||||||
os.system(cmd)
|
|
||||||
|
|
||||||
def fmt_convert(self,dest,cnv):
|
|
||||||
cmd = "%s '%s' '%s:%s'" % (const.convert,self.src,cnv,dest)
|
|
||||||
os.system(cmd)
|
|
||||||
|
|
||||||
def fmt_data(self,cnv):
|
|
||||||
cmd = "%s '%s' '%s:-'" % (const.convert,self.src,cnv)
|
|
||||||
r,w = popen2.popen2(cmd)
|
|
||||||
buf = r.read()
|
|
||||||
r.close()
|
|
||||||
w.close()
|
|
||||||
return buf
|
|
||||||
|
|
||||||
def fmt_scale_data(self,x,y,cnv):
|
|
||||||
cmd = "%s -geometry %dx%d '%s' '%s:-'" % (const.convert,x,y,self.src,cnv)
|
|
||||||
signal.signal (signal.SIGCHLD, signal.SIG_DFL)
|
|
||||||
r,w = popen2.popen2(cmd)
|
|
||||||
buf = r.read()
|
|
||||||
r.close()
|
|
||||||
w.close()
|
|
||||||
return buf
|
|
||||||
|
|
||||||
else:
|
|
||||||
|
|
||||||
def size(self):
|
|
||||||
return PIL.Image.open(self.src).size
|
|
||||||
|
|
||||||
def fmt_thumbnail(self,dest,width,height,pil):
|
|
||||||
im = PIL.Image.open(self.src)
|
|
||||||
im.thumbnail((width,height))
|
|
||||||
if im.mode != 'RGB':
|
|
||||||
im.draft('RGB',im.size)
|
|
||||||
im = im.convert("RGB")
|
|
||||||
im.save(dest,pil.upper())
|
|
||||||
|
|
||||||
def fmt_convert(self,dest,pil):
|
def fmt_convert(self,dest,cnv):
|
||||||
im = PIL.Image.open(self.src)
|
cmd = "%s '%s' '%s:%s'" % (const.convert,self.src,cnv,dest)
|
||||||
if im.mode != 'RGB':
|
os.system(cmd)
|
||||||
im.draft('RGB',im.size)
|
|
||||||
im = im.convert("RGB")
|
def fmt_data(self,cnv):
|
||||||
im.save(dest,pil.upper())
|
cmd = "%s '%s' '%s:-'" % (const.convert,self.src,cnv)
|
||||||
|
r,w = popen2.popen2(cmd)
|
||||||
|
buf = r.read()
|
||||||
|
r.close()
|
||||||
|
w.close()
|
||||||
|
return buf
|
||||||
|
|
||||||
def fmt_data(self,pil):
|
def fmt_scale_data(self,x,y,cnv):
|
||||||
g = StringIO.StringIO()
|
cmd = "%s -geometry %dx%d '%s' '%s:-'" % (const.convert,x,y,self.src,cnv)
|
||||||
im = PIL.Image.open(self.src)
|
signal.signal (signal.SIGCHLD, signal.SIG_DFL)
|
||||||
if im.mode != 'RGB':
|
r,w = popen2.popen2(cmd)
|
||||||
im.draft('RGB',im.size)
|
buf = r.read()
|
||||||
im = im.convert("RGB")
|
r.close()
|
||||||
im.save(g,pil.upper())
|
w.close()
|
||||||
g.seek(0)
|
return buf
|
||||||
buf = g.read()
|
|
||||||
g.close()
|
|
||||||
return buf
|
|
||||||
|
|
||||||
def fmt_scale_data(self,x,y,pil):
|
|
||||||
im = PIL.Image.open(self.src)
|
|
||||||
im.thumbnail((x,y))
|
|
||||||
if im.mode != 'RGB':
|
|
||||||
im.draft('RGB',im.size)
|
|
||||||
im = im.convert("RGB")
|
|
||||||
return im.tostring(pil,"RGB")
|
|
||||||
|
|
||||||
def jpg_thumbnail(self,dest,width,height):
|
def jpg_thumbnail(self,dest,width,height):
|
||||||
self.fmt_thumbnail(dest,width,height,"jpeg")
|
self.fmt_thumbnail(dest,width,height,"jpeg")
|
||||||
@ -151,16 +103,4 @@ class ImgManip:
|
|||||||
return self.fmt_scale_data(x,y,"eps")
|
return self.fmt_scale_data(x,y,"eps")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
img = ImgManip(sys.argv[1])
|
|
||||||
img.jpg_thumbnail("foo.jpg",50,50)
|
|
||||||
img.png_thumbnail("foo.png",50,50)
|
|
||||||
img.eps_thumbnail("foo.eps",50,50)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,12 +112,11 @@ class MediaView:
|
|||||||
self.list.connect('button-press-event',self.on_button_press_event)
|
self.list.connect('button-press-event',self.on_button_press_event)
|
||||||
self.list.connect('key-press-event',self.key_press)
|
self.list.connect('key-press-event',self.key_press)
|
||||||
self.selection.connect('changed',self.on_select_row)
|
self.selection.connect('changed',self.on_select_row)
|
||||||
if not (RelImage.is_pil() or RelImage.is_cnv() ):
|
if not RelImage.is_cnv():
|
||||||
WarningDialog(_("Thumbnails not available")
|
WarningDialog(_("Thumbnails not available")
|
||||||
,_("There is no suitable tool to generate thumbnails for the images. "
|
,_("There is no suitable tool to generate thumbnails for the images. "
|
||||||
"If you would like to enable this feature, "
|
"If you would like to enable this feature, "
|
||||||
"install Python Imaging Library (PIL), available at http://www.pythonware.com/products/pil/ "
|
"install ImageMagick, available at http://www.imagemagick.org/"))
|
||||||
"or ImageMagick, available at http://www.imagemagick.org/"))
|
|
||||||
self.columns = []
|
self.columns = []
|
||||||
self.build_columns()
|
self.build_columns()
|
||||||
self.build_tree()
|
self.build_tree()
|
||||||
|
@ -42,6 +42,7 @@ import pango
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from RelLib import *
|
from RelLib import *
|
||||||
|
import accent
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -266,7 +267,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
|||||||
if col == 0:
|
if col == 0:
|
||||||
return iter
|
return iter
|
||||||
elif col == COLUMN_NAME_SORT:
|
elif col == COLUMN_NAME_SORT:
|
||||||
return iter.upper()
|
return accent.deaccent(iter.upper())
|
||||||
else:
|
else:
|
||||||
return u''
|
return u''
|
||||||
else:
|
else:
|
||||||
|
@ -92,7 +92,7 @@ class PeopleView:
|
|||||||
for column in self.columns:
|
for column in self.columns:
|
||||||
self.person_tree.remove_column(column)
|
self.person_tree.remove_column(column)
|
||||||
|
|
||||||
column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0,weight=9)
|
column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0,weight=PeopleModel.COLUMN_BOLD)
|
||||||
column.set_resizable(gtk.TRUE)
|
column.set_resizable(gtk.TRUE)
|
||||||
column.set_min_width(225)
|
column.set_min_width(225)
|
||||||
column.set_clickable(gtk.TRUE)
|
column.set_clickable(gtk.TRUE)
|
||||||
@ -150,10 +150,7 @@ class PeopleView:
|
|||||||
self.person_model = PeopleModel.PeopleModel(db)
|
self.person_model = PeopleModel.PeopleModel(db)
|
||||||
if not maps[0]:
|
if not maps[0]:
|
||||||
self.build_tree()
|
self.build_tree()
|
||||||
if gtk.pygtk_version >= (2,3,92):
|
self.sort_model = gtk.TreeModelSort(self.person_model).filter_new()
|
||||||
self.sort_model = gtk.TreeModelSort(self.person_model).filter_new()
|
|
||||||
else:
|
|
||||||
self.sort_model = gtk.TreeModelSort(self.person_model)
|
|
||||||
self.sort_model.set_visible_column(PeopleModel.COLUMN_VIEW)
|
self.sort_model.set_visible_column(PeopleModel.COLUMN_VIEW)
|
||||||
self.person_tree.set_model(self.sort_model)
|
self.person_tree.set_model(self.sort_model)
|
||||||
|
|
||||||
@ -264,10 +261,7 @@ class PeopleView:
|
|||||||
|
|
||||||
def redisplay_person_list(self,person):
|
def redisplay_person_list(self,person):
|
||||||
self.person_model = PeopleModel.PeopleModel(self.parent.db)
|
self.person_model = PeopleModel.PeopleModel(self.parent.db)
|
||||||
if gtk.pygtk_version >= (2,3,92):
|
self.sort_model = gtk.TreeModelSort(self.person_model).filter_new()
|
||||||
self.sort_model = gtk.TreeModelSort(self.person_model).filter_new()
|
|
||||||
else:
|
|
||||||
self.sort_model = gtk.TreeModelSort(self.person_model)
|
|
||||||
self.sort_model.set_visible_column(PeopleModel.COLUMN_VIEW)
|
self.sort_model.set_visible_column(PeopleModel.COLUMN_VIEW)
|
||||||
self.person_tree.set_model(self.sort_model)
|
self.person_tree.set_model(self.sort_model)
|
||||||
|
|
||||||
|
@ -188,18 +188,6 @@ def check_thumb(source,dest,size):
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# Test if there's PIL available
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
def is_pil():
|
|
||||||
try:
|
|
||||||
from PIL import __name__ as pilname
|
|
||||||
return 1
|
|
||||||
except:
|
|
||||||
return 0
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Test if there's convert available
|
# Test if there's convert available
|
||||||
|
@ -34,6 +34,7 @@ from re import compile
|
|||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import types
|
import types
|
||||||
|
import accent
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -1832,7 +1833,7 @@ class Name(DataObj):
|
|||||||
|
|
||||||
def build_sort_name(self):
|
def build_sort_name(self):
|
||||||
if self.surname:
|
if self.surname:
|
||||||
self.sname = "%-25s%-30s%s" % (self.surname.upper(),self.first_name.upper(),self.suffix.upper())
|
self.sname = accent.deaccent("%-25s%-30s%s" % (self.surname.upper(),self.first_name.upper(),self.suffix.upper()))
|
||||||
else:
|
else:
|
||||||
self.sname = "@"
|
self.sname = "@"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user