2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
3
from __future__ import with_statement
6
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
7
__docformat__ = 'restructuredtext en'
10
from calibre.gui2.convert.toc_ui import Ui_Form
11
from calibre.gui2.convert import Widget
12
from calibre.gui2 import error_dialog
14
class TOCWidget(Widget, Ui_Form):
16
TITLE = _('Table of\nContents')
17
ICON = ':/images/series.svg'
18
HELP = _('Control the creation/conversion of the Table of Contents.')
20
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
21
Widget.__init__(self, parent, 'toc',
22
['level1_toc', 'level2_toc', 'level3_toc',
23
'toc_threshold', 'max_toc_links', 'no_chapters_in_toc',
24
'use_auto_toc', 'toc_filter',
27
self.db, self.book_id = db, book_id
28
self.initialize_options(get_option, get_help, db, book_id)
29
self.opt_level1_toc.set_msg(_('Level &1 TOC (XPath expression):'))
30
self.opt_level2_toc.set_msg(_('Level &2 TOC (XPath expression):'))
31
self.opt_level3_toc.set_msg(_('Level &3 TOC (XPath expression):'))
34
def pre_commit_check(self):
35
for x in ('level1', 'level2', 'level3'):
36
x = getattr(self, 'opt_'+x+'_toc')
38
error_dialog(self, _('Invalid XPath'),
39
_('The XPath expression %s is invalid.')%x.text).exec_()