From adc3af3779ad12bc4ee4c4528abe13ded9b06120 Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Sat, 30 Oct 2010 13:40:56 -0400 Subject: [PATCH] Menu tweaks Playlists and libraries now have a right click menu, and a generic function for making the menus. --- ocarina/menu.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/ocarina/menu.py b/ocarina/menu.py index 95c054a2..5d86afc4 100644 --- a/ocarina/menu.py +++ b/ocarina/menu.py @@ -6,22 +6,31 @@ gtk = ocarina.gtk Menu = gtk.Menu MenuItem = gtk.MenuItem -lib_items = [] +lib_items = [] +plist_items = [] + +def add_menu_item(items, text, func): + items.append( (text, func) ) + items.sort() def add_lib_menu_item(text, func): - lib_items.append( (text, func) ) - lib_items.sort() + add_menu_item(lib_items, text, func) + +def add_plist_menu_item(text, func): + add_menu_item(plist_items, text, func) -def make_lib_menu(button, time): +def make_menu(items, button, time): menu = Menu() - for (text, func) in lib_items: + for (text, func) in items: item = MenuItem(text) item.connect("activate", lambda x: func()) item.show() menu.append(item) menu.popup(None, None, None, button, time) +def make_lib_menu(button, time): + make_menu(lib_items, button, time) def make_plist_menu(button, time): - print "make_plist_menu() not implemented yet..." + make_menu(plist_items, button, time)