* src/latin_utf8.py: removed

* src/ReadGedcom.py: added latin_utf8 functions
* src/Spell.py: better error checking on import


svn: r5225
This commit is contained in:
Don Allingham 2005-09-24 16:41:17 +00:00
parent 522d79a1f9
commit 1c60276c14
3 changed files with 42 additions and 9 deletions

View File

@ -1,3 +1,8 @@
2005-09-24 Don Allingham <don@gramps-project.org>
* 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 <don@gramps-project.org> 2005-09-23 Don Allingham <don@gramps-project.org>
* doc/gramps-manual/C/faq.xml: more updates * doc/gramps-manual/C/faq.xml: more updates
* doc/gramps-manual/C/getstart.xml: more updates * doc/gramps-manual/C/getstart.xml: more updates

View File

@ -54,13 +54,27 @@ import Date
import DateParser import DateParser
import DisplayTrace import DisplayTrace
from ansel_utf8 import ansel_to_utf8 from ansel_utf8 import ansel_to_utf8
import latin_utf8
import Utils import Utils
import GrampsMime import GrampsMime
from bsddb import db from bsddb import db
from GedcomInfo import * from GedcomInfo import *
from QuestionDialog import ErrorDialog 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 # constants
@ -312,7 +326,7 @@ class GedcomParser:
if self.override == 1: if self.override == 1:
self.cnv = ansel_to_utf8 self.cnv = ansel_to_utf8
elif self.override == 2: elif self.override == 2:
self.cnv = latin_utf8.latin_to_utf8 self.cnv = latin_to_utf8
else: else:
self.cnv = nocnv self.cnv = nocnv
else: else:
@ -1791,7 +1805,7 @@ class GedcomParser:
elif matches[2] == "ANSEL": elif matches[2] == "ANSEL":
self.cnv = ansel_to_utf8 self.cnv = ansel_to_utf8
else: else:
self.cnv = latin_utf8.latin_to_utf8 self.cnv = latin_to_utf8
self.ignore_sub_junk(2) self.ignore_sub_junk(2)
if self.window: if self.window:
self.update(self.encoding_obj,matches[2]) self.update(self.encoding_obj,matches[2])

View File

@ -29,26 +29,40 @@ present, we default to no spell checking.
import GrampsKeys 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 success = False
try: try:
import gtk import gtk
import gtkspell import gtkspell
import locale import locale
text_view = gtk.TextView()
spell = gtkspell.Spell(text_view)
lang = locale.getlocale()[0] lang = locale.getlocale()[0]
spell.set_language(lang) gtkspell.Spell(gtk.TextView()).set_language(lang)
success = True success = True
except ImportError, msg: except ImportError, msg:
print "Spell.py:", msg print "Spell.py: ", msg
except RuntimeError,msg: except RuntimeError,msg:
print "Spell.py:", msg print "Spell.py: ", msg
except SystemError,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: class Spell:
def __init__(self,obj): def __init__(self,obj):
if success and GrampsKeys.get_spellcheck(): if success and GrampsKeys.get_spellcheck():
self.spell = gtkspell.Spell(obj) self.spell = gtkspell.Spell(obj)