summaryrefslogtreecommitdiff
path: root/src/book.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2022-03-19 18:05:05 +0100
committerJörg Frings-Fürst <debian@jff.email>2022-03-19 18:05:05 +0100
commit8ac2508eb094459c062d0c31b6367da393b4fa6e (patch)
treea3dd69ae2a2f90e59914e9ede6acdc94e3a6712d /src/book.vala
parent05315c3da6d3761ba95f1ae96b852768dd651c25 (diff)
New upstream version 42.0upstream/42.0
Diffstat (limited to 'src/book.vala')
-rw-r--r--src/book.vala30
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