From 8ac2508eb094459c062d0c31b6367da393b4fa6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 19 Mar 2022 18:05:05 +0100 Subject: New upstream version 42.0 --- src/book.vala | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'src/book.vala') 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 write_queue; private ThreadPool 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 -- cgit v1.2.3