diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 5936d640c..4704bd0a5 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,8 @@ +2005-09-24 Don Allingham + * src/latin_utf8.py: removed + * src/ReadGedcom.py: added latin_utf8 functions + * src/Spell.py: better error checking on import + 2005-09-23 Don Allingham * doc/gramps-manual/C/faq.xml: more updates * doc/gramps-manual/C/getstart.xml: more updates diff --git a/gramps2/src/ReadGedcom.py b/gramps2/src/ReadGedcom.py index cdd6ca8f4..02eb19aeb 100644 --- a/gramps2/src/ReadGedcom.py +++ b/gramps2/src/ReadGedcom.py @@ -54,13 +54,27 @@ import Date import DateParser import DisplayTrace from ansel_utf8 import ansel_to_utf8 -import latin_utf8 import Utils import GrampsMime from bsddb import db from GedcomInfo import * from QuestionDialog import ErrorDialog +#------------------------------------------------------------------------- +# +# latin/utf8 conversions +# +#------------------------------------------------------------------------- + +def utf8_to_latin(s): + return s.encode('iso-8859-1','replace') + +def latin_to_utf8(s): + if type(s) == type(u''): + return s + else: + return unicode(s,'iso-8859-1') + #------------------------------------------------------------------------- # # constants @@ -312,7 +326,7 @@ class GedcomParser: if self.override == 1: self.cnv = ansel_to_utf8 elif self.override == 2: - self.cnv = latin_utf8.latin_to_utf8 + self.cnv = latin_to_utf8 else: self.cnv = nocnv else: @@ -1791,7 +1805,7 @@ class GedcomParser: elif matches[2] == "ANSEL": self.cnv = ansel_to_utf8 else: - self.cnv = latin_utf8.latin_to_utf8 + self.cnv = latin_to_utf8 self.ignore_sub_junk(2) if self.window: self.update(self.encoding_obj,matches[2]) diff --git a/gramps2/src/Spell.py b/gramps2/src/Spell.py index 289cbcd4c..eadccfb55 100644 --- a/gramps2/src/Spell.py +++ b/gramps2/src/Spell.py @@ -29,26 +29,40 @@ present, we default to no spell checking. import GrampsKeys +#----------------------------------------------------------- +# +# Attempt to instantiate a gtkspell instance to check for +# any errors. If it succeeds, set a success flag so that we +# know to use the spelling check in the future +# +#------------------------------------------------------------ + success = False try: import gtk import gtkspell import locale - text_view = gtk.TextView() - spell = gtkspell.Spell(text_view) lang = locale.getlocale()[0] - spell.set_language(lang) + gtkspell.Spell(gtk.TextView()).set_language(lang) success = True except ImportError, msg: - print "Spell.py:", msg + print "Spell.py: ", msg except RuntimeError,msg: - print "Spell.py:", msg + print "Spell.py: ", msg except SystemError,msg: - print "Spell.py:", msg + msg = _("Spelling checker is not available for %s") % lang + print "Spell.py: %s" % msg +#----------------------------------------------------------- +# +# Spell - if the initial test succeeded, attach a gtkspell +# instance to the passed TextView instance +# +#------------------------------------------------------------ class Spell: + def __init__(self,obj): if success and GrampsKeys.get_spellcheck(): self.spell = gtkspell.Spell(obj)