From ec9723a390b7d686a8739bc7f7bb4e45865a3e52 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 18 Aug 2004 03:55:55 +0000 Subject: [PATCH] * 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 --- ChangeLog | 10 ++++ src/GrampsBSDDB.py | 2 +- src/ImgManip.py | 122 ++++++++++++--------------------------------- src/MediaView.py | 5 +- src/PeopleModel.py | 3 +- src/PeopleView.py | 12 ++--- src/RelImage.py | 12 ----- src/RelLib.py | 3 +- 8 files changed, 51 insertions(+), 118 deletions(-) diff --git a/ChangeLog b/ChangeLog index 00882c97d..62ecd7883 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-08-17 Don Allingham + * 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 * src/FamilyView.py (spouse_changed): Update display. diff --git a/src/GrampsBSDDB.py b/src/GrampsBSDDB.py index f1f592670..211a40024 100644 --- a/src/GrampsBSDDB.py +++ b/src/GrampsBSDDB.py @@ -130,7 +130,7 @@ class GrampsBSDDB(GrampsDbBase): for name in names: a[unicode(name)] = 1 vals = a.keys() - vals.sort() + vals.sort(accent.sort_by_accent) return vals def get_person_event_type_list(self): diff --git a/src/ImgManip.py b/src/ImgManip.py index a041ce2db..a9f9e4719 100644 --- a/src/ImgManip.py +++ b/src/ImgManip.py @@ -27,92 +27,44 @@ import signal # Check for the python imaging library # #------------------------------------------------------------------------- -try: - import PIL.Image - import StringIO - PIL.Image.init() - no_pil = 0 -except: - import popen2 - import gtk - no_pil = 1 + +import popen2 +import gtk class ImgManip: def __init__(self,source): self.src = source - if no_pil: - - def size(self): - 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) - h = int(height) - 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 size(self): + 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) + h = int(height) + cmd = "%s -geometry %dx%d '%s' '%s:%s'" % (const.convert,w,h,self.src,cnv,dest) + os.system(cmd) - def fmt_convert(self,dest,pil): - im = PIL.Image.open(self.src) - if im.mode != 'RGB': - im.draft('RGB',im.size) - im = im.convert("RGB") - im.save(dest,pil.upper()) + 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_data(self,pil): - g = StringIO.StringIO() - im = PIL.Image.open(self.src) - if im.mode != 'RGB': - im.draft('RGB',im.size) - im = im.convert("RGB") - im.save(g,pil.upper()) - g.seek(0) - 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 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 def jpg_thumbnail(self,dest,width,height): self.fmt_thumbnail(dest,width,height,"jpeg") @@ -151,16 +103,4 @@ class ImgManip: 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) - - - - diff --git a/src/MediaView.py b/src/MediaView.py index 13f1f5523..09ebc6e3f 100644 --- a/src/MediaView.py +++ b/src/MediaView.py @@ -112,12 +112,11 @@ class MediaView: self.list.connect('button-press-event',self.on_button_press_event) self.list.connect('key-press-event',self.key_press) 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") ,_("There is no suitable tool to generate thumbnails for the images. " "If you would like to enable this feature, " - "install Python Imaging Library (PIL), available at http://www.pythonware.com/products/pil/ " - "or ImageMagick, available at http://www.imagemagick.org/")) + "install ImageMagick, available at http://www.imagemagick.org/")) self.columns = [] self.build_columns() self.build_tree() diff --git a/src/PeopleModel.py b/src/PeopleModel.py index 15ced0c2b..c69a55bd7 100644 --- a/src/PeopleModel.py +++ b/src/PeopleModel.py @@ -42,6 +42,7 @@ import pango # #------------------------------------------------------------------------- from RelLib import * +import accent #------------------------------------------------------------------------- # @@ -266,7 +267,7 @@ class PeopleModel(gtk.GenericTreeModel): if col == 0: return iter elif col == COLUMN_NAME_SORT: - return iter.upper() + return accent.deaccent(iter.upper()) else: return u'' else: diff --git a/src/PeopleView.py b/src/PeopleView.py index 3702a9c6e..6fbe165c8 100644 --- a/src/PeopleView.py +++ b/src/PeopleView.py @@ -92,7 +92,7 @@ class PeopleView: for column in self.columns: 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_min_width(225) column.set_clickable(gtk.TRUE) @@ -150,10 +150,7 @@ class PeopleView: self.person_model = PeopleModel.PeopleModel(db) if not maps[0]: self.build_tree() - if gtk.pygtk_version >= (2,3,92): - self.sort_model = gtk.TreeModelSort(self.person_model).filter_new() - else: - self.sort_model = gtk.TreeModelSort(self.person_model) + self.sort_model = gtk.TreeModelSort(self.person_model).filter_new() self.sort_model.set_visible_column(PeopleModel.COLUMN_VIEW) self.person_tree.set_model(self.sort_model) @@ -264,10 +261,7 @@ class PeopleView: def redisplay_person_list(self,person): 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() - else: - self.sort_model = gtk.TreeModelSort(self.person_model) + self.sort_model = gtk.TreeModelSort(self.person_model).filter_new() self.sort_model.set_visible_column(PeopleModel.COLUMN_VIEW) self.person_tree.set_model(self.sort_model) diff --git a/src/RelImage.py b/src/RelImage.py index a74c66239..892e7ded9 100644 --- a/src/RelImage.py +++ b/src/RelImage.py @@ -188,18 +188,6 @@ def check_thumb(source,dest,size): 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 diff --git a/src/RelLib.py b/src/RelLib.py index 0d734876b..3374c1cc3 100644 --- a/src/RelLib.py +++ b/src/RelLib.py @@ -34,6 +34,7 @@ from re import compile import os import os.path import types +import accent from gettext import gettext as _ #------------------------------------------------------------------------- @@ -1832,7 +1833,7 @@ class Name(DataObj): def build_sort_name(self): 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: self.sname = "@"