xbmcswift2
xbmcswift2 copied to clipboard
add possibility to set ListItems' context_menu by list of dicts
... instead of "list of two-element-length-tuples containing label and action" ;)
This would improve readability and would make it easier for beginners. Also this is a good place to use the new wrappers _run and _view
Draft:
items = [{
'label': movie['title'],
'info': {
'year': '2013',
},
'context_menu': [{
'label': 'Add to favorites',
'action': _run(plugin.url_for(
endpoint='add_to_fav',
movie_id=movie['id'],
)),
}]
'replace_context_menu': True,
'is_playable': True,
'thumbnail': 'http://foo.bar',
'path': plugin.url_for(
endpoint='play',
movie_id=movie['id'],
)
}]
Tell me what you think :)
since there's only the fixed 2 items in that dict, tuple will do well and type less words, what's benefit from this? for the _run/_view, just use it in tuple, no much reason to use dict imo.
@ulion hit the nail on the head. The reason it is lists of tuples is because each item is always a label and an action, so typing out dict keys is wordier, especially if you have multiple context menu items. However, @dersphere I agree with you that the dict version if more informative to beginners...
Sure it is wordier, but it's explicit :) It could also be implemented to accept both (backward compatibility should be kept anyway).
But it was just an idea so feel free to close if you don't like :)