Remove the option to show a second tool bar from Preferences->Look & Feel. Instead go to Preferences->Toolbars and add items to the second toolbar to control exactly what is visible there. Fixes #742686 (Customize Toolbar only for Single (unsplit))

This commit is contained in:
Kovid Goyal 2011-03-27 12:07:50 -06:00
commit 625e1bd470
11 changed files with 158 additions and 81 deletions

View File

@ -210,21 +210,23 @@ record type usual length name comments
114 versionnumber 114 versionnumber
115 sample 115 sample
116 startreading 116 startreading
118 retail price (as text) 117 3 adult Mobipocket Creator adds this if Adult only is checked; contents: "yes"
119 retail price currency (as text) 118 retail price As text, e.g. "4.99"
201 coveroffset 119 retail price currency As text, e.g. "USD"
202 thumboffset 201 4 coveroffset Add to first image field in Mobi Header to find PDB record containing the cover image
202 4 thumboffset Add to first image field in Mobi Header to find PDB record containing the thumbnail cover image
203 hasfakecover 203 hasfakecover
204 204 Unknown 204 4 Creator Software Records 204-207 are usually the same for all books from a certain source, e.g. 1-6-2-41 for Baen and 201-1-0-85 for project gutenberg, 200-1-0-85 for amazon when converted to a 32 bit integer.
205 205 Unknown 205 4 Creator Major Version
206 206 Unknown 206 4 Creator Minor Version
207 207 Unknown 207 4 Creator Build Number
208 208 Unknown 208 watermark
300 300 Unknown 209 tamper proof keys Used by the Kindle (and Android app) for generating book-specific PIDs.
401 clippinglimit 300 fontsignature
401 1 clippinglimit
402 publisherlimit 402 publisherlimit
403 403 Unknown 403 403 Unknown 1 - Text to Speech disabled; 0 - Text to Speech enabled
404 404 ttsflag 404 1 404 ttsflag
501 4 cdetype PDOC - Personal Doc; 501 4 cdetype PDOC - Personal Doc;
EBOK - ebook; EBOK - ebook;
502 lastupdatetime 502 lastupdatetime
@ -287,9 +289,9 @@ content at the beginning of the following record. The trailing entry ends with
a byte containing a count of the overlapping bytes plus additional flags. a byte containing a count of the overlapping bytes plus additional flags.
offset bytes content comments offset bytes content comments
0 0-3 N terminal bytes 0 0-3 N terminal bytes
of a multibyte of a multibyte
character character
N 1 Size & flags bits 1-2 encode N, use of bits 3-8 is unknown N 1 Size & flags bits 1-2 encode N, use of bits 3-8 is unknown
@ -328,6 +330,102 @@ programs may ignore them entirely. They are stored at the end of the file itself
so the full file needs to be scanned when loaded to find them. so the full file needs to be scanned when loaded to find them.
Image Records
-------------
If the file contains images, they follow the text blocks, with each image using a
single block. The 4096-byte record size in the PalmDoc header applies only to
text records; image records may be larger.
Magic Records
-------------
In some cases, MobiPocket Creator adds a 2-zero-byte record after the text
records in a file. This record is not included in the "record count" of text
records in the PalmDoc header, and is also not used as the "first non-book
index" in the MOBI header. (If the 2-zero-byte record is present, the index of
the following block is used as the "first non-book index".)
MobiPocket Creator also ends files with three records: 'FLIS', 'FCIS', and
'end-of-file', in that order. The 'FLIS' and 'FCIS' records do not seem to be
necessary for MobiPocket Reader or the Amazon Kindle 2 to read the file. The
'end-of-file' record might be necessary.
FLIS Record
-----------
The FLIS record appears to have a fixed value. The meaning of the values is not known.
offset bytes content comments
0 4 identifier the characters F L I S (0x46 0x4c 0x49 0x53)
4 4 ? fixed value: 8
8 2 ? fixed value: 65
10 2 ? fixed value: 0
12 4 ? fixed value: 0
16 4 ? fixed value: -1
20 2 ? fixed value: 1
22 2 ? fixed value: 3
24 4 ? fixed value: 3
28 4 ? fixed value: 1
32 4 ? fixed value: -1
FCIS Record
-----------
The FCIS record appears to have mostly fixed values.
offset bytes content comments
0 4 identifier the characters F C I S (0x46 0x43 0x49 0x53)
4 4 ? fixed value: 20
8 4 ? fixed value: 16
12 4 ? fixed value: 1
16 4 ? fixed value: 0
20 4 ? text length (the same value as "text length" in the PalmDoc header)
24 4 ? fixed value: 0
28 4 ? fixed value: 32
32 4 ? fixed value: 8
36 2 ? fixed value: 1
38 2 ? fixed value: 1
40 4 ? fixed value: 0
End-of-file Record
------------------
The end-of-file record is a fixed 4-byte record. While the last two bytes
appear to be a CRLF marker, the meaning of the first two bytes is unknown.
offset bytes content comments
0 1 ? fixed value: 233 (0xe9)
1 1 ? fixed value: 142 (0x8e)
2 1 ? fixed value: 13 (0x0d)
3 1 ? fixed value: 10 (0x0a)
SRCS Record
-----------
kindlegen creates a record whose content is a zip archive of all source files
(i.e., .opf, .ncx, .htm, .jpg, ...) given to the command and puts it in the
generated MOBI file. The record begins with the "SRCS" signature and is
located just before the #End-of-file Record.
MOBI files created with Mobipocket creator, Amazon's Personal Document Service,
or Kindle Direct Publishing (former Amazon DTP) don't include SRCS record.
In a past, kindlegen had an undocumented option to suppress this record, but
the option was removed in 2010.
offset bytes content comments
0 4 identifier "SRCS" (0x53 0x52 0x43 0x53)
4 4 ? fixed value(?): 0x00000010
8 4 ? fixed value(?): 0x0000002f
12 4 ? fixed value(?): 0x00000001
16 zip The zip archive continues to the end of this record
MBP MBP
--- ---

View File

@ -1098,7 +1098,7 @@ class MobiWriter(object):
nodeCountValue = 0x80 if nodeCountValue == 0 else nodeCountValue nodeCountValue = 0x80 if nodeCountValue == 0 else nodeCountValue
tbSequence += chr(nodeCountValue) tbSequence += chr(nodeCountValue)
else : else :
tbSequence += decint(0x00, DECINT_FORWARD) # arg1 = 0x80 tbSequence += decint(0x00, DECINT_FORWARD) # arg1 = 0x80
tbSequence += decint(len(tbSequence) + 1, DECINT_FORWARD) # len tbSequence += decint(len(tbSequence) + 1, DECINT_FORWARD) # len
@ -1188,7 +1188,7 @@ class MobiWriter(object):
toc = self._oeb.toc toc = self._oeb.toc
nodes = list(toc.iter())[1:] nodes = list(toc.iter())[1:]
toc_conforms = True toc_conforms = True
for (i, child) in enumerate(nodes) : for child in nodes:
if child.klass == "periodical" and child.depth() != 3 or \ if child.klass == "periodical" and child.depth() != 3 or \
child.klass == "section" and child.depth() != 2 or \ child.klass == "section" and child.depth() != 2 or \
child.klass == "article" and child.depth() != 1 : child.klass == "article" and child.depth() != 1 :
@ -1644,14 +1644,14 @@ class MobiWriter(object):
self._oeb.log('Generating INDX ...') self._oeb.log('Generating INDX ...')
self._primary_index_record = None self._primary_index_record = None
# Build the NCXEntries and INDX # Build the NCXEntries and INDX
indxt, indxt_count, indices, last_name = self._generate_indxt() indxt, indxt_count, indices, last_name = self._generate_indxt()
if last_name is None: if last_name is None:
self._oeb.log.warn('Input document has no TOC. No index generated.') self._oeb.log.warn('Input document has no TOC. No index generated.')
return return
# Assemble the INDX0[0] and INDX1[0] output streams # Assemble the INDX0[0] and INDX1[0] output streams
indx1 = StringIO() indx1 = StringIO()
indx1.write('INDX'+pack('>I', 0xc0)) # header length indx1.write('INDX'+pack('>I', 0xc0)) # header length
@ -2310,10 +2310,8 @@ class MobiWriter(object):
parentIndex = sectionParent.parentIndex parentIndex = sectionParent.parentIndex
self._write_section_node(indxt, indices, sectionParent.myCtocMapIndex, index, offset, length, c, firstArticle, lastArticle, parentIndex) self._write_section_node(indxt, indices, sectionParent.myCtocMapIndex, index, offset, length, c, firstArticle, lastArticle, parentIndex)
last_name = "%04X"%c
# articles # articles
for (i, article) in enumerate(list(sectionParent.articles)) : for article in list(sectionParent.articles):
index = article.myCtocMapIndex index = article.myCtocMapIndex
offset = article.startAddress offset = article.startAddress
length = article.articleLength length = article.articleLength
@ -2413,7 +2411,6 @@ class MobiWriter(object):
# <navPoint> Article(s) child.depth() = 1 # <navPoint> Article(s) child.depth() = 1
# <navpoint> Section 2 # <navpoint> Section 2
documentType = "unknown"
sectionIndices = [] sectionIndices = []
sectionParents = [] sectionParents = []
currentSection = 0 # Starting section number currentSection = 0 # Starting section number
@ -2421,7 +2418,6 @@ class MobiWriter(object):
indxt, indices, c = StringIO(), StringIO(), 0 indxt, indices, c = StringIO(), StringIO(), 0
indices.write('IDXT') indices.write('IDXT')
c = 0
last_name = None last_name = None
# 'book', 'periodical' or None # 'book', 'periodical' or None
@ -2449,8 +2445,8 @@ class MobiWriter(object):
if self.opts.verbose > 3 : if self.opts.verbose > 3 :
self._oeb.logger.info("unknown document type %12.12s \tdepth:%d" % (child.title, child.depth()) ) self._oeb.logger.info("unknown document type %12.12s \tdepth:%d" % (child.title, child.depth()) )
# Original code starts here # Original code starts here
# test first node for depth/class # test first node for depth/class
entries = list(toc.iter())[1:] entries = list(toc.iter())[1:]
for (i, child) in enumerate(entries): for (i, child) in enumerate(entries):
if not child.title or not child.title.strip(): if not child.title or not child.title.strip():

View File

@ -29,6 +29,8 @@ gprefs.defaults['action-layout-toolbar'] = (
'Connect Share', None, 'Remove Books', None, 'Help', 'Preferences', 'Connect Share', None, 'Remove Books', None, 'Help', 'Preferences',
) )
gprefs.defaults['action-layout-toolbar-child'] = ()
gprefs.defaults['action-layout-toolbar-device'] = ( gprefs.defaults['action-layout-toolbar-device'] = (
'Add Books', 'Edit Metadata', None, 'Convert Books', 'View', 'Add Books', 'Edit Metadata', None, 'Convert Books', 'View',
'Send To Device', None, None, 'Location Manager', None, None, 'Send To Device', None, None, 'Location Manager', None, None,
@ -52,7 +54,6 @@ gprefs.defaults['show_splash_screen'] = True
gprefs.defaults['toolbar_icon_size'] = 'medium' gprefs.defaults['toolbar_icon_size'] = 'medium'
gprefs.defaults['automerge'] = 'ignore' gprefs.defaults['automerge'] = 'ignore'
gprefs.defaults['toolbar_text'] = 'auto' gprefs.defaults['toolbar_text'] = 'auto'
gprefs.defaults['show_child_bar'] = False
gprefs.defaults['font'] = None gprefs.defaults['font'] = None
gprefs.defaults['tags_browser_partition_method'] = 'first letter' gprefs.defaults['tags_browser_partition_method'] = 'first letter'
gprefs.defaults['tags_browser_collapse_at'] = 100 gprefs.defaults['tags_browser_collapse_at'] = 100

View File

@ -75,7 +75,7 @@ class InterfaceAction(QObject):
dont_remove_from = frozenset([]) dont_remove_from = frozenset([])
all_locations = frozenset(['toolbar', 'toolbar-device', 'context-menu', all_locations = frozenset(['toolbar', 'toolbar-device', 'context-menu',
'context-menu-device']) 'context-menu-device', 'toolbar-child'])
#: Type of action #: Type of action
#: 'current' means acts on the current view #: 'current' means acts on the current view

View File

@ -12,7 +12,7 @@ class AddToLibraryAction(InterfaceAction):
name = 'Add To Library' name = 'Add To Library'
action_spec = (_('Add books to library'), 'add_book.png', action_spec = (_('Add books to library'), 'add_book.png',
_('Add books to your calibre library from the connected device'), None) _('Add books to your calibre library from the connected device'), None)
dont_add_to = frozenset(['toolbar', 'context-menu']) dont_add_to = frozenset(['toolbar', 'context-menu', 'toolbar-child'])
action_type = 'current' action_type = 'current'
def genesis(self): def genesis(self):

View File

@ -121,7 +121,7 @@ class SendToDeviceAction(InterfaceAction):
name = 'Send To Device' name = 'Send To Device'
action_spec = (_('Send to device'), 'sync.png', None, _('D')) action_spec = (_('Send to device'), 'sync.png', None, _('D'))
dont_remove_from = frozenset(['toolbar-device']) dont_remove_from = frozenset(['toolbar-device'])
dont_add_to = frozenset(['toolbar', 'context-menu']) dont_add_to = frozenset(['toolbar', 'context-menu', 'toolbar-child'])
def genesis(self): def genesis(self):
self.qaction.triggered.connect(self.do_sync) self.qaction.triggered.connect(self.do_sync)

View File

@ -12,7 +12,7 @@ class EditCollectionsAction(InterfaceAction):
name = 'Edit Collections' name = 'Edit Collections'
action_spec = (_('Manage collections'), None, action_spec = (_('Manage collections'), None,
_('Manage the collections on this device'), None) _('Manage the collections on this device'), None)
dont_add_to = frozenset(['toolbar', 'context-menu']) dont_add_to = frozenset(['toolbar', 'context-menu', 'toolbar-child'])
action_type = 'current' action_type = 'current'
def genesis(self): def genesis(self):

View File

@ -278,11 +278,14 @@ class ToolBar(QToolBar): # {{{
pass pass
def build_bar(self): def build_bar(self):
self.child_bar.setVisible(gprefs['show_child_bar'])
self.showing_donate = False self.showing_donate = False
showing_device = self.location_manager.has_device showing_device = self.location_manager.has_device
actions = '-device' if showing_device else '' mactions = '-device' if showing_device else ''
actions = gprefs['action-layout-toolbar'+actions] mactions = gprefs['action-layout-toolbar'+mactions]
cactions = gprefs['action-layout-toolbar-child']
show_child = len(cactions) > 0
self.child_bar.setVisible(show_child)
for ac in self.added_actions: for ac in self.added_actions:
m = ac.menu() m = ac.menu()
@ -292,44 +295,30 @@ class ToolBar(QToolBar): # {{{
self.clear() self.clear()
self.child_bar.clear() self.child_bar.clear()
self.added_actions = [] self.added_actions = []
self.spacers = [Spacer(self.child_bar), Spacer(self.child_bar),
Spacer(self), Spacer(self)]
self.child_bar.addWidget(self.spacers[0])
if gprefs['show_child_bar']:
self.addWidget(self.spacers[2])
for what in actions: for bar, actions in ((self, mactions), (self.child_bar, cactions)):
if what is None and not gprefs['show_child_bar']: for what in actions:
self.addSeparator() if what is None:
elif what == 'Location Manager': bar.addSeparator()
for ac in self.location_manager.available_actions: elif what == 'Location Manager':
self.addAction(ac) for ac in self.location_manager.available_actions:
self.added_actions.append(ac) bar.addAction(ac)
self.setup_tool_button(ac, QToolButton.MenuButtonPopup) bar.added_actions.append(ac)
elif what == 'Donate': bar.setup_tool_button(bar, ac, QToolButton.MenuButtonPopup)
self.d_widget = QWidget() elif what == 'Donate':
self.d_widget.setLayout(QVBoxLayout()) self.d_widget = QWidget()
self.d_widget.layout().addWidget(self.donate_button) self.d_widget.setLayout(QVBoxLayout())
self.addWidget(self.d_widget) self.d_widget.layout().addWidget(self.donate_button)
self.showing_donate = True bar.addWidget(self.d_widget)
elif what in self.gui.iactions: self.showing_donate = True
action = self.gui.iactions[what] elif what in self.gui.iactions:
bar = self action = self.gui.iactions[what]
if action.action_type == 'current' and gprefs['show_child_bar']: bar.addAction(action.qaction)
bar = self.child_bar self.added_actions.append(action.qaction)
bar.addAction(action.qaction) self.setup_tool_button(bar, action.qaction, action.popup_type)
self.added_actions.append(action.qaction)
self.setup_tool_button(action.qaction, action.popup_type)
self.child_bar.addWidget(self.spacers[1]) def setup_tool_button(self, bar, ac, menu_mode=None):
if gprefs['show_child_bar']: ch = bar.widgetForAction(ac)
self.addWidget(self.spacers[3])
else:
for s in self.spacers[2:]:
s.setVisible(False)
def setup_tool_button(self, ac, menu_mode=None):
ch = self.widgetForAction(ac)
if ch is None: if ch is None:
ch = self.child_bar.widgetForAction(ac) ch = self.child_bar.widgetForAction(ac)
ch.setCursor(Qt.PointingHandCursor) ch.setCursor(Qt.PointingHandCursor)
@ -345,7 +334,7 @@ class ToolBar(QToolBar): # {{{
style = Qt.ToolButtonIconOnly style = Qt.ToolButtonIconOnly
if p == 'auto' and self.preferred_width > self.width()+35 and \ if p == 'auto' and self.preferred_width > self.width()+35 and \
not gprefs['show_child_bar']: not gprefs['action-layout-toolbar-child']:
style = Qt.ToolButtonIconOnly style = Qt.ToolButtonIconOnly
self.setToolButtonStyle(style) self.setToolButtonStyle(style)

View File

@ -48,7 +48,6 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
r('disable_tray_notification', config) r('disable_tray_notification', config)
r('use_roman_numerals_for_series_number', config) r('use_roman_numerals_for_series_number', config)
r('separate_cover_flow', config, restart_required=True) r('separate_cover_flow', config, restart_required=True)
r('show_child_bar', gprefs)
choices = [(_('Small'), 'small'), (_('Medium'), 'medium'), choices = [(_('Small'), 'small'), (_('Medium'), 'medium'),
(_('Large'), 'large')] (_('Large'), 'large')]

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>670</width> <width>717</width>
<height>422</height> <height>444</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -244,13 +244,6 @@ then the tags will be displayed each on their own line.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="opt_show_child_bar">
<property name="text">
<string>&amp;Split the toolbar into two toolbars</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -208,6 +208,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
LOCATIONS = [ LOCATIONS = [
('toolbar', _('The main toolbar')), ('toolbar', _('The main toolbar')),
('toolbar-child', _('The optional second toolbar')),
('toolbar-device', _('The main toolbar when a device is connected')), ('toolbar-device', _('The main toolbar when a device is connected')),
('context-menu', _('The context menu for the books in the ' ('context-menu', _('The context menu for the books in the '
'calibre library')), 'calibre library')),