GTK3: Working spellcheck using changes branch of:
https://github.com/manisandro/gtkspell3/tree/changes svn: r20130
This commit is contained in:
parent
f1ccd09cfc
commit
e908a84b1e
@ -51,7 +51,7 @@ LOG = logging.getLogger(".Spell")
|
|||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import gtkspell
|
from gi.repository import Gtkspell
|
||||||
HAVE_GTKSPELL = True
|
HAVE_GTKSPELL = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAVE_GTKSPELL = False
|
HAVE_GTKSPELL = False
|
||||||
@ -100,19 +100,21 @@ class Spell(object):
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
gtkspell_spell = gtkspell.Spell(self.textview)
|
#transfer full GTK object, so assign to an attribute!
|
||||||
|
self.gtkspell_spell = Gtkspell.Spell.new()
|
||||||
|
success = self.gtkspell_spell.attach(self.textview)
|
||||||
self._active_spellcheck = spellcheck_code
|
self._active_spellcheck = spellcheck_code
|
||||||
except:
|
except:
|
||||||
# attaching the spellchecker will fail if
|
# attaching the spellchecker will fail if
|
||||||
# the language does not exist
|
# the language does not exist
|
||||||
# and presumably if there is no dictionary
|
# and presumably if there is no dictionary
|
||||||
pass
|
LOG.warn(_("Spelling checker could not be attached to TextView"))
|
||||||
else:
|
else:
|
||||||
if spellcheck_code == 'on':
|
if spellcheck_code == 'on':
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
gtkspell_spell = gtkspell.get_from_text_view(self.textview)
|
self.gtkspell_spell = Gtkspell.Spell.get_from_text_view(self.textview)
|
||||||
gtkspell_spell.detach()
|
self.gtkspell_spell.detach()
|
||||||
self._active_spellcheck = spellcheck_code
|
self._active_spellcheck = spellcheck_code
|
||||||
|
|
||||||
# Public API
|
# Public API
|
||||||
@ -120,7 +122,7 @@ class Spell(object):
|
|||||||
def get_all_spellchecks(self):
|
def get_all_spellchecks(self):
|
||||||
"""Get the list of installed spellcheck names."""
|
"""Get the list of installed spellcheck names."""
|
||||||
return self._spellcheck_options.values()
|
return self._spellcheck_options.values()
|
||||||
|
|
||||||
def set_active_spellcheck(self, spellcheck):
|
def set_active_spellcheck(self, spellcheck):
|
||||||
"""Set active spellcheck by it's name."""
|
"""Set active spellcheck by it's name."""
|
||||||
for code, name in self._spellcheck_options.items():
|
for code, name in self._spellcheck_options.items():
|
||||||
@ -131,4 +133,3 @@ class Spell(object):
|
|||||||
def get_active_spellcheck(self):
|
def get_active_spellcheck(self):
|
||||||
"""Get the name of the active spellcheck."""
|
"""Get the name of the active spellcheck."""
|
||||||
return self._spellcheck_options[self._active_spellcheck]
|
return self._spellcheck_options[self._active_spellcheck]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user