~ubuntu-branches/ubuntu/karmic/calibre/karmic

« back to all changes in this revision

Viewing changes to src/calibre/gui2/convert/toc.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-30 12:49:41 UTC
  • mfrom: (1.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730124941-qjdsmri25zt8zocn
Tags: 0.6.3+dfsg-0ubuntu1
* New upstream release. Please see http://calibre.kovidgoyal.net/new_in_6/
  for the list of new features and changes.
* remove_postinstall.patch: Update for new version.
* build_debug.patch: Does not apply any more, disable for now. Might not be
  necessary any more.
* debian/copyright: Fix reference to versionless GPL.
* debian/rules: Drop obsolete dh_desktop call.
* debian/rules: Add workaround for weird Python 2.6 setuptools behaviour of
  putting compiled .so files into src/calibre/plugins/calibre/plugins
  instead of src/calibre/plugins.
* debian/rules: Drop hal fdi moving, new upstream version does not use hal
  any more. Drop hal dependency, too.
* debian/rules: Install udev rules into /lib/udev/rules.d.
* Add debian/calibre.preinst: Remove unmodified
  /etc/udev/rules.d/95-calibre.rules on upgrade.
* debian/control: Bump Python dependencies to 2.6, since upstream needs
  it now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
 
3
from __future__ import with_statement
 
4
 
 
5
__license__   = 'GPL v3'
 
6
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
 
7
__docformat__ = 'restructuredtext en'
 
8
 
 
9
 
 
10
from calibre.gui2.convert.toc_ui import Ui_Form
 
11
from calibre.gui2.convert import Widget
 
12
from calibre.gui2 import error_dialog
 
13
 
 
14
class TOCWidget(Widget, Ui_Form):
 
15
 
 
16
    TITLE = _('Table of\nContents')
 
17
    ICON  = ':/images/series.svg'
 
18
    HELP  = _('Control the creation/conversion of the Table of Contents.')
 
19
 
 
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',
 
25
                ]
 
26
                )
 
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):'))
 
32
 
 
33
 
 
34
    def pre_commit_check(self):
 
35
        for x in ('level1', 'level2', 'level3'):
 
36
            x = getattr(self, 'opt_'+x+'_toc')
 
37
            if not x.check():
 
38
                error_dialog(self, _('Invalid XPath'),
 
39
                _('The XPath expression %s is invalid.')%x.text).exec_()
 
40
                return False
 
41
        return True