aboutsummaryrefslogtreecommitdiff
path: root/lib/python
diff options
context:
space:
mode:
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>2006-01-25 16:15:44 +0000
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>2006-01-25 16:15:44 +0000
commit9bfa0ff587586c3bfe761200ca9fd890081024d4 (patch)
tree39a3d5e32fe3ae96e35b532e3852e0e58554369e /lib/python
parent258cced121c935a4affa19561b461c3e46f1de8a (diff)
downloadenigma2-9bfa0ff587586c3bfe761200ca9fd890081024d4.tar.gz
enigma2-9bfa0ff587586c3bfe761200ca9fd890081024d4.zip
many info handling changes (nownext/multi/single epg)
Diffstat (limited to 'lib/python')
-rw-r--r--lib/python/Components/EpgList.py29
-rw-r--r--lib/python/Components/UsageConfig.py1
-rw-r--r--lib/python/Screens/ChannelSelection.py23
-rw-r--r--lib/python/Screens/EpgSelection.py108
-rw-r--r--lib/python/Screens/EventView.py33
-rw-r--r--lib/python/Screens/InfoBarGenerics.py124
6 files changed, 205 insertions, 113 deletions
diff --git a/lib/python/Components/EpgList.py b/lib/python/Components/EpgList.py
index cc5bc619..a8750485 100644
--- a/lib/python/Components/EpgList.py
+++ b/lib/python/Components/EpgList.py
@@ -60,6 +60,11 @@ class EPGList(HTMLComponent, GUIComponent):
event = self.epgcache.lookupEventId(service.ref, eventid)
return event
+ def getCurrentChangeCount(self):
+ if self.type == EPG_TYPE_SINGLE:
+ return 0
+ return self.l.getCurrentSelection()[0][0]
+
def getCurrent(self):
if self.type == EPG_TYPE_SINGLE:
if SINGLE_CPP > 0:
@@ -69,8 +74,8 @@ class EPGList(HTMLComponent, GUIComponent):
evt = self.getEventFromId(self.service, eventid)
else:
tmp = self.l.getCurrentSelection()[0]
- eventid = tmp[0]
- service = ServiceReference(tmp[1])
+ eventid = tmp[1]
+ service = ServiceReference(tmp[2])
event = self.getEventFromId(service, eventid)
evt = ( event, service )
return evt
@@ -138,13 +143,13 @@ class EPGList(HTMLComponent, GUIComponent):
res.append((eListboxPythonMultiContent.TYPE_TEXT, r2.left(), r2.top(), r2.width(), r2.height(), 0, RT_HALIGN_LEFT, EventName))
return res
- def buildMultiEntry(self, service, eventId, begTime, duration, EventName, nowTime, service_name):
+ def buildMultiEntry(self, changecount, service, eventId, begTime, duration, EventName, nowTime, service_name):
sname = service_name
r1=self.service_rect
r2=self.progress_rect
r3=self.descr_rect
r4=self.start_end_rect
- res = [ (eventId, service, begTime, duration) ]
+ res = [ (changecount, eventId, service, begTime, duration) ]
re = compile('\xc2\x86.*?\xc2\x87')
list = re.findall(sname)
if len(list):
@@ -186,18 +191,19 @@ class EPGList(HTMLComponent, GUIComponent):
tmp = self.queryEPG(test)
self.list = [ ]
for x in tmp:
- self.list.append(self.buildMultiEntry(x[0], x[1], x[2], x[3], x[4], x[5], x[6]))
+ self.list.append(self.buildMultiEntry(0, x[0], x[1], x[2], x[3], x[4], x[5], x[6]))
self.l.setList(self.list)
print time() - t
+ self.selectionChanged()
def updateMultiEPG(self, direction):
t = time()
test = [ 'RIBDTCN' ]
for x in self.list:
data = x[0]
- service = data[1]
- begTime = data[2]
- duration = data[3]
+ service = data[2]
+ begTime = data[3]
+ duration = data[4]
if begTime is None:
begTime = 0
test.append((service, direction, begTime))
@@ -205,8 +211,10 @@ class EPGList(HTMLComponent, GUIComponent):
tmp = self.queryEPG(test)
cnt=0
for x in tmp:
- if x[2] is not None:
- self.list[cnt]=self.buildMultiEntry(x[0], x[1], x[2], x[3], x[4], x[5], x[6])
+ changecount = self.list[cnt][0][0] + direction
+ if changecount >= 0:
+ if x[2] is not None:
+ self.list[cnt]=self.buildMultiEntry(changecount, x[0], x[1], x[2], x[3], x[4], x[5], x[6])
cnt+=1
self.l.setList(self.list)
print time() - t
@@ -227,3 +235,4 @@ class EPGList(HTMLComponent, GUIComponent):
# self.list.append(self.buildSingleEntry(refstr, x[0], x[1], x[2], x[3]))
self.l.setList(self.list)
print time() - t
+ self.selectionChanged()
diff --git a/lib/python/Components/UsageConfig.py b/lib/python/Components/UsageConfig.py
index 779f5cf3..d51b512a 100644
--- a/lib/python/Components/UsageConfig.py
+++ b/lib/python/Components/UsageConfig.py
@@ -4,7 +4,6 @@ from enigma import *
def InitUsageConfig():
config.usage = ConfigSubsection();
- config.usage.epgtoggle = configElement("config.usage.epgtoggle", configSelection, 1, (("yes", _("yes")), ("no", _("no"))) )
config.usage.showdish = configElement("config.usage.showdish", configSelection, 1, (("yes", _("yes")), ("no", _("no"))) )
config.usage.multibouquet = configElement("config.usage.multibouquet", configSelection, 1, (("yes", _("yes")), ("no", _("no"))) )
diff --git a/lib/python/Screens/ChannelSelection.py b/lib/python/Screens/ChannelSelection.py
index 4c8b2486..89bc2154 100644
--- a/lib/python/Screens/ChannelSelection.py
+++ b/lib/python/Screens/ChannelSelection.py
@@ -2,6 +2,7 @@ from Screen import Screen
from Components.Button import Button
from Components.ServiceList import ServiceList
from Components.ActionMap import NumberActionMap, ActionMap
+from Components.MenuList import MenuList
from EpgSelection import EPGSelection
from enigma import eServiceReference, eEPGCache, eEPGCachePtr, eServiceCenter, eServiceCenterPtr, iMutableServiceListPtr, iStaticServiceInformationPtr, eTimer, eDVBDB
from Components.config import config, configElement, ConfigSubsection, configText, currentConfigSelectionElement
@@ -17,17 +18,27 @@ from os import remove
import xml.dom.minidom
-class BouquetSelector(FixedMenu):
+class BouquetSelector(Screen):
def __init__(self, session, bouquets, selectedFunc):
+ Screen.__init__(self, session)
+
self.selectedFunc=selectedFunc
+
+ self["actions"] = ActionMap(["OkCancelActions"],
+ {
+ "ok": self.okbuttonClick,
+ "cancel": self.cancelClick
+ })
entrys = [ ]
for x in bouquets:
- entrys.append((x[0], self.bouquetSelected, x[1]))
- FixedMenu.__init__(self, session, "Bouquetlist", entrys)
- self.skinName = "Menu"
+ entrys.append((x[0], x[1]))
+ self["menu"] = MenuList(entrys)
+
+ def okbuttonClick(self):
+ self.selectedFunc(self["menu"].getCurrent()[1])
- def bouquetSelected(self):
- self.selectedFunc(self["menu"].getCurrent()[2])
+ def cancelClick(self):
+ self.close(False)
class ChannelContextMenu(FixedMenu):
def __init__(self, session, csel):
diff --git a/lib/python/Screens/EpgSelection.py b/lib/python/Screens/EpgSelection.py
index d6fee567..c8db81b3 100644
--- a/lib/python/Screens/EpgSelection.py
+++ b/lib/python/Screens/EpgSelection.py
@@ -1,8 +1,11 @@
from Screen import Screen
from Components.Button import Button
+from Components.Pixmap import Pixmap
+from Components.Label import Label
from Components.EpgList import *
from Components.ActionMap import ActionMap
-from Screens.EventView import EventView
+from Components.ScrollLabel import ScrollLabel
+from Screens.EventView import EventViewSimple
from enigma import eServiceReference, eServiceEventPtr
from Screens.FixedMenu import FixedMenu
from RecordTimer import RecordTimerEntry, parseEvent
@@ -10,28 +13,40 @@ from TimerEdit import TimerEditList
from TimerEntry import TimerEntry
from ServiceReference import ServiceReference
from Components.config import config, currentConfigSelectionElement
+from time import localtime
import xml.dom.minidom
class EPGSelection(Screen):
- def __init__(self, session, service):
+ def __init__(self, session, service, zapFunc=None):
Screen.__init__(self, session)
-
self["key_red"] = Button("")
- self["key_green"] = Button(_("Add timer"))
-
+ self.closeRecursive = False
if isinstance(service, eServiceReference):
self.type = EPG_TYPE_SINGLE
self["key_yellow"] = Button()
self["key_blue"] = Button()
self.currentService=ServiceReference(service)
else:
+ self.skinName = "EPGSelectionMulti"
self.type = EPG_TYPE_MULTI
self["key_yellow"] = Button(_("Prev"))
self["key_blue"] = Button(_("Next"))
+ self["now_button"] = Pixmap()
+ self["next_button"] = Pixmap()
+ self["more_button"] = Pixmap()
+ self["now_button_sel"] = Pixmap()
+ self["next_button_sel"] = Pixmap()
+ self["more_button_sel"] = Pixmap()
+ self["now_text"] = Label()
+ self["next_text"] = Label()
+ self["more_text"] = Label()
+ self["date"] = Label()
self.services = service
+ self.zapFunc = zapFunc
- self["list"] = EPGList(self.type)
+ self["key_green"] = Button(_("Add timer"))
+ self["list"] = EPGList(self.type, self.onSelectionChanged)
class ChannelActionMap(ActionMap):
def action(self, contexts, action):
@@ -44,21 +59,26 @@ class EPGSelection(Screen):
"timerAdd": self.timerAdd,
"yellow": self.yellowButtonPressed,
"blue": self.blueButtonPressed,
- "info": self.infoKeyPressed
+ "info": self.infoKeyPressed,
+ "zapTo": self.zapTo
})
self["actions"].csel = self
self.onLayoutFinish.append(self.onCreate)
- def infoKeyPressed(self):
- if currentConfigSelectionElement(config.usage.epgtoggle) == "yes":
- self.close(True)
- else:
- self.close(False)
-
def closeScreen(self):
- self.close(False)
+ self.close(self.closeRecursive or self.type == EPG_TYPE_SINGLE)
+ def infoKeyPressed(self):
+ if self.type == EPG_TYPE_MULTI:
+ cur = self["list"].getCurrent()
+ event = cur[0]
+ service = cur[1]
+ else:
+ event = self["list"].getCurrent()
+ service = self.currentService
+ if event is not None:
+ self.session.open(EventViewSimple, event, service, self.eventViewCallback)
#just used in multipeg
def onCreate(self):
@@ -88,16 +108,17 @@ class EPGSelection(Screen):
setEvent(cur[0])
setService(cur[1])
+ def zapTo(self): # just used in multiepg
+ if self.zapFunc != None:
+ self.closeRecursive = True
+ ref = self["list"].getCurrent()[1]
+ self.zapFunc(ref.ref)
+
def eventSelected(self):
if self.type == EPG_TYPE_SINGLE:
- event = self["list"].getCurrent()
- service = self.currentService
+ self.infoKeyPressed()
else: # EPG_TYPE_MULTI
- cur = self["list"].getCurrent()
- event = cur[0]
- service = cur[1]
- if event is not None:
- self.session.open(EventView, event, service, self.eventViewCallback)
+ self.zapTo()
def yellowButtonPressed(self):
if self.type == EPG_TYPE_MULTI:
@@ -131,3 +152,48 @@ class EPGSelection(Screen):
def moveDown(self):
self["list"].moveDown()
+
+ def applyButtonState(self, state):
+ if state == 1:
+ self["now_button_sel"].showWidget()
+ self["now_button"].hideWidget()
+ else:
+ self["now_button"].showWidget()
+ self["now_button_sel"].hideWidget()
+
+ if state == 2:
+ self["next_button_sel"].showWidget()
+ self["next_button"].hideWidget()
+ else:
+ self["next_button"].showWidget()
+ self["next_button_sel"].hideWidget()
+
+ if state == 3:
+ self["more_button_sel"].showWidget()
+ self["more_button"].hideWidget()
+ else:
+ self["more_button"].showWidget()
+ self["more_button_sel"].hideWidget()
+
+ def onSelectionChanged(self):
+ if self.type == EPG_TYPE_MULTI:
+ count = self["list"].getCurrentChangeCount()
+ if count > 1:
+ self.applyButtonState(3)
+ elif count > 0:
+ self.applyButtonState(2)
+ else:
+ self.applyButtonState(1)
+ days = [ _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun") ]
+ datastr = ""
+ event = self["list"].getCurrent()[0]
+ if event is not None:
+ now = time()
+ beg = event.getBeginTime()
+ nowTime = localtime(now)
+ begTime = localtime(beg)
+ if nowTime[2] != begTime[2]:
+ datestr = '%s %d.%d.'%(days[begTime[6]], begTime[2], begTime[1])
+ else:
+ datestr = '%s %d.%d.'%(_("Today"), begTime[2], begTime[1])
+ self["date"].setText(datestr)
diff --git a/lib/python/Screens/EventView.py b/lib/python/Screens/EventView.py
index d96be6d6..95c875f5 100644
--- a/lib/python/Screens/EventView.py
+++ b/lib/python/Screens/EventView.py
@@ -1,5 +1,6 @@
from Screen import Screen
from Components.ActionMap import ActionMap
+from Components.Button import Button
from Components.Label import Label
from Components.ScrollLabel import ScrollLabel
from enigma import eServiceEventPtr
@@ -7,9 +8,8 @@ from ServiceReference import ServiceReference
from RecordTimer import RecordTimerEntry, parseEvent
from TimerEntry import TimerEntry
-class EventView(Screen):
- def __init__(self, session, Event, Ref, callback=None):
- Screen.__init__(self, session)
+class EventViewBase:
+ def __init__(self, Event, Ref, callback=None):
self.cbFunc = callback
self.currentService=Ref
self.event = Event
@@ -17,6 +17,10 @@ class EventView(Screen):
self["datetime"] = Label()
self["channel"] = Label()
self["duration"] = Label()
+ self["key_red"] = Button(_(""))
+ self["key_green"] = Button(_("Add Timer"))
+ self["key_yellow"] = Button(_(""))
+ self["key_blue"] = Button(_(""))
self["actions"] = ActionMap(["OkCancelActions", "EventViewActions"],
{
"cancel": self.close,
@@ -49,7 +53,7 @@ class EventView(Screen):
if (answer[0]):
self.session.nav.RecordTimer.record(answer[1])
else:
- print "Timeredit aborted"
+ print "Timeredit aborted"
def setService(self, service):
self.currentService=service
@@ -77,6 +81,25 @@ class EventView(Screen):
def pageUp(self):
self["epg_description"].pageUp()
-
+
def pageDown(self):
self["epg_description"].pageDown()
+
+class EventViewSimple(Screen, EventViewBase):
+ def __init__(self, session, Event, Ref, callback=None):
+ Screen.__init__(self, session)
+ self.skinName = "EventView"
+ EventViewBase.__init__(self, Event, Ref, callback)
+
+class EventViewEPGSelect(Screen, EventViewBase):
+ def __init__(self, session, Event, Ref, callback=None, singleEPGCB=None, multiEPGCB=None):
+ Screen.__init__(self, session)
+ self.skinName = "EventView"
+ EventViewBase.__init__(self, Event, Ref, callback)
+ self["key_yellow"].setText(_("Single EPG"))
+ self["key_blue"].setText(_("Multi EPG"))
+ self["epgactions"] = ActionMap(["EventViewEPGActions"],
+ {
+ "openSingleServiceEPG": singleEPGCB,
+ "openMultiServiceEPG": multiEPGCB
+ })
diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py
index 605a15fd..2da8a4bd 100644
--- a/lib/python/Screens/InfoBarGenerics.py
+++ b/lib/python/Screens/InfoBarGenerics.py
@@ -18,7 +18,7 @@ from EpgSelection import EPGSelection
from Screens.MessageBox import MessageBox
from Screens.Dish import Dish
from Screens.Standby import Standby
-from Screens.EventView import EventView
+from Screens.EventView import EventViewEPGSelect
from Screens.MinuteInput import MinuteInput
from Components.Harddisk import harddiskmanager
@@ -305,59 +305,18 @@ class InfoBarEPG:
def __init__(self):
self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions",
{
- "showEPGList": (self.showEPG, _("show EPG...")),
+ "showEventInfo": (self.openEventView, _("show EPG...")),
})
- def showEPG(self):
- if currentConfigSelectionElement(config.usage.epgtoggle) == "yes":
- self.openSingleServiceEPG()
- else:
- self.showEPGList()
-
- def showEPGList(self):
- bouquets = self.servicelist.getBouquetList()
- if bouquets is None:
- cnt = 0
- else:
- cnt = len(bouquets)
- if cnt > 1: # show bouquet list
- self.session.open(BouquetSelector, bouquets, self.openBouquetEPG)
- elif cnt == 1: # add to only one existing bouquet
- self.openBouquetEPG(bouquets[0][1])
- else: #no bouquets so we open single epg
- self.openSingleEPGSelector(self.session.nav.getCurrentlyPlayingServiceReference())
-
- def bouquetEPGCallback(self, info):
- if info:
- self.openSingleServiceEPG()
-
- def singleEPGCallback(self, info):
- if info:
- self.showEPGList()
-
- def openEventView(self):
- try:
- self.epglist = [ ]
- service = self.session.nav.getCurrentService()
- info = service.info()
- ptr=info.getEvent(0)
- if ptr:
- self.epglist.append(ptr)
- ptr=info.getEvent(1)
- if ptr:
- self.epglist.append(ptr)
- if len(self.epglist) > 0:
- self.session.open(EventView, self.epglist[0], ServiceReference(ref), self.eventViewCallback)
- except:
- pass
-
- def openSingleServiceEPG(self):
- ref=self.session.nav.getCurrentlyPlayingServiceReference()
- ptr=eEPGCache.getInstance()
- if ptr.startTimeQuery(ref) != -1:
- self.session.openWithCallback(self.singleEPGCallback, EPGSelection, ref)
- else: # try to show now/next
- print 'no epg for service', ref.toString()
+ def zapToService(self, service):
+ if not service is None:
+ if self.servicelist.getRoot() != self.epg_bouquet: #already in correct bouquet?
+ self.servicelist.clearPath()
+ if self.servicelist.bouquet_root != self.epg_bouquet:
+ self.servicelist.enterPath(self.servicelist.bouquet_root)
+ self.servicelist.enterPath(self.epg_bouquet)
+ self.servicelist.setCurrentSelection(service) #select the service in servicelist
+ self.servicelist.zap()
def openBouquetEPG(self, bouquet):
ptr=eEPGCache.getInstance()
@@ -372,28 +331,53 @@ class InfoBarEPG:
continue
services.append(ServiceReference(service))
if len(services):
- self.session.openWithCallback(self.bouquetEPGCallback, EPGSelection, services)
+ self.epg_bouquet = bouquet
+ self.session.openWithCallback(self.closed, EPGSelection, services, self.zapToService)
+
+ def closed(self, ret):
+ if ret:
+ self.close(ret)
- def openSingleEPGSelector(self, ref):
+ def openMultiServiceEPG(self):
+ bouquets = self.servicelist.getBouquetList()
+ if bouquets is None:
+ cnt = 0
+ else:
+ cnt = len(bouquets)
+ if cnt > 1: # show bouquet list
+ self.session.openWithCallback(self.closed, BouquetSelector, bouquets, self.openBouquetEPG)
+ elif cnt == 1:
+ self.openBouquetEPG(bouquets[0][1])
+
+ def openSingleServiceEPG(self):
+ ref=self.session.nav.getCurrentlyPlayingServiceReference()
ptr=eEPGCache.getInstance()
- if ptr.startTimeQuery(ref) != -1:
- self.session.open(EPGSelection, ref)
- else: # try to show now/next
- print 'no epg for service', ref.toString()
- try:
- self.epglist = [ ]
- service = self.session.nav.getCurrentService()
- info = service.info()
- ptr=info.getEvent(0)
- if ptr:
- self.epglist.append(ptr)
- ptr=info.getEvent(1)
+ self.session.openWithCallback(self.closed, EPGSelection, ref)
+
+ def openEventView(self):
+ self.epglist = [ ]
+ service = self.session.nav.getCurrentService()
+ ref = self.session.nav.getCurrentlyPlayingServiceReference()
+ info = service.info()
+ ptr=info.getEvent(0)
+ if ptr:
+ self.epglist.append(ptr)
+ ptr=info.getEvent(1)
+ if ptr:
+ self.epglist.append(ptr)
+ if len(self.epglist) == 0:
+ epg = eEPGCache.getInstance()
+ ptr = epg.lookupEventTime(ref, -1)
+ if ptr:
+ self.epglist.append(ptr)
+ ptr = epg.lookupEventTime(ref, ptr.getBeginTime(), +1)
if ptr:
self.epglist.append(ptr)
- if len(self.epglist) > 0:
- self.session.open(EventView, self.epglist[0], ServiceReference(ref), self.eventViewCallback)
- except:
- pass
+ if len(self.epglist) > 0:
+ self.session.open(EventViewEPGSelect, self.epglist[0], ServiceReference(ref), self.eventViewCallback, self.openSingleServiceEPG, self.openMultiServiceEPG)
+ else:
+ print "no epg for the service avail.. so we show multiepg instead of eventinfo"
+ self.openMultiServiceEPG()
def eventViewCallback(self, setEvent, setService, val): #used for now/next displaying
if len(self.epglist) > 1: