+class GroovesharkPlaylistSelect(xbmcgui.WindowDialog):
+
+ def __init__(self, title, items=[], width=100):
+ w = int(self.getWidth()*width)
+ pad = int(self.getHeight()/100)
+ hCnt = 30
+ yo = 30
+ self.selected = [-1, -1]
+ h = self.getHeight()-30*pad
+ rw = self.getWidth()
+ rh = self.getHeight()
+ x = rw/2 - w/2
+ y = rh/2 -h/2
+
+ #self.imgBg = xbmcgui.ControlImage(0+x-30,0+y-30,w+60,h+60, os.path.join(mediaDir,'gs-bg-menu.png'))
+ #self.addControl(self.imgBg)
+ self.imgBg = xbmcgui.ControlImage(0+x+pad,5*pad+y,w-2*pad,h-5*pad, listBackground)
+ self.addControl(self.imgBg)
+
+ self.labelTitle = xbmcgui.ControlLabel(0+x, 0+y, w, hCnt, title, 'font14', '0xFFFFFFFF', alignment=2)
+ self.addControl(self.labelTitle)
+
+ self.cntList = xbmcgui.ControlList(2*pad+x, yo+y+3*pad, w-4*pad, h-10*pad, font='font12', textColor='0xFFFFFFFF', selectedColor='0xFFFF4242', space=0, itemHeight=7*pad)
+ self.addControl(self.cntList)
+ self.lastPos = 0
+ self.isSelecting = False
+ listitems = []
+ listitems.append(xbmcgui.ListItem('first'))
+ for playlist in items:
+ print "playlist is " + playlist[0]
+ listitems.append(xbmcgui.ListItem(playlist[0]))
+ self.cntList.addItems(listitems)
+ self.setFocus(self.cntList)
+ item = self.cntList.getListItem(self.lastPos)
+ item.select(True)
+
+ # Highlight selected item
+ def setHighlight(self):
+ if self.isSelecting:
+ return
+ else:
+ self.isSelecting = True
+
+ pos = self.cntList.getSelectedPosition()
+ if pos >= 0:
+ item = self.cntList.getListItem(self.lastPos)
+ item.select(False)
+ item = self.cntList.getListItem(pos)
+ item.select(True)
+ self.lastPos = pos
+ self.isSelecting = False
+
+ def onAction(self, action):
+ if action == ACTION_PREVIOUS_MENU:
+ self.selected = [-1, -1]
+ print 'close'
+ self.close()
+ elif action == ACTION_MOVE_UP or action == ACTION_MOVE_DOWN or action == ACTION_PAGE_UP or action == ACTION_PAGE_DOWN == 6:
+ print 'up down'
+ self.setHighlight()
+ elif action == ACTION_SELECT_ITEM:
+ #self.selected = [-1, self.cntList.getSelectedPosition()]
+ #self.close()
+ print "Selected"
+ else:
+ pass
+