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

« back to all changes in this revision

Viewing changes to src/calibre/devices/usbms/deviceconfig.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
# -*- coding: utf-8 -*-
 
2
 
 
3
__license__ = 'GPL 3'
 
4
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
 
5
__docformat__ = 'restructuredtext en'
 
6
 
 
7
from calibre.utils.config import Config, ConfigProxy
 
8
 
 
9
class DeviceConfig(object):
 
10
 
 
11
    HELP_MESSAGE = _('Configure Device')
 
12
 
 
13
    @classmethod
 
14
    def _config(cls):
 
15
        klass = cls if isinstance(cls, type) else cls.__class__
 
16
        c = Config('device_drivers_%s' % klass.__name__, _('settings for device drivers'))
 
17
        c.add_opt('format_map', default=cls.FORMATS,  help=_('Ordered list of formats the device will accept'))
 
18
        c.add_opt('use_subdirs', default=True, help=_('Place files in sub directories if the device supports them'))
 
19
        c.add_opt('read_metadata', default=True, help=_('Read metadata from files on device'))
 
20
        return c
 
21
 
 
22
    @classmethod
 
23
    def _configProxy(cls):
 
24
        return ConfigProxy(cls._config())
 
25
 
 
26
    @classmethod
 
27
    def config_widget(cls):
 
28
        from calibre.gui2.device_drivers.configwidget import ConfigWidget
 
29
        cw = ConfigWidget(cls.settings(), cls.FORMATS, cls.SUPPORTS_SUB_DIRS,
 
30
            cls.MUST_READ_METADATA)
 
31
        return cw
 
32
 
 
33
    @classmethod
 
34
    def save_settings(cls, config_widget):
 
35
        cls._configProxy()['format_map'] = config_widget.format_map()
 
36
        if cls.SUPPORTS_SUB_DIRS:
 
37
            cls._configProxy()['use_subdirs'] = config_widget.use_subdirs()
 
38
        if not cls.MUST_READ_METADATA:
 
39
            cls._configProxy()['read_metadata'] = config_widget.read_metadata()
 
40
 
 
41
    @classmethod
 
42
    def settings(cls):
 
43
        return cls._config().parse()
 
44
    
 
45
    @classmethod
 
46
    def customization_help(cls, gui=False):
 
47
        return cls.HELP_MESSAGE