View Single Post
Old 04-09-2011, 10:12 PM   #4
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,230
Karma: 1345754
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
Ok, I've just released new versions of all of my plugins so they will support the possibility of skinning. Give me a yell if you experience any issues with that but it seemed to work ok from my quick testing.

Clearly there are other UI plugins by other developers that will not as yet made changes to support skinning in this way. Whether they do or not is obviously up to them and if/when they plan to release a new version.

To the other plugin developers - if you want to just "borrow" code, take a look in any of my UI plugins at the top of common_utils.py at these functions (with two variables plugin_name and plugin_icon_resources). I am sure you can simplify them if you want to but I re-use each of these functions individually for other purposes too.
Code:
set_plugin_icon_resources()
get_icon()
get_pixmap()
get_local_images_dir()
The assumption I make in all my plugins is that all images will exist within an images subfolder within the zip, so any request to get_icon or get_pixmap that starts with "images/" is believed to be for plugin icon.

The initialisation of the resources for the plugin is in the InterfaceAction derived class in action.py in the genesis method, with code like this:
Code:
from calibre_plugins.foo.common_utils import set_plugin_icon_resources, get_icon
PLUGIN_ICONS = ['images/foo.png']
...
    def genesis(self):
        ...
        icon_resources = self.load_resources(PLUGIN_ICONS)
        set_plugin_icon_resources(self.name, icon_resources)
        ...
Then anywhere I need an icon, I just use:
Code:
    image=get_icon('images/foo.png')
And as described in post 2 above, it will first look in the local Calibre resource images folder for a subfolder of the plugin name for that icon, and if not then use that found from resources loaded from the zip.

Hope that helps.
kiwidude is offline   Reply With Quote