Logo Search packages:      
Sourcecode: calibre version File versions  Download package

sending.py

#!/usr/bin/env python
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai

__license__   = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'



from calibre.gui2.preferences import ConfigWidgetBase, test_widget, \
        AbortCommit
from calibre.gui2.preferences.sending_ui import Ui_Form
from calibre.utils.config import ConfigProxy
from calibre.library.save_to_disk import config
from calibre.utils.config import prefs

class ConfigWidget(ConfigWidgetBase, Ui_Form):

    def genesis(self, gui):
        self.gui = gui
        self.proxy = ConfigProxy(config())

        r = self.register

        for x in ('send_timefmt',):
            r(x, self.proxy)

        choices = [(_('Manual management'), 'manual'),
                (_('Only on send'), 'on_send'),
                (_('Automatic management'), 'on_connect')]
        r('manage_device_metadata', prefs, choices=choices)

        self.send_template.changed_signal.connect(self.changed_signal.emit)


    def initialize(self):
        ConfigWidgetBase.initialize(self)
        self.send_template.blockSignals(True)
        self.send_template.initialize('send_to_device', self.proxy['send_template'],
                self.proxy.help('send_template'))
        self.send_template.blockSignals(False)

    def restore_defaults(self):
        ConfigWidgetBase.restore_defaults(self)
        self.send_template.set_value(self.proxy.defaults['send_template'])

    def commit(self):
        if not self.send_template.validate():
            raise AbortCommit('abort')
        self.send_template.save_settings(self.proxy, 'send_template')
        return ConfigWidgetBase.commit(self)

if __name__ == '__main__':
    from PyQt4.Qt import QApplication
    app = QApplication([])
    test_widget('Import/Export', 'Sending')


Generated by  Doxygen 1.6.0   Back to index