mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
GwR revisions wip
This commit is contained in:
parent
40718a915a
commit
60cb1c2fbe
@ -71,10 +71,3 @@ gui_pubdate_display_format = 'MMM yyyy'
|
||||
# order until the title is edited. Double-clicking on a title and hitting return
|
||||
# without changing anything is sufficient to change the sort.
|
||||
title_series_sorting = 'library_order'
|
||||
|
||||
# Apple iTunes/iDevice
|
||||
# Control whether Series name is used as Genre in iTunes/iBooks
|
||||
# If set to 'True', a Book's Series name (if one exists) will be used as the Genre
|
||||
# If set to 'False', the book's first tag beginning with an alpha character will
|
||||
# be used as the Genre
|
||||
ITUNES_use_series_as_category = False
|
||||
|
@ -10,12 +10,13 @@ from calibre.constants import __appname__, __version__, DEBUG
|
||||
from calibre import fit_image
|
||||
from calibre.constants import isosx, iswindows
|
||||
from calibre.devices.errors import UserFeedback
|
||||
from calibre.devices.usbms.deviceconfig import DeviceConfig
|
||||
from calibre.devices.interface import DevicePlugin
|
||||
from calibre.ebooks.BeautifulSoup import BeautifulSoup
|
||||
from calibre.ebooks.metadata import MetaInformation
|
||||
from calibre.ebooks.metadata.epub import set_metadata
|
||||
from calibre.library.server.utils import strftime
|
||||
from calibre.utils.config import Config, config_dir, tweaks
|
||||
from calibre.utils.config import Config, ConfigProxy, config_dir
|
||||
from calibre.utils.date import isoformat, now, parse_date
|
||||
from calibre.utils.logging import Log
|
||||
from calibre.utils.zipfile import ZipFile
|
||||
@ -34,7 +35,7 @@ if iswindows:
|
||||
import pythoncom, win32com.client
|
||||
|
||||
|
||||
class ITUNES(DevicePlugin):
|
||||
class ITUNES(DeviceConfig, DevicePlugin):
|
||||
'''
|
||||
Calling sequences:
|
||||
Initialization:
|
||||
@ -85,6 +86,15 @@ class ITUNES(DevicePlugin):
|
||||
|
||||
FORMATS = ['epub','pdf']
|
||||
|
||||
# Configuration
|
||||
HELP_MESSAGE = _('Configure Device')
|
||||
EXTRA_CUSTOMIZATION_MESSAGE = None
|
||||
EXTRA_CUSTOMIZATION_DEFAULT = None
|
||||
MUST_READ_METADATA = False
|
||||
SAVE_TEMPLATE = '{title}'
|
||||
SUPPORTS_SUB_DIRS = False
|
||||
SUPPORTS_USE_AUTHOR_SORT = False
|
||||
|
||||
# Product IDs:
|
||||
# 0x1292:iPhone 3G
|
||||
# 0x129a:iPad
|
||||
@ -163,7 +173,7 @@ class ITUNES(DevicePlugin):
|
||||
sources = None
|
||||
update_msg = None
|
||||
update_needed = False
|
||||
use_series_as_category = tweaks['ITUNES_use_series_as_category']
|
||||
use_series_as_category = False
|
||||
|
||||
# Public methods
|
||||
def add_books_to_metadata(self, locations, metadata, booklists):
|
||||
@ -512,6 +522,29 @@ class ITUNES(DevicePlugin):
|
||||
'''
|
||||
return (None,None)
|
||||
|
||||
def config_widget(self):
|
||||
'''
|
||||
Return a QWidget with settings for the device interface
|
||||
'''
|
||||
if DEBUG:
|
||||
self.log.info("ITUNES.config_widget()")
|
||||
from calibre.gui2.device_drivers.configwidget import ConfigWidget
|
||||
cw = ConfigWidget(self.settings(), self.FORMATS, self.SUPPORTS_SUB_DIRS,
|
||||
self.MUST_READ_METADATA, self.SUPPORTS_USE_AUTHOR_SORT,
|
||||
self.EXTRA_CUSTOMIZATION_MESSAGE)
|
||||
# Turn off the Save template
|
||||
cw.opt_save_template.setVisible(False)
|
||||
cw.label.setVisible(False)
|
||||
|
||||
# Repurpose the checkbox
|
||||
cw.opt_read_metadata.setText("Use Series as Genre in iTunes/iBooks")
|
||||
return cw
|
||||
|
||||
def customization_help(self,gui=False):
|
||||
if DEBUG:
|
||||
self.log.info("ITUNES.customization_help()")
|
||||
return _('Configure Device')
|
||||
|
||||
def delete_books(self, paths, end_session=True):
|
||||
'''
|
||||
Delete books at paths on device.
|
||||
@ -741,16 +774,45 @@ class ITUNES(DevicePlugin):
|
||||
'''
|
||||
self.report_progress = report_progress
|
||||
|
||||
def save_settings(self, settings_widget):
|
||||
'''
|
||||
Should save settings to disk. Takes the widget created in config_widget
|
||||
and saves all settings to disk.
|
||||
'''
|
||||
if DEBUG:
|
||||
self.log.info("ITUNES.save_settings()")
|
||||
proxy = self._configProxy()
|
||||
proxy['format_map'] = settings_widget.format_map()
|
||||
if self.SUPPORTS_SUB_DIRS:
|
||||
proxy['use_subdirs'] = settings_widget.use_subdirs()
|
||||
if not self.MUST_READ_METADATA:
|
||||
proxy['read_metadata'] = settings_widget.read_metadata()
|
||||
if self.SUPPORTS_USE_AUTHOR_SORT:
|
||||
proxy['use_author_sort'] = settings_widget.use_author_sort()
|
||||
if self.EXTRA_CUSTOMIZATION_MESSAGE:
|
||||
ec = unicode(settings_widget.opt_extra_customization.text()).strip()
|
||||
if not ec:
|
||||
ec = None
|
||||
proxy['extra_customization'] = ec
|
||||
st = unicode(settings_widget.opt_save_template.text())
|
||||
proxy['save_template'] = st
|
||||
|
||||
# Snag the read_metadata check box contents on the way by
|
||||
self.use_series_as_category = settings_widget.read_metadata()
|
||||
|
||||
def settings(self):
|
||||
'''
|
||||
Should return an opts object. The opts object should have one attribute
|
||||
`format_map` which is an ordered list of formats for the device.
|
||||
'''
|
||||
klass = self if isinstance(self, type) else self.__class__
|
||||
c = Config('device_drivers_%s' % klass.__name__, _('settings for device drivers'))
|
||||
c.add_opt('format_map', default=self.FORMATS,
|
||||
help=_('Ordered list of formats the device will accept'))
|
||||
return c.parse()
|
||||
if DEBUG:
|
||||
self.log.info("ITUNES.settings()")
|
||||
opts = self._config().parse()
|
||||
|
||||
# Repurpose the read_metadata check box
|
||||
self.use_series_as_category = opts.read_metadata
|
||||
|
||||
return opts
|
||||
|
||||
def sync_booklists(self, booklists, end_session=True):
|
||||
'''
|
||||
@ -1067,6 +1129,27 @@ class ITUNES(DevicePlugin):
|
||||
|
||||
return db_added, lb_added
|
||||
|
||||
def _config(self):
|
||||
klass = self if isinstance(self, type) else self.__class__
|
||||
c = Config('device_drivers_%s' % klass.__name__, _('settings for device drivers'))
|
||||
c.add_opt('format_map', default=self.FORMATS,
|
||||
help=_('Ordered list of formats the device will accept'))
|
||||
c.add_opt('use_subdirs', default=True,
|
||||
help=_('Place files in sub directories if the device supports them'))
|
||||
c.add_opt('read_metadata', default=True,
|
||||
help=_('Use Series as Genre in iTunes/iBooks'))
|
||||
c.add_opt('use_author_sort', default=False,
|
||||
help=_('Use author sort instead of author'))
|
||||
c.add_opt('save_template', default=self._default_save_template(),
|
||||
help=_('Template to control how books are titled in iTunes/iBooks'))
|
||||
c.add_opt('extra_customization',
|
||||
default=self.EXTRA_CUSTOMIZATION_DEFAULT,
|
||||
help=_('Extra customization'))
|
||||
return c
|
||||
|
||||
def _configProxy(self):
|
||||
return ConfigProxy(self._config())
|
||||
|
||||
def _cover_to_thumb(self, path, metadata, db_added, lb_added, format):
|
||||
'''
|
||||
assumes pythoncom wrapper for db_added
|
||||
@ -1217,6 +1300,11 @@ class ITUNES(DevicePlugin):
|
||||
|
||||
return this_book
|
||||
|
||||
def _default_save_template(self):
|
||||
from calibre.library.save_to_disk import config
|
||||
return self.SAVE_TEMPLATE if self.SAVE_TEMPLATE else \
|
||||
config().parse().send_template
|
||||
|
||||
def _delete_iTunesMetadata_plist(self,fpath):
|
||||
'''
|
||||
Delete the plist file from the file to force recache
|
||||
|
@ -429,6 +429,7 @@ class Bookmark():
|
||||
entries, = unpack('>I', data[9:13])
|
||||
current_entry = 0
|
||||
e_base = 0x0d
|
||||
self.pdf_page_offset = 0
|
||||
while current_entry < entries:
|
||||
'''
|
||||
location, = unpack('>I', data[e_base+2:e_base+6])
|
||||
|
Loading…
x
Reference in New Issue
Block a user