Skip to content

Commit

Permalink
Made the item context menu use the same system as the conversion menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Dean-Kawamura committed Mar 19, 2013
1 parent dc10a74 commit b0e08f4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tv/lib/frontends/widgets/itemcontextmenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"""itemcontextmenu.py -- Handle popping up a context menu for an item
"""

import functools

from miro import api
from miro import app
from miro import displaytext
Expand Down Expand Up @@ -470,15 +472,13 @@ def _make_edit_metadata_menu(self):

def _make_convert_menu(self):
convert_menu = []
sections = conversion_manager.get_converters()
for index, section in enumerate(sections):
for converter in section[1]:
def convert(converter=converter.identifier):
app.widgetapp.convert_items(converter)
convert_menu.append((converter.displayname, convert))
if index+1 < len(sections):
convert_menu.append(None)
convert_menu.append(None)
sections = app.menu_manager.get_converters()
for index, converter_list in enumerate(sections):
for (identifier, title) in converter_list:
func = functools.partial(app.widgetapp.convert_items,
identifier)
convert_menu.append((title, func))
convert_menu.append(None)
convert_menu.append((_("Show Conversion Folder"),
app.widgetapp.reveal_conversions_folder))
return convert_menu
Expand Down
11 changes: 11 additions & 0 deletions tv/lib/frontends/widgets/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ def __init__(self):
signals.SignalEmitter.__init__(self, 'menus-updated')
self.menu_item_fetcher = MenuItemFetcher()
self.subtitle_encoding_updater = SubtitleEncodingMenuUpdater()
self.converter_list = []

def setup_menubar(self, menubar):
"""Setup the main miro menubar.
Expand Down Expand Up @@ -1012,6 +1013,16 @@ def add_converters(self, converters):
groups=["LocalPlayablesSelected"])
menu.insert(position.next(), item)
menu.insert(position.next(), Separator())
for i, group_list in enumerate(converters):
self.converter_list.insert(i, group_list)

def get_converters(self):
"""Get the current list of converters
:returns: list of converter groups. Each group will be a list of
(identifier, title) tuples.
"""
return self.converter_list

def select_subtitle_encoding(self, encoding):
if not self.subtitle_encoding_updater.has_encodings():
Expand Down

0 comments on commit b0e08f4

Please sign in to comment.