mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 14:53:06 +02:00
Add option to the user-defined device to swap main and card
This commit is contained in:
parent
7b502b06f7
commit
82367fdd93
1 changed files with 30 additions and 0 deletions
|
|
@ -66,6 +66,9 @@ class USER_DEFINED(USBMS):
|
|||
_('Card A folder') + ':::<p>' +
|
||||
_('Enter the folder where the books are to be stored. This folder '
|
||||
'is prepended to any send_to_device template') + '</p>',
|
||||
_('Swap main and card A') + ':::<p>' +
|
||||
_('Check this box if the device\'s main memory is being seen as '
|
||||
'card a and the card is being seen as main memory') + '</p>',
|
||||
]
|
||||
EXTRA_CUSTOMIZATION_DEFAULT = [
|
||||
'0xffff',
|
||||
|
|
@ -78,16 +81,19 @@ class USER_DEFINED(USBMS):
|
|||
'',
|
||||
'',
|
||||
'',
|
||||
False,
|
||||
]
|
||||
OPT_USB_VENDOR_ID = 0
|
||||
OPT_USB_PRODUCT_ID = 1
|
||||
OPT_USB_REVISION_ID = 2
|
||||
# OPT 3 isn't used
|
||||
OPT_USB_WINDOWS_MM_VEN_ID = 4
|
||||
OPT_USB_WINDOWS_MM_ID = 5
|
||||
OPT_USB_WINDOWS_CA_VEN_ID = 6
|
||||
OPT_USB_WINDOWS_CA_ID = 7
|
||||
OPT_MAIN_MEM_FOLDER = 8
|
||||
OPT_CARD_A_FOLDER = 9
|
||||
OPT_SWAP_MAIN_AND_CARD = 10
|
||||
|
||||
def initialize(self):
|
||||
self.plugin_needs_delayed_initialization = True
|
||||
|
|
@ -113,4 +119,28 @@ def do_delayed_plugin_initialization(self):
|
|||
traceback.print_exc()
|
||||
self.plugin_needs_delayed_initialization = False
|
||||
|
||||
def windows_sort_drives(self, drives):
|
||||
|
||||
if len(drives) < 2: return drives
|
||||
e = self.settings().extra_customization
|
||||
if not e[self.OPT_SWAP_MAIN_AND_CARD]:
|
||||
return drives
|
||||
main = drives.get('main', None)
|
||||
carda = drives.get('carda', None)
|
||||
if main and carda:
|
||||
drives['main'] = carda
|
||||
drives['carda'] = main
|
||||
return drives
|
||||
|
||||
def linux_swap_drives(self, drives):
|
||||
if len(drives) < 2 or not drives[1] or not drives[2]: return drives
|
||||
e = self.settings().extra_customization
|
||||
if not e[self.OPT_SWAP_MAIN_AND_CARD]:
|
||||
return drives
|
||||
drives = list(drives)
|
||||
t = drives[0]
|
||||
drives[0] = drives[1]
|
||||
drives[1] = t
|
||||
return tuple(drives)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue