Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 12-07-2023, 09:32 PM   #1
teagles
Junior Member
teagles began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Dec 2023
Device: Kindle Oasis
Understanding the Container/GUI lifecycle

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:
  1. 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
  2. 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
teagles is offline   Reply With Quote
Old 12-07-2023, 10:17 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,866
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
If you are doing a lot of modifications it will take time, so show a busy cursor or run it in a thread and show a progress dialog.
kovidgoyal is online now   Reply With Quote
Reply

Tags
container, plugin development


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[GUI Plugin] Save Virtual Libraries To Column (GUI) chaley Plugins 14 04-04-2021 05:25 AM
container.mi and unicode jackie_w Development 7 05-27-2018 10:49 AM
Lifecycle of a new Kindle rguion Amazon Kindle 16 10-27-2017 11:41 AM
Recreating Container.xhtml SigilBear Sigil 42 06-27-2017 05:32 PM
Model update lifecycle jerryleejr Kobo Reader 17 08-24-2016 01:12 PM


All times are GMT -4. The time now is 09:35 AM.


MobileRead.com is a privately owned, operated and funded community.