2012-11-08, 18:12
Hi there,
I'm currently working on a new addon extension point called Context Item Addons.
The goal of this is to add context items to list items not populated from addons. (Like asked for in here)
Pull Request
My Development Branch
I wanted the addon author to have a lot of flexibility to specify when the context item should be visible so I decided to use the already implemented Visibility Expressions for Skins.
NOTE: aditionally to everything you can do in skins, you can also use "addon.hasSetting(settingname)" which works on boolean addon settings. I plan to also add support for non boolean settings.
This is how it would look like in your addon.xml
Check it out
This is already working. There are mostly some TODO's left concerning special cases (what to do when a context item addon gets automatically updated when it is currently displayed... and stuff like that) but basically it should be save (as safe as nightlies can be ) to check it out and test it.
If you're on a mac your lucky. Just checkout my branch and compile or if you want I can upload a dmg.
if you're on any other os, you can still checkout my branch but you probably have add the following files to your project/build process:
What I want to know from you as an addon developer
- First of all I want to know your ideas for context item addons and especially when those should be visible. I'm pretty sure that my current PR is pretty limited as you cannot actually add a context item just for e.g. Movies because i haven seen a way to query that information from the visibility expression. So what I want to find out is what new Expression should be exposed so you guys can actually usefull context item addons.
- You can disable the build-in context items for content addons. If you have done this, could you explain why you disabled them? I want to figure out when context item addons should be available to list items populate by addons.
- If you're a skinner / or have more knowledge of the visibility expressions than I do, please let me know If the list of new proposed expression at the end of this thread is in fact already possible...
- And of course Bugs...
Here is a list of Bugs i know about:
Some examples I thought of
Right now there are a lot of scripts floating around that need special skin support (Actors Biography, Home Theatre Experience, All those "Download additional metadata" addons).
For the home Theatre Experience we need to find out if the current item is a movie.
For the actors biography we need to find out if the current item is a actors node.
For the cd-art downloader script we need to know if the current item is a album.
That why I think it is reasonable to add a new visibility condition like ListItem.IsType(season) that would return true or false. (Seems related but haven't read it yet)
Another Idea would be "Ripd DVD/BluRay" Context Item addons. This one should only be visible on DVD/BluRay drives...
New Visibility Expressions to Expose
I will try to maintain a list of what is needed to make your suggested addons work...
I'm currently working on a new addon extension point called Context Item Addons.
The goal of this is to add context items to list items not populated from addons. (Like asked for in here)
Pull Request
My Development Branch
I wanted the addon author to have a lot of flexibility to specify when the context item should be visible so I decided to use the already implemented Visibility Expressions for Skins.
NOTE: aditionally to everything you can do in skins, you can also use "addon.hasSetting(settingname)" which works on boolean addon settings. I plan to also add support for non boolean settings.
This is how it would look like in your addon.xml
Code:
<extension point="xbmc.context" library="addon.py" visible="{VISIBILITY_EXPRESSION}">
<label>The label to display</label>
<label lang="de">Localized german label</label>
</extension>
Check it out
This is already working. There are mostly some TODO's left concerning special cases (what to do when a context item addon gets automatically updated when it is currently displayed... and stuff like that) but basically it should be save (as safe as nightlies can be ) to check it out and test it.
If you're on a mac your lucky. Just checkout my branch and compile or if you want I can upload a dmg.
if you're on any other os, you can still checkout my branch but you probably have add the following files to your project/build process:
- xbmc/GUIContextMenuManager.cpp
- xbmc/GUIContextMenuManager.h
- xbmc/IGUIContextItem.cpp
- xbmc/IGUIContextItem.h
- xbmc/addons/ContextItemAddon.cpp
- xbmc/addons/ContextItemAddon.h
What I want to know from you as an addon developer
- First of all I want to know your ideas for context item addons and especially when those should be visible. I'm pretty sure that my current PR is pretty limited as you cannot actually add a context item just for e.g. Movies because i haven seen a way to query that information from the visibility expression. So what I want to find out is what new Expression should be exposed so you guys can actually usefull context item addons.
- You can disable the build-in context items for content addons. If you have done this, could you explain why you disabled them? I want to figure out when context item addons should be available to list items populate by addons.
- If you're a skinner / or have more knowledge of the visibility expressions than I do, please let me know If the list of new proposed expression at the end of this thread is in fact already possible...
- And of course Bugs...
Here is a list of Bugs i know about:
- In some Views the context addon items are added in the middle. My goal is that context item addons should always be at the bottom, while the core ones are at the top. One way to fix it would be a lot of code duplication... should be easy but I'm looking for a more elegant way, so please just ignore that for now
Some examples I thought of
Right now there are a lot of scripts floating around that need special skin support (Actors Biography, Home Theatre Experience, All those "Download additional metadata" addons).
For the home Theatre Experience we need to find out if the current item is a movie.
For the actors biography we need to find out if the current item is a actors node.
For the cd-art downloader script we need to know if the current item is a album.
That why I think it is reasonable to add a new visibility condition like ListItem.IsType(season) that would return true or false. (Seems related but haven't read it yet)
Another Idea would be "Ripd DVD/BluRay" Context Item addons. This one should only be visible on DVD/BluRay drives...
New Visibility Expressions to Expose
I will try to maintain a list of what is needed to make your suggested addons work...
- Add possibility to check of a strng (or label) matches a regex patter. Useful to check if a items path comes from a specific website (regardles of the addon that provides the item). Code Example: Code:
visibility="matchesRegex(listitem.path, {REG_EX})"