From 68df332cadc7f4ba5c884306e485591063b75085 Mon Sep 17 00:00:00 2001 From: GRiker Date: Sat, 18 Sep 2010 05:14:41 -0600 Subject: [PATCH 1/8] GwR apple driver patch --- src/calibre/devices/apple/driver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/devices/apple/driver.py b/src/calibre/devices/apple/driver.py index 5fe36faf75..0946bd2f51 100644 --- a/src/calibre/devices/apple/driver.py +++ b/src/calibre/devices/apple/driver.py @@ -739,7 +739,7 @@ class ITUNES(DriverBase): # Purge the booklist, self.cached_books, thumb cache for i,bl_book in enumerate(booklists[0]): - if DEBUG: + if False: self.log.info(" evaluating '%s' by '%s' uuid:%s" % (bl_book.title, bl_book.author,bl_book.uuid)) From 4416264c0289b80a7eda510c375591f88e1ab8d4 Mon Sep 17 00:00:00 2001 From: GRiker Date: Sat, 18 Sep 2010 19:43:02 -0600 Subject: [PATCH 2/8] GwR wip tweak_epub --- src/calibre/customize/builtins.py | 6 ++++- src/calibre/gui2/actions/tweak_epub.py | 34 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100755 src/calibre/gui2/actions/tweak_epub.py diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index 68df832048..ec9f7e2bc2 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -666,13 +666,17 @@ class ActionCopyToLibrary(InterfaceActionBase): name = 'Copy To Library' actual_plugin = 'calibre.gui2.actions.copy_to_library:CopyToLibraryAction' +class ActionTweakEpub(InterfaceActionBase): + name = 'Tweak ePub' + actual_plugin = 'calibre.gui2.actions.tweak_epub:TweakEpubAction' + plugins += [ActionAdd, ActionFetchAnnotations, ActionGenerateCatalog, ActionConvert, ActionDelete, ActionEditMetadata, ActionView, ActionFetchNews, ActionSaveToDisk, ActionShowBookDetails, ActionRestart, ActionOpenFolder, ActionConnectShare, ActionSendToDevice, ActionHelp, ActionPreferences, ActionSimilarBooks, ActionAddToLibrary, ActionEditCollections, ActionChooseLibrary, - ActionCopyToLibrary] + ActionCopyToLibrary, ActionTweakEpub] # }}} diff --git a/src/calibre/gui2/actions/tweak_epub.py b/src/calibre/gui2/actions/tweak_epub.py new file mode 100755 index 0000000000..5f49c57379 --- /dev/null +++ b/src/calibre/gui2/actions/tweak_epub.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai + +__license__ = 'GPL v3' +__copyright__ = '2010, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + +from calibre.gui2.actions import InterfaceAction + +class TweakEpubAction(InterfaceAction): + + name = 'Tweak ePub' + action_spec = (_('Edit ePub in situ'), 'document_open.png', None, None) + dont_add_to = frozenset(['toolbar-device', 'context-menu-device']) + action_type = 'current' + + def genesis(self): + self.qaction.triggered.connect(self.edit_epub_in_situ) + print "gui2.actions.tweak_epub:TweakEpubAction.genesis()" + + def initialization_complete(self): + print "gui2.actions.tweak_epub:TweakEpubAction.initialization_complete()" + + def library_changed(self, db): + print "gui2.actions.tweak_epub:TweakEpubAction.library_changed()" + + def location_selected(self, loc): + print "gui2.actions.tweak_epub:TweakEpubAction.location_selected()" + + def shutting_down(self): + print "gui2.actions.tweak_epub:TweakEpubAction.shutting_down()" + + def edit_epub_in_situ(self, *args): + print "gui2.actions.tweak_epub:TweakEpubAction.edit_epub_in_situ()" From 90ff41dfb2ba554f64cb61dd5d1a6de599941b32 Mon Sep 17 00:00:00 2001 From: GRiker Date: Sun, 19 Sep 2010 03:54:39 -0600 Subject: [PATCH 3/8] KG fix for TweakEpub --- src/calibre/gui2/actions/tweak_epub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/actions/tweak_epub.py b/src/calibre/gui2/actions/tweak_epub.py index 5f49c57379..020e9c0382 100755 --- a/src/calibre/gui2/actions/tweak_epub.py +++ b/src/calibre/gui2/actions/tweak_epub.py @@ -11,7 +11,7 @@ class TweakEpubAction(InterfaceAction): name = 'Tweak ePub' action_spec = (_('Edit ePub in situ'), 'document_open.png', None, None) - dont_add_to = frozenset(['toolbar-device', 'context-menu-device']) + #dont_add_to = frozenset(['toolbar-device', 'context-menu-device']) action_type = 'current' def genesis(self): From cec2f873cb29b8868695da152467c8f9d3eb9ea5 Mon Sep 17 00:00:00 2001 From: GRiker Date: Mon, 20 Sep 2010 07:44:33 -0700 Subject: [PATCH 4/8] GwR wip tweak_epub --- src/calibre/gui2/dialogs/tweak_epub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/dialogs/tweak_epub.py b/src/calibre/gui2/dialogs/tweak_epub.py index cc5b526291..a78d26a9dc 100755 --- a/src/calibre/gui2/dialogs/tweak_epub.py +++ b/src/calibre/gui2/dialogs/tweak_epub.py @@ -117,7 +117,7 @@ class TweakEpub(QDialog, Ui_Dialog): # Write mimetype zf.write(os.path.join(self._exploded,'mimetype'), 'mimetype', compress_type=ZIP_STORED) # Write everything else - exclude_files = ['.DS_Store','mimetype','iTunesMetadata.plist'] + exclude_files = ['.DS_Store','mimetype','iTunesMetadata.plist','rebuilt.epub'] for root, dirs, files in os.walk(self._exploded): for fn in files: if fn in exclude_files: From 62d9449e88f6aa5a6a2e1234137f31ed3d9e25d9 Mon Sep 17 00:00:00 2001 From: GRiker Date: Mon, 20 Sep 2010 07:57:05 -0700 Subject: [PATCH 5/8] GwR wip tweak_epub --- src/calibre/gui2/dialogs/tweak_epub.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/dialogs/tweak_epub.py b/src/calibre/gui2/dialogs/tweak_epub.py index a78d26a9dc..c0ad79385b 100755 --- a/src/calibre/gui2/dialogs/tweak_epub.py +++ b/src/calibre/gui2/dialogs/tweak_epub.py @@ -71,8 +71,8 @@ class TweakEpub(QDialog, Ui_Dialog): prints(" killing file browser proc") #self._file_browser_proc.terminate() #self._file_browser_proc.kill() - #self._file_browser_send_signal() - #self._file_browser_proc = None + #self._file_browser_send_signal(?) + self._file_browser_proc = None # Delete directory containing exploded ePub if self._exploded is not None: @@ -93,6 +93,7 @@ class TweakEpub(QDialog, Ui_Dialog): elif iswindows: cmd = 'start explorer.exe /e,/root,%s' % self._exploded else: + # *** Kovid - need proper linux invocation here *** cmd = '' # *** Kovid - need a way of launching this process than can be killed in cleanup() *** From ec8164470b8b4ac54b2f16bba57f22a6e856be8b Mon Sep 17 00:00:00 2001 From: GRiker Date: Mon, 20 Sep 2010 19:39:33 -0700 Subject: [PATCH 6/8] GwR revisions tweak_epub --- src/calibre/gui2/dialogs/tweak_epub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/dialogs/tweak_epub.py b/src/calibre/gui2/dialogs/tweak_epub.py index c0ad79385b..379352f390 100755 --- a/src/calibre/gui2/dialogs/tweak_epub.py +++ b/src/calibre/gui2/dialogs/tweak_epub.py @@ -25,7 +25,6 @@ class TweakEpub(QDialog, Ui_Dialog): To do: - need way to kill file browser proc in cleanup() - - Windows file browser launch - linux file browser launch ''' @@ -109,6 +108,7 @@ class TweakEpub(QDialog, Ui_Dialog): zipextract(self._epub, self._exploded) self.display_exploded() self.rebuild_button.setEnabled(True) + self.explode_button.setEnabled(False) def rebuild(self): if DEBUG: From 3dfaa2cdaaeda5f56d5d39b02df61b1371942a58 Mon Sep 17 00:00:00 2001 From: GRiker Date: Mon, 20 Sep 2010 20:10:17 -0700 Subject: [PATCH 7/8] change to use open_local_file --- src/calibre/gui2/dialogs/tweak_epub.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/calibre/gui2/dialogs/tweak_epub.py b/src/calibre/gui2/dialogs/tweak_epub.py index 379352f390..a967ca310a 100755 --- a/src/calibre/gui2/dialogs/tweak_epub.py +++ b/src/calibre/gui2/dialogs/tweak_epub.py @@ -15,6 +15,7 @@ from PyQt4.Qt import QDialog, SIGNAL from calibre import prints from calibre.constants import iswindows, isosx, DEBUG +from calibre.gui2 import open_local_file from calibre.gui2.dialogs.tweak_epub_ui import Ui_Dialog from calibre.libunzip import extract as zipextract from calibre.ptempfile import PersistentTemporaryDirectory @@ -33,7 +34,7 @@ class TweakEpub(QDialog, Ui_Dialog): self._epub = epub self._exploded = None - self._file_browser_proc = None + #self._file_browser_proc = None self._output = None # Run the dialog setup generated from tweak_epub.ui @@ -64,14 +65,6 @@ class TweakEpub(QDialog, Ui_Dialog): ''' if DEBUG: prints("gui2.dialogs.tweak_epub:TweakEpub.cleanup()") - # Kill file browser proc - if self._file_browser_proc: - if DEBUG: - prints(" killing file browser proc") - #self._file_browser_proc.terminate() - #self._file_browser_proc.kill() - #self._file_browser_send_signal(?) - self._file_browser_proc = None # Delete directory containing exploded ePub if self._exploded is not None: @@ -87,6 +80,7 @@ class TweakEpub(QDialog, Ui_Dialog): ''' if DEBUG: prints("gui2.dialogs.tweak_epub:TweakEpub.display_exploded()") + ''' if isosx: cmd = 'open %s' % self._exploded elif iswindows: @@ -97,6 +91,8 @@ class TweakEpub(QDialog, Ui_Dialog): # *** Kovid - need a way of launching this process than can be killed in cleanup() *** self._file_browser_proc = subprocess.Popen(cmd, shell=True) + ''' + open_local_file(self._exploded) def explode(self): if DEBUG: From 88f980ad186859708aceb3907ae59d4052648ff3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 20 Sep 2010 21:33:43 -0600 Subject: [PATCH 8/8] News download: Don't add inline table of contents when downloading news for the Kindle --- src/calibre/gui2/tools.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/calibre/gui2/tools.py b/src/calibre/gui2/tools.py index 7a516bb4ff..2f0452a773 100644 --- a/src/calibre/gui2/tools.py +++ b/src/calibre/gui2/tools.py @@ -217,6 +217,10 @@ def fetch_scheduled_recipe(arg): if 'output_profile' in ps: recs.append(('output_profile', ps['output_profile'], OptionRecommendation.HIGH)) + if ps['output_profile'] == 'kindle': + recs.append(('no_inline_toc', True, + OptionRecommendation.HIGH)) + lf = load_defaults('look_and_feel') if lf.get('base_font_size', 0.0) != 0.0: recs.append(('base_font_size', lf['base_font_size'],