diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2022-03-19 18:05:26 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2022-03-19 18:05:26 +0100 |
commit | 4e466fc263ef18533b1368ac7514bdf01973227b (patch) | |
tree | ed6425480e22209291077ee018858e2a7c9e26f9 /src/book.vala | |
parent | 14afa21f4a428f9a6a5788dc1fb8a3507a42d02f (diff) | |
parent | e2af6e905a98b8b90b0504bc8f245733196dd808 (diff) |
Merge branch 'feature/upstream' into develop
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 |