home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / calibre-0.7.26.msi / file_1366 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-10-31  |  2.7 KB  |  57 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __license__ = 'GPL v3'
  5. __copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
  6. __docformat__ = 'restructuredtext en'
  7. from calibre.gui2.preferences import ConfigWidgetBase, test_widget, AbortCommit
  8. from calibre.gui2.preferences.tweaks_ui import Ui_Form
  9. from calibre.gui2 import error_dialog
  10. from calibre.utils.config import read_raw_tweaks, write_tweaks
  11.  
  12. class ConfigWidget(ConfigWidgetBase, Ui_Form):
  13.     
  14.     def genesis(self, gui):
  15.         self.gui = gui
  16.         self.current_tweaks.textChanged.connect(self.changed)
  17.  
  18.     
  19.     def changed(self, *args):
  20.         self.changed_signal.emit()
  21.  
  22.     
  23.     def initialize(self):
  24.         (deft, curt) = read_raw_tweaks()
  25.         self.current_tweaks.blockSignals(True)
  26.         self.current_tweaks.setPlainText(curt.decode('utf-8'))
  27.         self.current_tweaks.blockSignals(False)
  28.         self.default_tweaks.setPlainText(deft.decode('utf-8'))
  29.  
  30.     
  31.     def restore_defaults(self):
  32.         ConfigWidgetBase.restore_defaults(self)
  33.         (deft, curt) = read_raw_tweaks()
  34.         self.current_tweaks.setPlainText(deft.decode('utf-8'))
  35.  
  36.     
  37.     def commit(self):
  38.         raw = unicode(self.current_tweaks.toPlainText()).encode('utf-8')
  39.         
  40.         try:
  41.             exec raw
  42.         except:
  43.             import traceback
  44.             error_dialog(self, _('Invalid tweaks'), _('The tweaks you entered are invalid, try resetting the tweaks to default and changing them one by one until you find the invalid setting.'), det_msg = traceback.format_exc(), show = True)
  45.             raise AbortCommit('abort')
  46.  
  47.         write_tweaks(raw)
  48.         ConfigWidgetBase.commit(self)
  49.         return True
  50.  
  51.  
  52. if __name__ == '__main__':
  53.     from PyQt4.Qt import QApplication
  54.     app = QApplication([])
  55.     test_widget('Advanced', 'Tweaks')
  56.  
  57.