Hey y'all, I am currently working on my first Calibre Plugin, for context I discovered Calibre just about a month ago so there are still a lot of parts I'm not familiar with.
Anyway my plugin, my goal is to port one of the many Bionic Reading clones that work in browsers to the Calibre book editing tool. So far I have successfully been able to find, parse and edit a single XHTML file using most of the editor_demo_plugin as a starting point.
However my issue comes when I try to apply the modifications to the entire book. I have tried to simply:
- iterate over
Code:
container.mime_map.items()
making the modifications to the container, file by file, calling container.dirty at the end of each iteration
- then I call
Code:
self.boss.show_current_diff()
self.boss.apply_container_update_to_gui()
and a single time at the end
But the application hangs for quite a while. I suspect I am missing a crucial detail necessary to handle a full book's modification like this. Am I not calling 'container.dirty' at the right time, is this a parser caching issue? Am I not am not using 'self.boss.show_current_diff()' correctly? Do I need to be creating savepoints for each file I change? Perhaps I need to be using Threads more deliberately to distribute the work?
I attempted to block and prompt the user to give input at the end of each file modification, but I found that calling 'self.boss.show_current_diff()' multiple times just spawns multiple diff windows eventually crashing the app. I was hoping there was a way to execute the plugin, modify a single XHTML file, show the diff, wait for the user to preview it and ok or abort it, then proceed to the next file in the book until the book is finished.
Any tips on editor plugins would be greatly appreciated thanks