def cancelClick(self):
self.close(False)
-class ChannelContextMenu(FixedMenu):
+class ChannelContextMenu(Screen):
def __init__(self, session, csel):
+ Screen.__init__(self, session)
self.csel = csel
+ self["actions"] = ActionMap(["OkCancelActions"],
+ {
+ "ok": self.okbuttonClick,
+ "cancel": self.cancelClick
+ })
menu = [ ]
inBouquetRootList = csel.getRoot().getPath().find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
menu.append((_("end favourites edit"), self.bouquetMarkEnd))
menu.append((_("abort favourites edit"), self.bouquetMarkAbort))
- menu.append((_("back"), self.close))
+ menu.append((_("back"), self.cancelClick))
+ self["menu"] = MenuList(menu)
+
+ def okbuttonClick(self):
+ self["menu"].getCurrent()[1]()
- FixedMenu.__init__(self, session, _("Channel Selection"), menu)
- self.skinName = "Menu"
+ def cancelClick(self):
+ self.close(False)
def addServiceToBouquetSelected(self):
bouquets = self.csel.getBouquetList()
else:
cnt = len(bouquets)
if cnt > 1: # show bouquet list
- self.session.open(BouquetSelector, bouquets, self.addCurrentServiceToBouquet)
+ self.session.openWithCallback(self.bouquetSelClosed, BouquetSelector, bouquets, self.addCurrentServiceToBouquet)
elif cnt == 1: # add to only one existing bouquet
self.addCurrentServiceToBouquet(bouquets[0][1])
else: #no bouquets in root.. so assume only one favourite list is used
self.addCurrentServiceToBouquet(self.csel.bouquet_root)
+ def bouquetSelClosed(self, recursive):
+ if recursive:
+ self.close(False)
+
def copyCurrentToBouquetList(self):
self.csel.copyCurrentToBouquetList()
self.close()
def addCurrentServiceToBouquet(self, dest):
self.csel.addCurrentServiceToBouquet(dest)
- self.close()
+ self.close(True) # close bouquet selection
def removeCurrentService(self):
self.csel.removeCurrentService()
str = '1:7:2:0:0:0:0:0:0:0:(type == 2) FROM BOUQUET \"userbouquet.%s.radio\" ORDER BY bouquet'%(self.buildBouquetID(providerName))
new_bouquet_ref = eServiceReference(str)
if not mutableBouquetList.addService(new_bouquet_ref):
+ self.bouquetNumOffsetCache = { }
mutableBouquetList.flushChanges()
eDVBDB.getInstance().reloadBouquets()
mutableBouquet = serviceHandler.list(new_bouquet_ref).startEdit()
def removeBouquet(self):
refstr = self.getCurrentSelection().toString()
+ self.bouquetNumOffsetCache = { }
pos = refstr.find('FROM BOUQUET "')
if pos != -1:
refstr = refstr[pos+14:]
- print refstr
pos = refstr.find('"')
if pos != -1:
filename = '/etc/enigma2/' + refstr[:pos] # FIXMEEE !!! HARDCODED /etc/enigma2
def startMarkedEdit(self):
self.mutableList = self.getMutableList()
# add all services from the current list to internal marked set in listboxservicecontent
- self.bouquetRoot = self.getRoot()
self.clearMarks() # this clears the internal marked set in the listboxservicecontent
self.saved_title = self.instance.getTitle()
- new_title = self.saved_title
+ pos = self.saved_title.find(')')
+ new_title = self.saved_title[:pos+1]
if self.bouquet_root.getPath().find('FROM BOUQUET "bouquets.') != -1:
new_title += ' ' + _("[bouquet edit]")
else:
self.__marked = self.servicelist.getRootServices()
for x in self.__marked:
self.servicelist.addMarked(eServiceReference(x))
- self.saved_root = self.getRoot()
+ self.savedPath = self.servicePath[:]
self.showAllServices()
def endMarkedEdit(self, abort):
if not abort and self.mutableList is not None:
+ self.bouquetNumOffsetCache = { }
new_marked = set(self.servicelist.getMarked())
old_marked = set(self.__marked)
removed = old_marked - new_marked
self.__marked = []
self.clearMarks()
self.bouquet_mark_edit = False
- self.bouquetRoot = None
self.mutableList = None
self.instance.setTitle(self.saved_title)
self.saved_title = None
- self.setRoot(self.saved_root)
+ self.servicePath = self.savedPath[:]
+ del self.savedPath
+ self.setRoot(self.servicePath[len(self.servicePath)-1])
def clearMarks(self):
self.servicelist.clearMarks()
mutableList = self.getMutableList()
if ref.valid() and mutableList is not None:
if not mutableList.removeService(ref):
+ self.bouquetNumOffsetCache = { }
currentIndex = self.servicelist.getCurrentIndex()
self.servicelist.moveDown()
if self.servicelist.getCurrentIndex() == currentIndex:
mutableList = self.getMutableList(dest)
if not mutableList is None:
if not mutableList.addService(self.servicelist.getCurrent()):
+ self.bouquetNumOffsetCache = { }
mutableList.flushChanges()
self.close()
self.mutableList = None
self.instance.setTitle(self.saved_title)
self.saved_title = None
+ if self.getRoot() == self.bouquet_root:
+ self.bouquetNumOffsetCache = { }
else:
self.mutableList = self.getMutableList()
self.movemode = True
self.pathChangedDisabled = True # no path change allowed in movemode
self.saved_title = self.instance.getTitle()
new_title = self.saved_title
- new_title += ' ' + _("[move mode]");
+ pos = self.saved_title.find(')')
+ new_title = self.saved_title[:pos+1] + ' ' + _("[move mode]") + self.saved_title[pos+1:]
self.instance.setTitle(new_title);
def handleEditCancel(self):
self.servicePathTV = [ ]
self.servicePathRadio = [ ]
+ self.servicePath = None
self.pathChangedDisabled = False
+ self.bouquetNumOffsetCache = { }
+
self["ChannelSelectBaseActions"] = NumberActionMap(["ChannelSelectBaseActions", "NumberActions"],
{
"showFavourites": self.showFavourites,
return ref
def getBouquetNumOffset(self, bouquet):
- bouquet = self.appendDVBTypes(bouquet)
if self.bouquet_root.getPath().find('FROM BOUQUET "bouquets.') == -1: #FIXME HACK
return 0
- offsetCount = 0
- serviceHandler = eServiceCenter.getInstance()
- bouquetlist = serviceHandler.list(self.bouquet_root)
- if not bouquetlist is None:
- while True:
- bouquetIterator = self.appendDVBTypes(bouquetlist.getNext())
- if not bouquetIterator.valid() or bouquetIterator == bouquet: #end of list or bouquet found
- break
- if ((bouquetIterator.flags & eServiceReference.flagDirectory) != eServiceReference.flagDirectory):
- continue
- servicelist = serviceHandler.list(bouquetIterator)
- if not servicelist is None:
- while True:
- serviceIterator = servicelist.getNext()
- if not serviceIterator.valid(): #check if end of list
- break
- if serviceIterator.flags: #playable services have no flags
- continue
- offsetCount += 1
- return offsetCount
+ bouquet = self.appendDVBTypes(bouquet)
+ try:
+ return self.bouquetNumOffsetCache[bouquet.toString()]
+ except:
+ offsetCount = 0
+ serviceHandler = eServiceCenter.getInstance()
+ bouquetlist = serviceHandler.list(self.bouquet_root)
+ if not bouquetlist is None:
+ while True:
+ bouquetIterator = self.appendDVBTypes(bouquetlist.getNext())
+ if not bouquetIterator.valid(): #end of list
+ break
+ self.bouquetNumOffsetCache[bouquetIterator.toString()]=offsetCount
+ if ((bouquetIterator.flags & eServiceReference.flagDirectory) != eServiceReference.flagDirectory):
+ continue
+ servicelist = serviceHandler.list(bouquetIterator)
+ if not servicelist is None:
+ while True:
+ serviceIterator = servicelist.getNext()
+ if not serviceIterator.valid(): #check if end of list
+ break
+ if serviceIterator.flags: #playable services have no flags
+ continue
+ offsetCount += 1
+ return self.bouquetNumOffsetCache.get(bouquet.toString(), offsetCount)
def recallBouquetMode(self):
if self.mode == MODE_TV:
self.bouquet_root = eServiceReference(self.bouquet_rootstr)
def setTvMode(self):
+ self.mode = MODE_TV
+ self.servicePath = self.servicePathTV
+ self.recallBouquetMode()
title = self.instance.getTitle()
pos = title.find(" (")
if pos != -1:
title = title[:pos]
title += " (TV)"
self.instance.setTitle(title)
- self.mode = MODE_TV
- self.recallBouquetMode()
def setRadioMode(self):
+ self.mode = MODE_RADIO
+ self.servicePath = self.servicePathRadio
+ self.recallBouquetMode()
title = self.instance.getTitle()
pos = title.find(" (")
if pos != -1:
title = title[:pos]
title += " (Radio)"
self.instance.setTitle(title)
- self.mode = MODE_RADIO
- self.recallBouquetMode()
def setRoot(self, root, justSet=False):
path = root.getPath()
else:
self.servicelist.setMode(ServiceList.MODE_NORMAL)
self.servicelist.setRoot(root, justSet)
+ self.buildTitleString()
+
+ def removeModeStr(self, str):
+ if self.mode == MODE_TV:
+ pos = str.find(' (TV)')
+ else:
+ pos = str.find(' (Radio)')
+ if pos != -1:
+ return str[:pos]
+ return str
+
+ def getServiceName(self, ref):
+ str = self.removeModeStr(ServiceReference(ref).getServiceName())
+ if not len(str):
+ pathstr = ref.getPath()
+ if pathstr.find('FROM PROVIDERS') != -1:
+ return _("Provider")
+ if pathstr.find('FROM SATELLITES') != -1:
+ return _("Satellites")
+ if pathstr.find(') ORDER BY name') != -1:
+ return _("All")
+ return str
+
+ def buildTitleString(self):
+ titleStr = self.instance.getTitle()
+ pos = titleStr.find(']')
+ if pos == -1:
+ pos = titleStr.find(')')
+ if pos != -1:
+ titleStr = titleStr[:pos+1]
+ Len = len(self.servicePath)
+ if Len > 0:
+ base_ref = self.servicePath[0]
+ if Len > 1:
+ end_ref = self.servicePath[Len-1]
+ else:
+ end_ref = None
+ nameStr = self.getServiceName(base_ref)
+ titleStr += ' ' + nameStr
+ if end_ref is not None:
+ if Len > 2:
+ titleStr += '/../'
+ else:
+ titleStr += '/'
+ nameStr = self.getServiceName(end_ref)
+ titleStr += nameStr
+ self.instance.setTitle(titleStr)
def moveUp(self):
self.servicelist.moveUp()
self.servicelist.moveDown()
def clearPath(self):
- if self.mode == MODE_RADIO:
- self.servicePathRadio = [ ]
- else:
- self.servicePathTV = [ ]
+ del self.servicePath[:]
def enterPath(self, ref, justSet=False):
- if self.mode == MODE_RADIO:
- self.servicePathRadio.append(ref)
- else:
- self.servicePathTV.append(ref)
+ self.servicePath.append(ref)
self.setRoot(ref, justSet)
def pathUp(self, justSet=False):
- if self.mode == MODE_TV:
- prev = self.servicePathTV.pop()
- length = len(self.servicePathTV)
- if length:
- current = self.servicePathTV[length-1]
- else:
- prev = self.servicePathRadio.pop()
- length = len(self.servicePathRadio)
- if length:
- current = self.servicePathRadio[length-1]
+ prev = self.servicePath.pop()
+ length = len(self.servicePath)
+ if length:
+ current = self.servicePath[length-1]
self.setRoot(current, justSet)
if not justSet:
self.setCurrentSelection(prev)
return prev
def isBasePathEqual(self, ref):
- if self.mode == MODE_RADIO and len(self.servicePathRadio) > 1 and self.servicePathRadio[0] == ref:
- return True
- elif self.mode == MODE_TV and len(self.servicePathTV) > 1 and self.servicePathTV[0] == ref:
+ if len(self.servicePath) > 1 and self.servicePath[0] == ref:
return True
return False
def isPrevPathEqual(self, ref):
- path = self.servicePathRadio
- if self.mode == MODE_TV:
- path = self.servicePathTV
- length = len(path)
- if length > 1 and path[length-2] == ref:
+ length = len(self.servicePath)
+ if length > 1 and self.servicePath[length-2] == ref:
return True
return False
service.setName(service_name) # why we need this cast?
except:
if orbpos > 1800: # west
- service.setName("%s (%3.1f" + _("W") + ")" %(str, (0 - (orbpos - 3600)) / 10.0))
+ orbpos = 3600 - orbpos
+ h = _("W")
else:
- service.setName("%s (%3.1f" + _("E") + ")" % (str, orbpos / 10.0))
+ h = _("E")
+ n = ("%s (%d.%d" + h + ")") % (service_name, orbpos / 10, orbpos % 10)
+ service.setName(n)
self.servicelist.addService(service)
self.servicelist.finishFill()
if prev is not None:
ref = self.getCurrentSelection()
self.enterPath(ref)
+ def inBouquet(self):
+ return self.isBasePathEqual(self.bouquet_root)
+
+ def atBegin(self):
+ return self.servicelist.atBegin()
+
+ def atEnd(self):
+ return self.servicelist.atEnd()
+
def nextBouquet(self):
self.changeBouquet(+1)
return bouquets
return None
+HISTORYSIZE = 20
+
class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelectionEPG):
def __init__(self, session):
ChannelSelectionBase.__init__(self,session)
"cancel": self.cancel,
"ok": self.channelSelected,
})
- self.onShown.append(self.onShow)
+ self.onShown.append(self.__onShown)
self.lastChannelRootTimer = eTimer()
- self.lastChannelRootTimer.timeout.get().append(self.onCreate)
+ self.lastChannelRootTimer.timeout.get().append(self.__onCreate)
self.lastChannelRootTimer.start(100,True)
- def onCreate(self):
+ self.history = [ ]
+ self.history_pos = 0
+
+ def __onCreate(self):
self.setTvMode()
- self.servicePathTV = [ ]
self.restoreRoot()
lastservice=eServiceReference(config.tv.lastservice.value)
if lastservice.valid():
self.setCurrentSelection(lastservice)
- self.session.nav.playService(lastservice)
+ self.zap()
- def onShow(self):
+ def __onShown(self):
self.recallBouquetMode()
ref = self.session.nav.getCurrentlyPlayingServiceReference()
if ref is not None and ref.valid() and ref.getPath() == "":
#called from infoBar and channelSelected
def zap(self):
ref = self.session.nav.getCurrentlyPlayingServiceReference()
- if ref is None or ref != self.getCurrentSelection():
- self.session.nav.playService(self.getCurrentSelection())
+ nref = self.getCurrentSelection()
+ if ref is None or ref != nref:
+ self.session.nav.playService(nref)
+ self.saveRoot()
+ self.saveChannel()
+ tmp=self.servicePath[:]
+ tmp.append(nref)
+ try:
+ del self.history[self.history_pos+1:]
+ except:
+ pass
+ self.history.append(tmp)
+ hlen = len(self.history)
+ if hlen > HISTORYSIZE:
+ del self.history[0]
+ hlen -= 1
+ self.history_pos = hlen-1
+
+ def historyBack(self):
+ hlen = len(self.history)
+ if hlen > 1 and self.history_pos > 0:
+ self.history_pos -= 1
+ self.setHistoryPath()
+
+ def historyNext(self):
+ hlen = len(self.history)
+ if hlen > 1 and self.history_pos < (hlen-1):
+ self.history_pos += 1
+ self.setHistoryPath()
+
+ def setHistoryPath(self):
+ path = self.history[self.history_pos][:]
+ ref = path.pop()
+ self.servicePath = path
self.saveRoot()
+ plen = len(path)
+ root = path[plen-1]
+ if self.getRoot() != root:
+ self.setRoot(root)
+ self.session.nav.playService(ref)
+ self.setCurrentSelection(ref)
self.saveChannel()
def saveRoot(self):
config.tv.lastroot.save()
def restoreRoot(self):
- self.servicePathTV = [ ]
+ self.clearPath()
re = compile('.+?;')
tmp = re.findall(config.tv.lastroot.value)
cnt = 0
if pathstr is not None and pathstr.find(refstr) == 0:
self.restoreRoot()
lastservice=eServiceReference(config.tv.lastservice.value)
- if lastservice is not None:
+ if lastservice.valid():
self.setCurrentSelection(lastservice)
return True
return False
config.radio.lastroot.save()
def restoreRoot(self):
- self.servicePathRadio = [ ]
+ self.clearPath()
re = compile('.+?;')
tmp = re.findall(config.radio.lastroot.value)
cnt = 0
if pathstr is not None and pathstr.find(refstr) == 0:
self.restoreRoot()
lastservice=eServiceReference(config.radio.lastservice.value)
- if lastservice is not None:
+ if lastservice.valid():
self.setCurrentSelection(lastservice)
return True
return False
self.servicelist.setCurrent(lastservice)
self.session.nav.playService(lastservice)
self.servicelist.setPlayableIgnoreService(lastservice)
- self.info.instance.show()
+ self.info.show()
def channelSelected(self): # just return selected service
ref = self.getCurrentSelection()
self.saveRoot()
def closeRadio(self):
- self.info.instance.hide()
+ self.info.hide()
#set previous tv service
lastservice=eServiceReference(config.tv.lastservice.value)
self.session.nav.playService(lastservice)
def __init__(self, session, title):
ChannelSelectionBase.__init__(self, session)
self.title = title
- self.onShown.append(self.onExecCallback)
+ self.onShown.append(self.__onExecCallback)
self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"],
{
- "cancel": self.cancel,
+ "cancel": self.close,
"ok": self.channelSelected,
"keyRadio": self.setModeRadio,
"keyTV": self.setModeTv,
})
- def onExecCallback(self):
+ def __onExecCallback(self):
self.session.currentDialog.instance.setTitle(self.title)
self.setModeTv()