From ac60235775ccfcb004fe48ef141c8932409fa236 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 23 Sep 2015 09:44:56 +0530 Subject: [PATCH] Allow device drivers to provide a custom message to display to the user for virtual books --- src/calibre/devices/interface.py | 5 ++++- src/calibre/gui2/actions/add.py | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/calibre/devices/interface.py b/src/calibre/devices/interface.py index d6159b9613..c81d7fade6 100644 --- a/src/calibre/devices/interface.py +++ b/src/calibre/devices/interface.py @@ -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 diff --git a/src/calibre/gui2/actions/add.py b/src/calibre/gui2/actions/add.py index 9ed6274db0..8c7ea97104 100644 --- a/src/calibre/gui2/actions/add.py +++ b/src/calibre/gui2/actions/add.py @@ -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: