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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from __future__ import with_statement
  5. __license__ = 'GPL v3'
  6. __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
  7. __docformat__ = 'restructuredtext en'
  8. from PyQt4.Qt import Qt
  9. from calibre.gui2.convert.mobi_output_ui import Ui_Form
  10. from calibre.gui2.convert import Widget
  11. from calibre.gui2.widgets import FontFamilyModel
  12. from calibre.utils.fonts import fontconfig
  13. font_family_model = None
  14.  
  15. class PluginWidget(Widget, Ui_Form):
  16.     TITLE = _('MOBI Output')
  17.     HELP = _('Options specific to') + ' MOBI ' + _('output')
  18.     COMMIT_NAME = 'mobi_output'
  19.     ICON = I('mimetypes/mobi.png')
  20.     
  21.     def __init__(self, parent, get_option, get_help, db = None, book_id = None):
  22.         global font_family_model
  23.         Widget.__init__(self, parent, [
  24.             'prefer_author_sort',
  25.             'rescale_images',
  26.             'toc_title',
  27.             'dont_compress',
  28.             'no_inline_toc',
  29.             'masthead_font',
  30.             'personal_doc'])
  31.         self.db = db
  32.         self.book_id = book_id
  33.         if font_family_model is None:
  34.             font_family_model = FontFamilyModel()
  35.             
  36.             try:
  37.                 font_family_model.families = fontconfig.find_font_families(allowed_extensions = [
  38.                     'ttf'])
  39.             except:
  40.                 import traceback
  41.                 font_family_model.families = []
  42.                 print 'WARNING: Could not load fonts'
  43.                 traceback.print_exc()
  44.  
  45.             font_family_model.families.sort()
  46.             font_family_model.families[:0] = [
  47.                 _('Default')]
  48.         
  49.         self.font_family_model = font_family_model
  50.         self.opt_masthead_font.setModel(self.font_family_model)
  51.         self.initialize_options(get_option, get_help, db, book_id)
  52.  
  53.     
  54.     def set_value_handler(self, g, val):
  55.         if unicode(g.objectName()) in 'opt_masthead_font':
  56.             idx = -1
  57.             if val:
  58.                 idx = g.findText(val, Qt.MatchFixedString)
  59.             
  60.             if idx < 0:
  61.                 idx = 0
  62.             
  63.             g.setCurrentIndex(idx)
  64.             return True
  65.         return False
  66.  
  67.  
  68.