Beispiel #1
0
 def _on_check_spelling_activate(self, *args):
     """Check for incorrect spelling."""
     gaupol.util.set_cursor_busy(self.window)
     try:  # Fails if no dictionary for conf.spell_check.language.
         dialog = gaupol.SpellCheckDialog(self.window, self)
     except ValueError:
         return gaupol.util.set_cursor_normal(self.window)
     gaupol.util.set_cursor_normal(self.window)
     gaupol.util.flash_dialog(dialog)
Beispiel #2
0
 def _on_check_spelling_activate(self, *args):
     """Check for incorrect spelling."""
     gaupol.util.set_cursor_busy(self.window)
     try:
         dialog = gaupol.SpellCheckDialog(self.window, self)
     except Exception as error:
         gaupol.util.set_cursor_normal(self.window)
         title = _('Failed to load dictionary for language "{}"')
         title = title.format(gaupol.conf.spell_check.language)
         dialog = gaupol.ErrorDialog(self.window, title, str(error))
         dialog.add_button(_("_OK"), Gtk.ResponseType.OK)
         dialog.set_default_response(Gtk.ResponseType.OK)
         return gaupol.util.flash_dialog(dialog)
     gaupol.util.set_cursor_normal(self.window)
     gaupol.util.flash_dialog(dialog)
Beispiel #3
0
 def setup_method(self, method):
     gaupol.conf.spell_check.language = "en"
     self.application = self.new_application()
     for page in self.application.pages:
         for subtitle in page.project.subtitles:
             subtitle.main_text = subtitle.main_text.replace("a", "x")
             subtitle.tran_text = subtitle.tran_text.replace("a", "x")
         page.reload_view_all()
     self.dialog = gaupol.SpellCheckDialog(self.application.window,
                                           self.application)
     # Avoid adding words to either enchant's or a backend's
     # personal word list or gaupol's personal replacement list.
     self.dialog._checker.dict.add = lambda *args: None
     self.dialog._personal_dir = aeidon.temp.create_directory()
     self.dialog.show()
Beispiel #4
0
 def setup_method(self, method):
     # Don't interact with the config files at all.
     aeidon.SpellChecker.add_to_personal = aeidon.SpellChecker.add_to_session
     aeidon.SpellChecker.read_replacements = lambda *args: None
     aeidon.SpellChecker.write_replacements = lambda *args: None
     language = self.get_spell_check_language("en")
     gaupol.conf.spell_check.language = language
     self.application = self.new_application()
     for page in self.application.pages:
         for subtitle in page.project.subtitles:
             subtitle.main_text = subtitle.main_text.replace("a", "x")
             subtitle.tran_text = subtitle.tran_text.replace("a", "x")
         page.reload_view_all()
     self.dialog = gaupol.SpellCheckDialog(self.application.window,
                                           self.application)
     self.dialog.show()
 def test___init____replacements(self):
     basename = "{}.repl".format(gaupol.conf.spell_check.language)
     path = os.path.join(self.dialog._personal_dir, basename)
     open(path, "w").write("a|b\nc|d\n")
     gaupol.SpellCheckDialog(self.application.window,
                             self.application)