View Single Post
Old 07-19-2012, 02:43 AM   #1
SauliusP.
Plugin developer
SauliusP. can name that song in three notesSauliusP. can name that song in three notesSauliusP. can name that song in three notesSauliusP. can name that song in three notesSauliusP. can name that song in three notesSauliusP. can name that song in three notesSauliusP. can name that song in three notesSauliusP. can name that song in three notesSauliusP. can name that song in three notesSauliusP. can name that song in three notesSauliusP. can name that song in three notes
 
SauliusP.'s Avatar
 
Posts: 108
Karma: 24394
Join Date: Feb 2012
Location: Lithuania
Device: Kindle
External plugin: how to add PluginWidget into conversion window?

After pressing "C" and bringing up the conversion windows, on the left sidebar one can choose various options. According to selected output format there is also a button for the output, e.g. "EPUB Output" or "MOBI Output". When converting from some specific formats, like PDF, there is also "PDF Input". I've found these panels are developed as PluginWidgets with UI_Form.

I am working on DOCX Input plugin, which I would like to have such "DOCX Input" widget. I have created it, added to package initialization, but it does not appear. Then I've checked Calibre's code and found, what in my opinion shows it, that only "native" plugins can have those PluginWidgets. The code snippet here:

def config_widget_for_input_plugin(plugin):
name = plugin.name.lower().replace(' ', '_')
try:
return importlib.import_module(
'calibre.gui2.convert.'+name).PluginWidget
except ImportError:
pass

Not sure, if this same procedure should load also external plugin's Widgets. Also, I believe, this widget should appear in "Common Options" to set some properties to be "sticky" or "default". Currenly my workaround is simple ConfigWidget. But it is very inconvenient, when for some particular document one wants to check particular options and needs to navigate deeply into plugin's configuration via "Customize Plugin"...

So is there a possibility for external plugin to have PluginWidget and if yes, how to properly do that? When it is simply put into dependencies, it does not appear. And if it is not possible, could I request such a feature in "some next" Calibre version?

The root cause, I believe, my DOCX Input is the only external InputFormatPlugin and I'm facing a lot of pioneering problems.

And the last question. Is it possible to use JSON config for PluginWidget? Currently all those widgets use OptionRecommendation.

Regards.
SauliusP. is offline   Reply With Quote