forked from Mirrors/apostrophe
Improve gspell_view encapsulation inside TextView
parent
c2d0bde9f8
commit
250519f319
|
@ -417,9 +417,7 @@ class MainWindow(StyledWindow):
|
||||||
status {gtk bool} -- Desired status of the spellchecking
|
status {gtk bool} -- Desired status of the spellchecking
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.text_view.gspell_view\
|
self.text_view.set_spellcheck(state.get_boolean())
|
||||||
.set_inline_spell_checking(state.get_boolean()
|
|
||||||
and not self.text_view.focus_mode)
|
|
||||||
|
|
||||||
def toggle_gradient_overlay(self, state):
|
def toggle_gradient_overlay(self, state):
|
||||||
"""Toggle the gradient overlay
|
"""Toggle the gradient overlay
|
||||||
|
|
|
@ -65,6 +65,7 @@ class TextView(Gtk.TextView):
|
||||||
self.get_buffer().connect('changed', self.on_text_changed)
|
self.get_buffer().connect('changed', self.on_text_changed)
|
||||||
|
|
||||||
# Spell checking
|
# Spell checking
|
||||||
|
self.spellcheck = True
|
||||||
self.gspell_view = Gspell.TextView.get_from_gtk_text_view(self)
|
self.gspell_view = Gspell.TextView.get_from_gtk_text_view(self)
|
||||||
self.gspell_view.basic_setup()
|
self.gspell_view.basic_setup()
|
||||||
|
|
||||||
|
@ -184,10 +185,14 @@ class TextView(Gtk.TextView):
|
||||||
and the surrounding text is greyed out."""
|
and the surrounding text is greyed out."""
|
||||||
|
|
||||||
self.focus_mode = focus_mode
|
self.focus_mode = focus_mode
|
||||||
self.gspell_view.set_inline_spell_checking(not focus_mode)
|
|
||||||
self.update_vertical_margin()
|
self.update_vertical_margin()
|
||||||
self.markup.apply()
|
self.markup.apply()
|
||||||
self.smooth_scroll_to()
|
self.smooth_scroll_to()
|
||||||
|
self.set_spellcheck(self.spellcheck)
|
||||||
|
|
||||||
|
def set_spellcheck(self, spellcheck):
|
||||||
|
self.spellcheck = spellcheck
|
||||||
|
self.gspell_view.set_inline_spell_checking(self.spellcheck and not self.focus_mode)
|
||||||
|
|
||||||
def update_horizontal_margin(self):
|
def update_horizontal_margin(self):
|
||||||
width = self.get_allocation().width
|
width = self.get_allocation().width
|
||||||
|
|
Loading…
Reference in New Issue