12-15-2010, 04:59 AM | #1 |
US Navy, Retired
Posts: 9,864
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
|
Create area for plugin images in config directory
Update: This feature already exists.
All that was needed was for me to create a resources\images path under my calibre configuration directory and move the plugin thumbnails there. Update Complete Recently the ability to create GUI plugins was added to calibre. Many of these plugins add thumbnails to the Calibre2\resources\images folder. This works great but has one drawback. Previously all plugins, tweaks, and settings were stored in the calibre config directory. This meant I could run calibre from any computer and point to this configuration and have the exact same setup from every computer. Now the thumbnail images are hanging out in a separate spot and have to be accounted for or updated on each computer. I don't know how feasible this is but it would be convenient if there was a image area in the config directory where the added plugins could stash their thumbnails. Thus keeping all updated configuration files in the configuration directory. If this is something worth doing I'll be glad to create the ticket (most I can do given my programming knowledge is nil). Last edited by DoctorOhh; 12-15-2010 at 06:30 AM. |
12-15-2010, 05:50 AM | #2 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Can't the images be put into the config_dir\resources\images, like the other image replacements?
|
12-15-2010, 05:50 AM | #3 |
Calibre Plugins Developer
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
I'd love to have some way to keep the plugin as self contained as possible. I was reluctant to add icons to menus for the messiness it adds to installation. If it was possible for the plugin zip file to contain not just the .py code file but also the images it needs and then Calibre does "whatever it has to" after that when you install a plugin would be ideal from my perspective.
|
12-15-2010, 05:56 AM | #4 | |
Wizard
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
|
Quote:
|
|
12-15-2010, 06:16 AM | #5 |
Calibre Plugins Developer
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
If there is a solution for both fully self-contained plugin zips (a simple menu item with an icon) and user configurable plugins (like search the internet, where users want to also be able to add their own images after the plugin is installed) that sounds good to me.
What is config_dir\resources\images ? Not come across that before? |
12-15-2010, 06:19 AM | #6 | |
US Navy, Retired
Posts: 9,864
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
|
Quote:
I created the path you mentioned and moved the plugin thumbnails. Then I started calibre and the thumbnails were in the menu as expected. Unless calibre somehow caches these thumbnails I guess all that is needed is to change the directions of the plugin posts to reflect placing these images in the config\resources\images folder. Thanks Chaley for the scoop. |
|
12-15-2010, 06:21 AM | #7 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
If you create a parallel resources directory tree in your calibre configuration directory and put some things in it, then calibre will use those things in preference over the other resource directories (source, then binary). This was done during the foohaa about toolbar icons so that people could use their own images, but it works in general. For example, I have used it to debug javascript used by calibre's server.
Last edited by chaley; 12-15-2010 at 07:10 AM. |
12-15-2010, 07:03 AM | #8 |
Calibre Plugins Developer
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
Hmmm, ok, that is good to know. I did as dwanthny did of creating a resources\images subfolder, moving all the stip_* images in there, removed them from my other directories (Program Files and source code), restarted Calibre and the Search the Internet plugin worked fine. So no coding changes needed.
However before I update any instructions for gui plugins that still leaves my suggestion about installing a plugin. I think it would be nice if when you install it checks the zip for any images and if present puts them in this resources\images folder for you, to remove the manual steps. Does such functionality exist already, or should I create a ticket? |
12-15-2010, 07:06 AM | #9 |
Calibre Plugins Developer
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
Again nice to know, thanks. That icon Calibre has for "trash" gives me the willies, it looks like a Refresh button. And yeah I know it is meant to symbolise "Recycle" but as Calibre has zero undo capabilities that is misleading too. Clearly my brain works in mysterious ways...
|
12-15-2010, 08:19 AM | #10 | |
Comparer of the Ephemeris
Posts: 1,496
Karma: 424697
Join Date: Mar 2009
Device: iPad
|
Quote:
G |
|
12-15-2010, 08:28 AM | #11 |
Calibre Plugins Developer
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
|
12-15-2010, 09:22 AM | #12 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
self.plugin_path in the plugin points to the zip file. You can add code to genesis() to load images from the zip file. If you're worried about it becoming necessary for every plugin, write the code for one of your plugins and send it to me, I'll put it into a method in the GUI plugin base class so other plugins can use it easily.
|
12-15-2010, 10:11 AM | #13 | |
Calibre Plugins Developer
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
Quote:
But if that's the only accepted approach so be it. If I try to write it generically, can you give me any hints as to the sort of api/behaviour you would prefer to see so both of us don't end up rewriting it? |
|
12-15-2010, 10:36 AM | #14 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I added a load_resource method to the InterfaceAction class. See method docstring.
And as for load time, store the images in the zip file without compression then loading them from the zip file will be just as fast as loading them from the filesystem. Last edited by kovidgoyal; 12-15-2010 at 10:41 AM. |
12-15-2010, 10:47 AM | #15 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Wouldn't it be even faster if the method took a list of names and returned a dict {name: file_contents, }? That would permit the zip to be opened once to retrieve all the resources. Instead of ValueError, it could return {name: None} if it can't find a particular resource.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
New Plugin Type Idea: Library Plugin | cgranade | Plugins | 3 | 09-15-2010 12:11 PM |
Multicomputer Sync users - Do you sync the Config directory? | Starson17 | Calibre | 4 | 07-29-2010 01:07 AM |
How do I Create a Python Plugin? | Sydney's Mom | Plugins | 25 | 01-27-2010 06:26 AM |
How do I do create a directory on a PRS-500? | JSWolf | Calibre | 5 | 11-25-2009 11:53 AM |
Statusbar config? | tselling | PocketBook | 0 | 11-13-2009 10:47 AM |