Exemple #1
0
 def __init__(self, *args, **kwargs):
     self._recents = {}
     self._pinned = {}
     super().__init__(*args, **kwargs)
     reader_book_loaded.connect(self.after_loading_book)
     reader_book_unloaded.connect(self.after_unloading_book,
                                  sender=self.reader)
 def __init__(self):
     self.tts = SpeechProvider(self)
     self._current_textinfo = None
     reader_book_unloaded.connect(self._tts_on_unload, sender=self)
     reader_page_changed.connect(self._change_page_for_tts, sender=self)
     speech_engine_state_changed.connect(self._on_tts_state_changed,
                                         sender=self.tts)
Exemple #3
0
 def __init__(self):
     reader_book_loaded.connect(self.on_reader_load_unload,
                                sender=self.reader)
     reader_book_unloaded.connect(self.on_reader_load_unload,
                                  sender=self.reader)
     speech_engine_state_changed.connect(self.on_tts_state_changed,
                                         sender=self.reader.tts)
     # XXX sent explicitly to disable items upon startup
     reader_book_unloaded.send(self.reader)
Exemple #4
0
 def __post_init__(self):
     self.view.contentTextCtrl.Bind(wx.EVT_KEY_UP, self.onKeyUp,
                                    self.view.contentTextCtrl)
     reader_book_loaded.connect(self.on_book_load, sender=self.reader)
     reader_book_unloaded.connect(self.on_book_unload, sender=self.reader)
     reader_page_changed.connect(self.comments_page_handler,
                                 sender=self.reader)
     reader_page_changed.connect(self.highlight_bookmarked_positions,
                                 sender=self.reader)
     reader_page_changed.connect(self.highlight_highlighted_text,
                                 sender=self.reader)
Exemple #5
0
 def __post_init__(self):
     self.config_manager = TTSConfigManager()
     self.textCtrl = self.view.contentTextCtrl
     self.engine = None
     self._whole_page_text_info = None
     self._highlighted_ranges = set()
     restart_speech.connect(self.on_restart_speech, sender=self.view)
     reader_book_unloaded.connect(self.on_reader_unload, sender=self.reader)
     reader_page_changed.connect(self._change_page_for_tts,
                                 sender=self.reader)
     # maintain state upon book load
     self.view.add_load_handler(
         lambda s: self.on_engine_state_changed(state=SynthState.ready))
     reading_position_change.connect(self.on_reading_position_change,
                                     sender=self.view)
     self.initialize_state()
 def __post_init__(self):
     self._book_opened = threading.Event()
     self._page_turn_barrier = threading.Barrier(2)
     # Event handling
     reader_book_loaded.connect(self.on_reader_load,
                                weak=False,
                                sender=self.reader)
     reader_book_unloaded.connect(lambda s: self._book_opened.clear(),
                                  weak=False,
                                  sender=self.reader)
     self._worker_thread = threading.Thread(
         target=self.start_monitoring,
         args=(self.view.contentTextCtrl, self.reader),
         daemon=True,
         name="bookworm.continuous.reading.service",
     )
     self._worker_thread.start()
Exemple #7
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.view.add_load_handler(self.after_loading_book)
     self.search_lock = threading.RLock()
     reader_book_unloaded.connect(self.after_unloading_book,
                                  sender=self.reader)
Exemple #8
0
    def __init__(self, service):
        super().__init__()
        self.service = service
        self.view = service.view
        self._ocr_cancelled = threading.Event()
        image2textId = wx.NewIdRef()

        # Add menu items
        self.Append(
            OCRMenuIds.scanCurrentPage,
            # Translators: the label of an item in the application menubar
            _("&Scan Current Page...\tF4"),
            # Translators: the help text of an item in the application menubar
            _("Run OCR on the current page"),
        )
        self.auto_scan_item = self.Append(
            OCRMenuIds.autoScanPages,
            # Translators: the label of an item in the application menubar
            _("&Automatic OCR\tCtrl-F4"),
            # Translators: the help text of an item in the application menubar
            _("Auto run  OCR when turning pages."),
            kind=wx.ITEM_CHECK,
        )
        self.Append(
            OCRMenuIds.changeOCROptions,
            # Translators: the label of an item in the application menubar
            _("&Change OCR Options..."),
            # Translators: the help text of an item in the application menubar
            _("Change OCR options"),
        )
        self.Append(
            OCRMenuIds.scanToTextFile,
            # Translators: the label of an item in the application menubar
            _("Scan To &Text File..."),
            # Translators: the help text of an item in the application menubar
            _("Scan pages and save the text to a .txt file."),
        )
        self.Append(
            image2textId,
            # Translators: the label of an item in the application menubar
            _("Image To Text..."),
            # Translators: the help text of an item in the application menubar
            _("Run OCR on an image."),
        )
        # Add the menu to the menubar
        # Translators: the label of the OCR menu in the application menubar
        # Event handlers
        self.view.Bind(wx.EVT_MENU,
                       self.onScanCurrentPage,
                       id=OCRMenuIds.scanCurrentPage)
        self.view.Bind(wx.EVT_MENU,
                       self.onAutoScanPages,
                       id=OCRMenuIds.autoScanPages)
        self.view.Bind(wx.EVT_MENU,
                       self.onScanToTextFile,
                       id=OCRMenuIds.scanToTextFile)
        self.view.Bind(wx.EVT_MENU,
                       self.onChangeOCROptions,
                       id=OCRMenuIds.changeOCROptions)
        self.view.Bind(wx.EVT_MENU, self.onScanImageFile, id=image2textId)
        self.view.add_load_handler(self._on_reader_loaded)
        reader_book_unloaded.connect(self._on_reader_unloaded,
                                     sender=self.view.reader)
        reader_page_changed.connect(self._on_reader_page_changed,
                                    sender=self.service.reader)
        if should_auto_navigate_to_next_page:
            should_auto_navigate_to_next_page.connect(
                self.on_should_auto_navigate_to_next_page, sender=self.view)