diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2022-03-20 09:13:50 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2022-03-20 09:13:50 +0100 |
commit | aafaa7c3ff1f88dadbad34559adab7b35be8542b (patch) | |
tree | 11f3ff35af220dd659d42e5f87d29b5d5ca073cb /src/book.vala | |
parent | 055f6f3e01bb718bfdd61331e1b13b0cdba6d718 (diff) | |
parent | e01ac9786891513c1cb628ca0a0374436057cc3b (diff) |
Merge branch 'release/debian/42.0-1'debian/42.0-1
Diffstat (limited to 'src/book.vala')
-rw-r--r-- | src/book.vala | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/book.vala b/src/book.vala index 798fe98..d2aa54d 100644 --- a/src/book.vala +++ b/src/book.vala @@ -136,10 +136,14 @@ public class Book : Object return pages.index (page); } - public async void save_async (string mime_type, int quality, File file, ProgressionCallback? progress_cb, Cancellable? cancellable = null) throws Error + public async void save_async (string mime_type, int quality, File file, + bool postproc_enabled, string postproc_script, string postproc_arguments, bool postproc_keep_original, + ProgressionCallback? progress_cb, Cancellable? cancellable = null) throws Error { var book_saver = new BookSaver (); - yield book_saver.save_async (this, mime_type, quality, file, progress_cb, cancellable); + yield book_saver.save_async (this, mime_type, quality, file, + postproc_enabled, postproc_script, postproc_arguments, postproc_keep_original, + progress_cb, cancellable); } } @@ -155,12 +159,15 @@ private class BookSaver private AsyncQueue<WriteTask> write_queue; private ThreadPool<EncodeTask> encoder; private SourceFunc save_async_callback; + private Postprocessor postprocessor = new Postprocessor(); /* save_async get called in the main thread to start saving. It * distributes all encode tasks to other threads then yield so * the ui can continue operating. The method then return once saving * is completed, cancelled, or failed */ - public async void save_async (Book book, string mime_type, int quality, File file, ProgressionCallback? progression_callback, Cancellable? cancellable) throws Error + public async void save_async (Book book, string mime_type, int quality, File file, + bool postproc_enabled, string postproc_script, string postproc_arguments, bool postproc_keep_original, + ProgressionCallback? progression_callback, Cancellable? cancellable) throws Error { var timer = new Timer (); @@ -239,6 +246,23 @@ private class BookSaver timer.stop (); debug ("Save time: %f seconds", timer.elapsed (null)); + + if ( postproc_enabled ) { + /* Perform post-processing */ + timer = new Timer (); + var return_code = postprocessor.process(postproc_script, + mime_type, // MIME Type + postproc_keep_original, // Keep Original + file.get_path(), // Filename + postproc_arguments // Arguments + ); + if ( return_code != 0 ) { + warning ("Postprocessing script execution failed. "); + } + timer.stop (); + debug ("Postprocessing time: %f seconds", timer.elapsed (null)); + } + } /* Those methods are run in the encoder threads pool. It process |