def create_learning_tree_menu(self):
"""
Create and return a Gtk.Menu object that has submenus that
let us select all lessons on the learning tree.
"""
def create_menu(page):
menu = Gtk.Menu()
for column in page:
for section in column:
item = Gtk.MenuItem(section.m_name)
for link in section:
if isinstance(link, frontpage.Page):
item = Gtk.MenuItem(link.m_name)
menu.append(item)
item.set_submenu(create_menu(link))
else:
assert isinstance(link, unicode)
# This will also alert us if the file is not
# found or not parsable:
try:
if lessonfile.infocache.get(link, 'module') not in ('melodicinterval', 'harmonicinterval', 'idbyname'):
continue
except lessonfile.infocache.InfoCacheException:
continue
# We don't want to add these lesson files because we know
# that they cannot be exported. It would be better
# to catch these with a more generic algorithm, but
# then we would have to parse all the files, and that
# would be too slow.
if link in (
# melodic-interval-self-config
"f62929dc-7122-4173-aad1-4d4eef8779af",
# harmonic-interval-self-config
"466409e7-9086-4623-aff0-7c27f7dfd13b",
# the csound-fifth-* files:
"b465c807-d7bf-4e3a-a6da-54c78d5b59a1",
"aa5c3b18-664b-4e3d-b42d-2f06582f4135",
"5098fb96-c362-45b9-bbb3-703db149a079",
"3b1f57e8-2983-4a74-96da-468aa5414e5e",
"a06b5531-7422-4ea3-8711-ec57e2a4ce22",
"e67c5bd2-a275-4d9a-96a8-52e43a1e8987",
"1cadef8c-859e-4482-a6c4-31bd715b4787",
):
continue
item = Gtk.MenuItem(_(lessonfile.infocache.get(link, 'title')))
item.connect('activate', self.on_select_exercise, link)
menu.append(item)
return menu
menu = create_menu(solfege.app.m_frontpage_data)
menu.show_all()
self._menu_hide_stuff(menu)
return menu
评论列表
文章目录