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 07-28-2014, 03:35 PM   #1
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,548
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Editor plugin question

Is it possible for an editor plugin to leave an ebook in an unchanged (not needing to be saved) state?

At first I thought it might be :
Code:
self.boss.commit_all_editors_to_container()
or
Code:
self.boss.add_savepoint()
that was leaving the ebook in a "dirty" state, but commenting them out made no difference. Right now, I can open a book; run a plugin that checks a few things and makes no changes to the container itself; immediately close the book, and I'll be prompted about unsaved changes.

"self.boss.show_current_diff()" even shows no changes (between current, the checkpoint my plugin creates, and the "Start of editing session" ) and I'm still prompted to save the book when closing.

If it's not possible for an editor plugin to leave an ebook in a "clean" state, just let me know so I can stop trying to figure out what--in my plugin--is dirtying" it up!
DiapDealer is offline   Reply With Quote
Old 07-28-2014, 09:50 PM   #2
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Yes, I hit that yesterday while playing with my Sort CSS plugin. I was simply writing lots of stuff to the console to get a better idea of what was in the files and not making changes, but I was still prompted to save changes when I exited.

OK, I just looked through my code and commented out all the things I thought it could be. Still had the update needed. But, the first pass I missed one. After the display of the differences I have

Code:
self.boss.apply_container_update_to_gui()
That seems to be the trigger. Even if I don't actually make any changes, executing that line will mark the file as dirty and need a save. That's probably reasonable.
davidfor is offline   Reply With Quote
Advert
Old 07-28-2014, 10:23 PM   #3
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,548
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by davidfor View Post
Code:
self.boss.apply_container_update_to_gui()
That seems to be the trigger. Even if I don't actually make any changes, executing that line will mark the file as dirty and need a save. That's probably reasonable.
Ah ... thanks for that! I can just create my own clean/dirty flag and then apply_container_update_to_gui() only when it's actually necessary.

Thanks again.
DiapDealer is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calibre plugin question Firestorm1 Plugins 3 12-20-2013 11:30 AM
Metadata Editor Question locomouse Sigil 14 02-22-2013 02:12 PM
Question on Index editor rpitkin49 Sigil 10 12-14-2012 04:44 PM
Another plugin dev question DiapDealer Plugins 2 12-11-2010 01:46 PM
Plugin Developer Question KevinH Plugins 3 10-23-2010 08:17 PM


All times are GMT -4. The time now is 12:20 AM.


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