+ self.toggleMoveMarked() # unmark current entry
+ self.movemode = False
+ self.mutableList.flushChanges() # FIXME add check if changes was made
+ self.mutableList = None
+ else:
+ self.mutableList = self.getMutableList()
+ self.movemode = True
+
+ def handleEditCancel(self):
+ if self.movemode: #movemode active?
+ self.channelSelected() # unmark
+ self.toggleMoveMode() # disable move mode
+ elif self.bouquet_mark_edit:
+ self.endMarkedEdit(True) # abort edit mode
+
+ def toggleMoveMarked(self):
+ if self.entry_marked:
+ self.servicelist.setCurrentMarked(False)
+ self.entry_marked = False
+ else:
+ self.servicelist.setCurrentMarked(True)
+ self.entry_marked = True
+
+ def doContext(self):
+ self.session.open(ChannelContextMenu, self)
+
+class ChannelSelectionBase(Screen):
+ def __init__(self, session):
+ Screen.__init__(self, session)
+
+ # this makes it much simple to implement a selectable radio or tv mode :)
+ self.service_types_tv = '1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17)'
+ self.service_types_radio = '1:7:1:0:0:0:0:0:0:0:(type == 2)'
+
+ self.service_types = self.service_types_tv
+
+ #self.bouquet_root = eServiceReference('1:7:1:0:0:0:0:0:0:0:(type == 1) FROM BOUQUET "bouquets.tv" ORDER BY bouquet')
+ self.bouquet_root = eServiceReference('%s FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet'%(self.service_types))
+
+ self["key_red"] = Button("All")
+ self["key_green"] = Button("Satellites")
+ self["key_yellow"] = Button("Provider")
+ self["key_blue"] = Button("Favourites")
+
+ self["list"] = ServiceList()
+ self.servicelist = self["list"]
+
+ #self["okbutton"] = Button("ok", [self.channelSelected])
+
+ self.numericalTextInput = NumericalTextInput()
+
+ def getBouquetNumOffset(self, 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 = 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
+
+ def setRootBase(self, root):
+ inBouquetRootList = root.getPath().find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
+ if not inBouquetRootList and (root.getPath().find('FROM BOUQUET') != -1):
+ self.servicelist.setMode(ServiceList.MODE_FAVOURITES)
+ self.servicelist.setNumberOffset(self.getBouquetNumOffset(root))
+ else:
+ self.servicelist.setMode(ServiceList.MODE_NORMAL)
+ self.servicelist.setRoot(root)
+
+ def moveUp(self):
+ self.servicelist.moveUp()
+
+ def moveDown(self):
+ self.servicelist.moveDown()
+
+ def showAllServices(self):
+ ref = eServiceReference('%s ORDER BY name'%(self.service_types))
+ self.setRoot(ref)
+
+ def showSatellites(self):
+ ref = eServiceReference('%s FROM SATELLITES ORDER BY satellitePosition'%(self.service_types))
+ self.setRoot(ref)
+
+ def showProviders(self):
+ ref = eServiceReference('%s FROM PROVIDERS ORDER BY name'%(self.service_types))
+ self.setRoot(ref)
+
+ def showFavourites(self):
+ self.setRoot(self.bouquet_root)
+
+ def keyNumberGlobal(self, number):
+ char = self.numericalTextInput.getKey(number)
+ print "You pressed number " + str(number)
+ print "You would go to character " + str(char)
+ self.servicelist.moveToChar(char)
+
+ def enterBouquet(self, action):
+ if action[:7] == "bouquet":
+ if action.find("FROM BOUQUET") != -1:
+ self.setRoot(eServiceReference("1:7:1:0:0:0:0:0:0:0:" + action[8:]))