mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-04-28 21:43:08 +02:00
Add a few more ensure books
This commit is contained in:
parent
1c9d837e08
commit
e50e00b855
1 changed files with 12 additions and 1 deletions
|
|
@ -554,6 +554,8 @@ def add_files(self):
|
|||
show_font_face_rule_for_font_files(c, added_fonts, self.gui)
|
||||
|
||||
def add_cover(self):
|
||||
if not self.ensure_book():
|
||||
return
|
||||
d = AddCover(current_container(), self.gui)
|
||||
d.import_requested.connect(self.do_add_file)
|
||||
try:
|
||||
|
|
@ -567,7 +569,8 @@ def add_cover(self):
|
|||
finally:
|
||||
d.import_requested.disconnect()
|
||||
|
||||
def ensure_book(self, msg):
|
||||
def ensure_book(self, msg=None):
|
||||
msg = msg or _('No book is currently open. You must first open a book.')
|
||||
if current_container() is None:
|
||||
error_dialog(self.gui, _('No book open'), msg, show=True)
|
||||
return False
|
||||
|
|
@ -601,6 +604,8 @@ def insert_inline_toc(self):
|
|||
self.edit_file(name, 'html')
|
||||
|
||||
def polish(self, action, name, parent=None):
|
||||
if not self.ensure_book():
|
||||
return
|
||||
from calibre.gui2.tweak_book.polish import get_customization, show_report
|
||||
customization = get_customization(action, name, parent or self.gui)
|
||||
if customization is None:
|
||||
|
|
@ -682,6 +687,8 @@ def manage_fonts_subset(self):
|
|||
# Renaming {{{
|
||||
|
||||
def rationalize_folders(self):
|
||||
if not self.ensure_book():
|
||||
return
|
||||
c = current_container()
|
||||
if not c.SUPPORTS_FILENAMES:
|
||||
return error_dialog(self.gui, _('Not supported'),
|
||||
|
|
@ -848,6 +855,8 @@ def ask_to_show_current_diff(self, name, title, msg, allow_revert=True, to_conta
|
|||
self.show_current_diff(allow_revert=allow_revert, to_container=to_container)
|
||||
|
||||
def compare_book(self):
|
||||
if not self.ensure_book():
|
||||
return
|
||||
self.commit_all_editors_to_container()
|
||||
c = current_container()
|
||||
path = choose_files(self.gui, 'select-book-for-comparison', _('Choose book'), filters=[
|
||||
|
|
@ -975,6 +984,8 @@ def rename_class(self, class_name):
|
|||
'No class {} found to change').format(class_name), show=True)
|
||||
|
||||
def set_semantics(self):
|
||||
if not self.ensure_book():
|
||||
return
|
||||
self.commit_all_editors_to_container()
|
||||
c = current_container()
|
||||
if c.book_type == 'azw3':
|
||||
|
|
|
|||
Loading…
Reference in a new issue