+class GroovesharkPlaylistSelect(xbmcgui.WindowDialog):
+
+ def __init__(self, items=[]):
+ gap = int(self.getHeight()/100)
+ w = int(self.getWidth()*0.5)
+ h = self.getHeight()-30*gap
+ rw = self.getWidth()
+ rh = self.getHeight()
+ x = rw/2 - w/2
+ y = rh/2 -h/2
+
+ self.imgBg = xbmcgui.ControlImage(x+gap, 5*gap+y, w-2*gap, h-5*gap, listBackground)
+ self.addControl(self.imgBg)
+
+ self.playlistControl = xbmcgui.ControlList(2*gap+x, y+3*gap+30, w-4*gap, h-10*gap, textColor='0xFFFFFFFF', selectedColor='0xFFFF4242', itemTextYOffset=0, itemHeight=30, alignmentY = 0)
+ self.addControl(self.playlistControl)
+
+ self.lastPos = 0
+ self.isSelecting = False
+ self.selected = -1
+ listitems = []
+ for playlist in items:
+ listitems.append(xbmcgui.ListItem(playlist[0]))
+ listitems.append(xbmcgui.ListItem('New...'))
+ self.playlistControl.addItems(listitems)
+ self.setFocus(self.playlistControl)
+ self.playlistControl.selectItem(0)
+ item = self.playlistControl.getListItem(self.lastPos)
+ item.select(True)
+
+ # Highlight selected item
+ def setHighlight(self):
+ if self.isSelecting:
+ return
+ else:
+ self.isSelecting = True
+
+ pos = self.playlistControl.getSelectedPosition()
+ if pos >= 0:
+ item = self.playlistControl.getListItem(self.lastPos)
+ item.select(False)
+ item = self.playlistControl.getListItem(pos)
+ item.select(True)
+ self.lastPos = pos
+ self.isSelecting = False
+
+ # Control
+ def onControl(self, control):
+ if control == self.playlistControl:
+ self.selected = self.playlistControl.getSelectedPosition()
+ self.close()
+
+ def onAction(self, action):
+ if action == ACTION_PREVIOUS_MENU:
+ self.selected = -1
+ self.close()
+ elif action == ACTION_MOVE_UP or action == ACTION_MOVE_DOWN or action == ACTION_PAGE_UP or action == ACTION_PAGE_DOWN == 6:
+ self.setFocus(self.playlistControl)
+ self.setHighlight()
+