def book_opened(self, job): ef = getattr(self, '_edit_file_on_open', None) cn = getattr(self, '_clear_notify_data', True) self._edit_file_on_open = None if job.traceback is not None: if 'DRMError:' in job.traceback: from calibre.gui2.dialogs.drm_error import DRMErrorMessage return DRMErrorMessage(self.gui).exec_() return error_dialog(self.gui, _('Failed to open book'), _('Failed to open book, click Show details for more information.'), det_msg=job.traceback, show=True) if cn: self.save_manager.clear_notify_data() parse_worker.clear() container = job.result set_current_container(container) with BusyCursor(): self.current_metadata = self.gui.current_metadata = container.mi self.global_undo.open_book(container) self.gui.update_window_title() self.gui.file_list.current_edited_name = None self.gui.file_list.build(container, preserve_state=False) self.gui.action_save.setEnabled(False) self.update_global_history_actions() recent_books = list(tprefs.get('recent-books', [])) path = container.path_to_ebook if path in recent_books: recent_books.remove(path) recent_books.insert(0, path) tprefs['recent-books'] = recent_books[:10] self.gui.update_recent_books() if ef: self.gui.file_list.request_edit(ef) self.gui.toc_view.update_if_visible()
def book_opened(self, job): if job.traceback is not None: return error_dialog(self.gui, _('Failed to open book'), _('Failed to open book, click Show details for more information.'), det_msg=job.traceback, show=True) parse_worker.clear() container = job.result set_current_container(container) self.current_metadata = self.gui.current_metadata = container.mi self.global_undo.open_book(container) self.gui.update_window_title() self.gui.file_list.build(container, preserve_state=False) self.gui.action_save.setEnabled(False) self.update_global_history_actions()
def book_opened(self, job): ef = getattr(self, '_edit_file_on_open', None) cn = getattr(self, '_clear_notify_data', True) self._edit_file_on_open = None if job.traceback is not None: if 'DRMError:' in job.traceback: from calibre.gui2.dialogs.drm_error import DRMErrorMessage return DRMErrorMessage(self.gui).exec_() return error_dialog( self.gui, _('Failed to open book'), _('Failed to open book, click Show details for more information.' ), det_msg=job.traceback, show=True) if cn: self.save_manager.clear_notify_data() parse_worker.clear() container = job.result set_current_container(container) with BusyCursor(): self.current_metadata = self.gui.current_metadata = container.mi self.global_undo.open_book(container) self.gui.update_window_title() self.gui.file_list.current_edited_name = None self.gui.file_list.build(container, preserve_state=False) self.gui.action_save.setEnabled(False) self.update_global_history_actions() recent_books = list(tprefs.get('recent-books', [])) path = container.path_to_ebook if path in recent_books: recent_books.remove(path) recent_books.insert(0, path) tprefs['recent-books'] = recent_books[:10] self.gui.update_recent_books() if ef: self.gui.file_list.request_edit(ef) self.gui.toc_view.update_if_visible()