Favorites #9

Open
wants to merge 8 commits into
from

Conversation

Projects
None yet
1 participant
Contributor

DragonWin commented Sep 16, 2011

This is the first attempt at making the menu-contexts available to the addon coder. It is fully documented with the changes, and the test addon has been updated to reflect the new functionality.

Feedback is appreciated.

DragonWin added some commits Sep 2, 2011

Added create_contextmenu() (convenience function)
lets you create a context menu by creating an object that you can
use with add_video_item, add_item, add_music_item, to have extra
menu's show when a user right clicks on a directory or a movie / song.

args:
    menuname (str): The name that will be shown in your menu

    scriptargs (str): a list of arguments will be passed back to the
    addon in sys.argv[2] the form of:
    mode=mymode&type=53&displaylist=1

    kwargs:
    newlist (Bol): Default False, If you want to replace the current
    movie / dir list shown on the screen set this to True.
    If you only want the user to stay on the same screen, set this
    to False or omit.

    contextmenuobj (tuple): is an existing object that has already been
    returned by this function. Passing the existing tuple, will stack
    the menu's you create, allowing you to create multiple menu items.

    Returns: a tuple conforming to the listitem.addContextMenuItems()

Modified add_item, add_video_item, add_music_item, add_dir to handle the context item.
added favorite functionality to addon.py
New functions are: create_favorite, save_favorite, del_favorite, show_favorites, dict_to_string, string_to_dict, create_contextmenu
reworked the Favorite functions to separate it out the menu functions…
… to MenuContext class, and adjusted code and documentation.

There is still a few issues:
cm = ContextMenu(addon.url) should be cm = ContextMenu(addon)

Find a way around parsing the ContextMenu obj to addon.show_favorite(cm)

Find a way not to pass a query string around base64 encrypted to avoid clashes with existing args.

Need to remvoe a few # comments in the code.
Changed serializing of data to use pickle. I still base64 url safe en…
…code it.

Changed init to receive the addon object instead of the addon.url
Chagned wording of error msg.
Removed debug printing
Changed show_favorites to return a list of dicts and not require the …
…cm module to be passed to it.

Moved the cotext and add_dir / add_item to the addon instead of t0mm0.common.addon
Changed test addon to use the new showfavorite
Fixed an urlencode failure in common.addon where it would fail if the content were unicode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment