04-28-2011, 05:48 AM | #1 |
Wizard
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
|
User Interface Plugin Creation/Debug process
I've read through the plugin tutorial on the main Calibre site, and there was one bit I wanted to clarify.
Is this the primary method to modify/debug these plugins?:
|
04-28-2011, 05:59 AM | #2 | |
Wizard
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
|
To answer my own question, I just missed this on the first read through the tutorial:
Quote:
Last edited by ldolse; 04-28-2011 at 06:21 AM. |
|
Advert | |
|
04-28-2011, 06:02 AM | #3 |
Calibre Plugins Developer
Posts: 4,673
Karma: 2162246
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
I posted a batch file here that I use.
I make this part of my project folder in Eclipse so in the package explorer I can directly just double click on it. This rebuilds the zip, re-installs it into Calibre and starts calibre in debug mode. You just need to remember to close Calibre before you next run it again. You can directly test preferences configuration screens etc using __main__ test stubs in the class files but I've never really found that particularly useful for user interface plugins, mainly because I am wanting to test the result of changing a setting rather than just the configuration screen itself. |
04-28-2011, 08:13 AM | #4 |
Sigil developer
Posts: 1,274
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
|
This is how I do it as well. A simple batch script (I include mine in the plugin's zip). And a second one when running from source just to set the source path. No need to uninstall - just install on top. And Calibre will remember your icon/menu setup so you don't have to re-add it. I used to have test stubs but they weren't of any real use once I got it running.
There is a lot of run, fix typo, run, tweak, run Sometimes even run, forget to tweak, run again and get very confused And with a device its wait 5/6 seconds before you can test... |
04-28-2011, 10:49 AM | #5 |
creator of calibre
Posts: 44,356
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I just added a command lie option to shutdown a running calibre instance. So now you can do this:
Code:
calibre -s; sleep 4s; zip -R /path/to/plugin/zip/file.zip *; calibre |
Advert | |
|
04-28-2011, 11:18 AM | #6 |
Comparer of the Ephemeris
Posts: 1,496
Karma: 424697
Join Date: Mar 2009
Device: iPad
|
Kovid, would it be possible to use reload() if running in debug mode and calling a UserInterfacePlugin?
I've been using a variation on this approach that dynamically loads my actual plugin code from the zipped contents in the plugin. It depends upon some custom macros in my editor that modify both the unzipped copy of the plugin as well as the original plugin source (which needs to be rebuilt when exiting). Using this approach, I can simply rerun the plugin in place without losing context. It seems like the concept of using reload() might be portable to the trunk. G |
04-28-2011, 11:22 AM | #7 |
creator of calibre
Posts: 44,356
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Dynamic reloading is fraught with a lot of complications. This is because there may be references to the plugin class/an object instantiated from the class held in various places. The reload would have to invalidate an recreate all those references.
|
04-28-2011, 11:28 AM | #8 |
Comparer of the Ephemeris
Posts: 1,496
Karma: 424697
Join Date: Mar 2009
Device: iPad
|
Yes, that makes sense for builtin plugins. But it seems that custom UI plugins wouldn't have active references to them in other parts of the code base. They tend to run modally, although there are some that don't (KiwiDude's Temp Marker comes to mind).
G |
04-28-2011, 11:36 AM | #9 |
creator of calibre
Posts: 44,356
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Well, the gui object holds a reference to the plugin object and the qaction built from the object.
While that could probably be managed, there' no guarantee that the plugin did not stick references to objects created in it anywhere else. All in all, this is not a can of worms I want to open. With the -s switch, developing a plugin is now almost as easy as developing calibre source code (the only difference is an extra 4 second wait when launching calibre). I'm pretty happy with that. |
04-28-2011, 12:09 PM | #10 |
creator of calibre
Posts: 44,356
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I should add that the zipplugin mechanism is reload friendly. So you can add code to your plugin that does
reload(module) to have it reload some previously loaded module from your plugin. |
04-29-2011, 02:59 AM | #11 | |
Wizard
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
|
Quote:
So using the reload(module) action could be temporarily tied directly into the plugin during the debugging phase as an action inside the plugin UI, correct? Based on the rest of the discussion it doesn't sound like something one would want to leave in the release version, but that could be a handy bit of code to comment/uncomment while making changes. |
|
04-29-2011, 10:18 AM | #12 |
creator of calibre
Posts: 44,356
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Yes, that's the idea, put it in while developing and take it out later.
|
04-29-2011, 10:54 AM | #13 |
Sigil & calibre developer
Posts: 2,487
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
|
Couldn't you set the reload code as a plugin tweak? This way you won't have to make changes for the release version.
|
04-29-2011, 10:57 AM | #14 |
creator of calibre
Posts: 44,356
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Yeah, that would work.
|
11-04-2011, 05:36 AM | #15 |
Wizard
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
|
I just made a sticky on this topic with links to any relevant data - the forum is generally the first place I always think to go on this topic when I'm getting back into plugin tweaking and it seems like I'm always seeking out this thread even when I could go to the docs. Anyway let me know if anything else useful on the topic should go into the sticky. I don't believe the reload tweak made it past the discussion phase.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Reset Sony Device Interface plugin? | NLight95 | Devices | 2 | 04-04-2011 06:40 PM |
Writing an interface action plugin | kiwidude | Plugins | 21 | 11-11-2010 04:11 PM |
Device interface plugin - nook | badmadbug | Plugins | 2 | 09-06-2010 11:03 AM |
User Interface settings | Ponderstibbons | Calibre | 1 | 09-05-2010 01:16 PM |
iLiad User interface programming | eth777 | iRex Developer's Corner | 3 | 12-23-2007 05:58 AM |