support newer version of gtkspell3

svn: r20542
This commit is contained in:
Josip Pisoj 2012-10-08 15:53:09 +00:00
parent ec018b8fcc
commit 1d3a4efc89

View File

@ -62,6 +62,12 @@ if repository.enumerate_versions("Gtkspell"):
HAVE_GTKSPELL = True HAVE_GTKSPELL = True
except: except:
pass pass
elif repository.enumerate_versions("GtkSpell"):
try:
from gi.repository import GtkSpell as Gtkspell
HAVE_GTKSPELL = True
except:
pass
if not HAVE_GTKSPELL: if not HAVE_GTKSPELL:
LOG.warn(_("Spelling checker is not installed")) LOG.warn(_("Spelling checker is not installed"))
@ -108,7 +114,10 @@ class Spell(object):
else: else:
try: try:
#transfer full GTK object, so assign to an attribute! #transfer full GTK object, so assign to an attribute!
self.gtkspell_spell = Gtkspell.Spell.new() if Gtkspell._namespace == "Gtkspell":
self.gtkspell_spell = Gtkspell.Spell.new()
elif Gtkspell._namespace == "GtkSpell":
self.gtkspell_spell = Gtkspell.Checker.new()
success = self.gtkspell_spell.attach(self.textview) success = self.gtkspell_spell.attach(self.textview)
self._active_spellcheck = spellcheck_code self._active_spellcheck = spellcheck_code
except: except:
@ -120,9 +129,12 @@ class Spell(object):
if spellcheck_code == 'on': if spellcheck_code == 'on':
return return
else: else:
self.gtkspell_spell = Gtkspell.Spell.get_from_text_view(self.textview) if Gtkspell._namespace == "Gtkspell":
self.gtkspell_spell.detach() self.gtkspell_spell = Gtkspell.Spell.get_from_text_view(self.textview)
self._active_spellcheck = spellcheck_code elif Gtkspell._namespace == "GtkSpell":
self.gtkspell_spell = Gtkspell.Checker.get_from_text_view(self.textview)
self.gtkspell_spell.detach()
self._active_spellcheck = spellcheck_code
# Public API # Public API