Allow device drivers to provide a custom message to display to the user for virtual books

This commit is contained in:
Kovid Goyal 2015-09-23 09:44:56 +05:30
parent 58a1365752
commit ac60235775
2 changed files with 8 additions and 5 deletions

View File

@ -79,7 +79,10 @@ class DevicePlugin(Plugin):
#: Set of extensions that are "virtual books" on the device
#: and therefore cannot be viewed/saved/added to library.
#: For example: ``frozenset(['kobo'])``
VIRTUAL_BOOK_EXTENSIONS = frozenset([])
VIRTUAL_BOOK_EXTENSIONS = frozenset()
#: Message to display to user for virtual book extensions.
VIRTUAL_BOOK_EXTENSION_MESSAGE = None
#: Whether to nuke comments in the copy of the book sent to the device. If
#: not None this should be short string that the comments will be replaced

View File

@ -507,10 +507,10 @@ class AddAction(InterfaceAction):
remove = set([p for p in paths if ext(p) in ve])
if remove:
paths = [p for p in paths if p not in remove]
info_dialog(self.gui, _('Not Implemented'),
_('The following books are virtual and cannot be added'
' to the calibre library:'), '\n'.join(remove),
show=True)
vmsg = getattr(self.gui.device_manager.device, 'VIRTUAL_BOOK_EXTENSION_MESSAGE', None) or _(
'The following books are virtual and cannot be added'
' to the calibre library:')
info_dialog(self.gui, _('Not Implemented'), vmsg, '\n'.join(remove), show=True)
if not paths:
return
if not paths or len(paths) == 0: