Code for #7131 - implementing SUPPORTS_BACKLOADING

This commit is contained in:
Charles Haley 2010-10-11 11:23:39 +01:00
parent b9499d7fc7
commit 4e8115a753
3 changed files with 13 additions and 1 deletions

View File

@ -39,6 +39,10 @@ class DevicePlugin(Plugin):
#: Whether the metadata on books can be set via the GUI.
CAN_SET_METADATA = ['title', 'authors', 'collections']
# Set this to True if the books on the device are files that the GUI can
# access in order to add the books from the device to the library
SUPPORTS_BACKLOADING = False
#: Path separator for paths to books on device
path_sep = os.sep

View File

@ -94,6 +94,9 @@ class Device(DeviceConfig, DevicePlugin):
EBOOK_DIR_CARD_B = ''
DELETE_EXTS = []
# USB disk-based devices can see the book files on the device, so can
# copy these back to the library
SUPPORTS_BACKLOADING = True
def reset(self, key='-1', log_packets=False, report_progress=None,
detected_device=None):

View File

@ -19,7 +19,12 @@ class AddToLibraryAction(InterfaceAction):
self.qaction.triggered.connect(self.add_books_to_library)
def location_selected(self, loc):
enabled = loc != 'library'
enabled = False
if loc != 'library':
if self.gui.device_manager.is_device_connected:
device = self.gui.device_manager.connected_device
if device is not None:
enabled = getattr(device, 'SUPPORTS_BACKLOADING', False)
self.qaction.setEnabled(enabled)
def add_books_to_library(self, *args):