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 02-28-2013, 05:16 AM   #1
Apprentice Alf
Member
Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.
 
Apprentice Alf's Avatar
 
Posts: 14
Karma: 1236266
Join Date: Dec 2010
Device: None
FileTypePlugin, config_widget, JSONConfig and Cancel

I am working on a FileTypePlugin with a preferences dialog implemented using config_widget, and preferences stored using JSONConfig.

When my config_widget object initialises, I copy my preferences from my JSONConfig object to local copies in the config_widget object. All changes made by the config_widget are to these local copies.

When the user exists the config_widget using the OK button, my save_settings function is called, which copies the preferences back into the JSONConfig object, which writes the preferences out to the .json disk file.

This all works fine.

When the user exits the config_widget using the Cancel button, my save_settings function is not called, and my JSONConfig preferences and disk file remain unchanged.

This all works fine.

The problem is that when the configuration dialog is next opened, my config_widget is already initialised, and retains the local copy of the preferences that may not match the preferences in my JSONConfig object.

What function do I need to add to my config_widget object so that I can copy the actual JSONConfig preferences to the config_widget local copy of the preferences every time the configuration dialog is opened, not just the first time?

I tried adding an initialize() function, but it never got called.

I hope that this is just something that I've missed in the documentation....
Apprentice Alf is offline   Reply With Quote
Old 02-28-2013, 05:21 AM   #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,842
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You should be instantiating a new config widget every tim config_widget() is called on your plugin. If you want to re-use an existing config_widget then you have to manually re-initialize it. calibre itself, will just call config_widget() blindly everytime it needs to reconfigure. See the do_user_config() method in customize/__init__.py
kovidgoyal is online now   Reply With Quote
Old 02-28-2013, 12:40 PM   #3
Apprentice Alf
Member
Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.
 
Apprentice Alf's Avatar
 
Posts: 14
Karma: 1236266
Join Date: Dec 2010
Device: None
Thank you Kovid. By checking the sample plugin, I found my mistake (which was, of course, not in the place I was looking for it).

I am a little embarrassed to admit it was a failure to make a copy of the some of the preferences. Instead I was just getting another reference to the same object.
Apprentice Alf is offline   Reply With Quote
Old 02-28-2013, 12:41 PM   #4
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,842
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Sith happens
kovidgoyal is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Will you cancel your Netflix? markbot Lounge 53 10-11-2011 07:34 AM
Content cancel a search hey Amazon Kindle 1 03-10-2011 03:20 PM
JSONConfig has no delete method meme Development 2 02-24-2011 08:38 AM
config_widget doesn't allow early exit meme Plugins 12 02-19-2011 11:42 AM
"cannot import name JSONConfig" on launching calibre .42 hakan42 Calibre 4 02-27-2010 03:37 AM


All times are GMT -4. The time now is 10:45 PM.


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