xbmcswift2 icon indicating copy to clipboard operation
xbmcswift2 copied to clipboard

add possibility to set ListItems' context_menu by list of dicts

Open dersphere opened this issue 11 years ago • 3 comments

... 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 :)

dersphere avatar Apr 25 '13 21:04 dersphere

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 avatar Apr 27 '13 20:04 ulion

@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...

jbeluch avatar Apr 28 '13 06:04 jbeluch

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 :)

dersphere avatar Apr 28 '13 09:04 dersphere