home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / calibre-0.7.26.msi / file_1174 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-10-31  |  2.3 KB  |  45 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 import error_dialog
  8. from calibre.gui2.actions import InterfaceAction
  9. from calibre.gui2.dialogs.tweak_epub import TweakEpub
  10.  
  11. class TweakEpubAction(InterfaceAction):
  12.     name = 'Tweak ePub'
  13.     action_spec = (_('Tweak ePub'), 'trim.png', _('Make small changes to ePub format books'), _('T'))
  14.     dont_add_to = frozenset([
  15.         'toolbar-device',
  16.         'context-menu-device'])
  17.     action_type = 'current'
  18.     
  19.     def genesis(self):
  20.         self.qaction.triggered.connect(self.edit_epub_in_situ)
  21.  
  22.     
  23.     def edit_epub_in_situ(self, *args):
  24.         row = self.gui.library_view.currentIndex()
  25.         if not row.isValid():
  26.             return error_dialog(self.gui, _('Cannot tweak ePub'), _('No book selected'), show = True)
  27.         book_id = self.gui.library_view.model().id(row)
  28.         
  29.         try:
  30.             path_to_epub = self.gui.library_view.model().db.format_abspath(book_id, 'EPUB', index_is_id = True)
  31.         except:
  32.             row.isValid()
  33.             path_to_epub = None
  34.  
  35.         if not path_to_epub:
  36.             return error_dialog(self.gui, _('Cannot tweak ePub'), _('No ePub available. First convert the book to ePub.'), show = True)
  37.         dlg = TweakEpub(self.gui, path_to_epub)
  38.         dlg.cleanup()
  39.  
  40.     
  41.     def update_db(self, book_id, rebuilt):
  42.         self.gui.library_view.model().db.add_format(book_id, 'EPUB', open(rebuilt, 'rb'), index_is_id = True)
  43.  
  44.  
  45.